/*
 +---------------------------------------------------------------------------+
 |									     |
 |     Copyright (c) 1990                  The INHEDO Application Developer  |
 |									     |
 |     All rights reserved. No part of this program or publication may be    |
 |     reproduced, transmitted, transcribed, stored in a retrieval system,   |
 |     or translated into any language or computer language, in any form or  |
 |     by any means, electronic, mechanical, magnetic, optical, chemical,    |
 |     biological, or otherwise, without the prior written permission of:    |
 |									     |
 |	      The INHEDO Application Developer   (002) 281-3686	             |
 |									     |
 +---------------------------------------------------------------------------+
 |	@(#)rdpar     	1.0				1/28/90	10:41:37     |
 |	rdpar : Lee parametros de tabla 				     |
 |									     |
 |		Written by Rafael Alcaraz     The Santa Cruz Operation	     |
 +---------------------------------------------------------------------------+
*/
	if (debug) dbgr (1,"ESTO ES rdpar");
	if ((fp=fopen(argv[1],"r")) == NULL) exit(0);
	fscanf(fp,"%d%d%d%d",&nh,&nr,&nc,&df);
	lh=1+nr*6L;
	ld=6L;
	db=1;
	for (i=0;i<nh;i++)
	{
		for (j=0;j<4;j++)
		{
			fscanf(fp,"%d",&m);
			ph[i][j]=m;
		}
		if (ph[i][3]<30||ph[i][3]>49)
		{
			lh +=ph[i][2];
			mm +=ph[i][2];
		}
		if (ph[i][3]>39 &&  ph[i][3]<50)
		{
			fscanf(fp,"%d",&m);
			ph[i][4]=m;
			fscanf(fp,"%d",&m);
			ph[i][5]=m;
			fscanf(fp,"%d",&m);
			ph[i][6]=m;
		}
		if (ph[i][3]>49)
		{
			db=ph[i][3]-49;
			fscanf(fp,"%s",dbr[db][0]);
			fscanf(fp,"%d",&m);
			dbd[db][0]=m;
			fscanf(fp,"%d",&m);
			dbd[db][1]=m;
			ph[i][5]=m;
			fscanf(fp,"%d",&m);
			dbd[db][2]=m;
			ph[i][6]=m;
		}
	}
				
	for(i=0;i<nr;i++)
	{
		for(j=0;j<nc;j++)
		{
			for(k=0;k<4;k++)
			{
				fscanf(fp,"%d",&m);
				pd[i][j][k]=m;
			}
			if (!i&&(pd[i][j][3]<30||pd[i][j][3]>49)) ld +=pd[i][j][2];
			if (!i && pd[i][j][3]>49)
			{
				db=pd[i][j][3]-49;
				fscanf(fp,"%s",dbr[db][0]);
				fscanf(fp,"%d",&dbd[db][0]);
				fscanf(fp,"%d",&dbd[db][1]);
				fscanf(fp,"%d",&dbd[db][2]);
			}
			if (!i && pd[i][j][3]>39 &&  pd[i][j][3]<50)
			{
				fscanf(fp,"%d",&m);
				pd[i][j][4]=m;
				fscanf(fp,"%d",&m);
				pd[i][j][5]=m;
				fscanf(fp,"%d",&m);
				pd[i][j][6]=m;
			}
		}
	}

	fclose(fp);
	sprintf (m2,"PARAMETROS LEIDOS FORM %s",argv[1]);
	dbgr(1,m2);
	sprintf(m1,"%s.0",argv[1]);
	fp=fopen(m1,"r");
	sprintf (m2,"ABRE MASCARA 0 %s",m1);
	j=0;
	while((c=getc(fp))!=EOF) hd[j++]=c;
	fclose(fp);
	sprintf(m1,"%s.1",argv[1]);
	fp=fopen(m1,"r");
	j=0;
	while((c=getc(fp))!=EOF) dc[j++]=c;
	fclose(fp);
	sprintf(m1,"%s.c0",argv[1]);
	fp=fopen(m1,"r");
	i=0;
	while((c=getc(fp))!=EOF)
	{
		clc[i][0]=c;
		fscanf(fp,"%2d",&m);
		clc[i][1]=m;
		j=2;
		while((c=getc(fp))!='\n') clc[i][j++]=c;
		clc[i][j]=0;
		while (clc[i][0] && clc[i][strlen(clc[i])-1]==32) clc[i][strlen(clc[i])-1]=0;
		i++;
	}
	cl1=i;
	fclose(fp);
	sprintf (m2,"ABIERTO E INICIALIZADO FORM %s %d %d %d",argv[1],nh,nr,nc);
	dbgr(1,m2);
