Manejo de archivos
De ArcoWiki
Write to file
The command WRITE/ is used to write and store data in an open file.
$$ Example of Write Command
DECL/CHAR,50,filnm,elnmDECL/INTGR,iDECL/DOUBLE,xx,yy,zz
TEXT/QUERY,(filnm),50,A,L,'insert file name'filnm=ASSIGN/CONCAT('C:\',filnm,'.TXT')DID(F1)=DEVICE/STOR,filnm
$$ This is to create some dummy points.
F(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0F(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0F(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0FA(POI_1)=FEAT/POINT,CART, 1.111,2.222,3.333, 0,0,0FA(POI_2)=FEAT/POINT,CART, 4.444,5.555,6.666, 0,0,0FA(POI_3)=FEAT/POINT,CART, 7.777,8.888,9.999, 0,0,0
$$ This row opens the file as an output device.
OPEN/DID(F1),DIRECT,OUTPUT,OVERWRDO/i,1,3$$ Get the values from pointselnm=ASSIGN/CONCAT('poi_',STR(i))xx=OBTAIN/FA(@elnm),3yy=OBTAIN/FA(@elnm),4zz=OBTAIN/FA(@elnm),5
$$ Write command writes in the output file the required valuesWRITE/DID(F1),xxWRITE/DID(F1),yyWRITE/DID(F1),zz
ENDDO
CLOSE/DID(F1)
Read from file
The command READ/ is used to get a value from an open file.
$$ Example of Read command
DECL/CHAR,50,filnm, resultDECL/CHAR,50,xyzDECL/DOUBLE,xx,yy,zzTEXT/QUERY,(filnm),50,A,L,'insert file name'filnm=ASSIGN/CONCAT('C:\',filnm,'.TXT')DID(F1)=DEVICE/STOR,filnm
$$ This row opens the file as an input device.
OPEN/DID(F1),DIRECT,INPUT$$ Read command reads values from the input file and declare a pointREAD/DID(F1),xxREAD/DID(F1),yyREAD/DID(F1),zzF(POI_10)=FEAT/POINT,CART, xx,yy,zz, 0,0,0FA(POI_10)=FEAT/POINT,CART, xx,yy,zz, 0,0,0$$ Read command reads values from the input file and declare a pointREAD/DID(F1),xxREAD/DID(F1),yyREAD/DID(F1),zzF(POI_20)=FEAT/POINT,CART, xx,yy,zz, 0,0,0FA(POI_20)=FEAT/POINT,CART, xx,yy,zz, 0,0,0
$$ Read command reads values from the input file and declare a pointREAD/DID(F1),xxREAD/DID(F1),yyREAD/DID(F1),zzF(POI_30)=FEAT/POINT,CART, xx,yy,zz, 0,0,0FA(POI_30)=FEAT/POINT,CART, xx,yy,zz, 0,0,0result=ASSIGN/CONCAT(STR(xx),' , ',STR(yy),' , ',STR(zz))TEXT/OPER,result
CLOSE/DID(F1)