Difference between revisions of "File Handling"
From ArcoWiki
| (3 intermediate revisions by one other user not shown) | |||
| Line 1: | Line 1: | ||
| − | '''Write to file'''<br/> | + | =='''Write to file'''<br/>== |
The command <code>WRITE/</code> is used to write and store data in an open file.<br/> | The command <code>WRITE/</code> is used to write and store data in an open file.<br/> | ||
<code><span style="color: green; text-decoration: none;">$$ Example of Write Command</span><br/></code> | <code><span style="color: green; text-decoration: none;">$$ Example of Write Command</span><br/></code> | ||
| Line 37: | Line 37: | ||
| − | == | + | =='''Read from file'''<br/>== |
| − | |||
| − | '''Read from file'''<br/> | ||
The command <code>READ/</code> is used to get a value from an open file. | The command <code>READ/</code> is used to get a value from an open file. | ||
| Line 73: | Line 71: | ||
::::<code>TEXT/OPER,result<br/></code> | ::::<code>TEXT/OPER,result<br/></code> | ||
::<code>CLOSE/DID(F1)<br/></code> | ::<code>CLOSE/DID(F1)<br/></code> | ||
| + | |||
| + | [[it:Gestione dei file]] | ||
| + | [[zh-cn:文件处理]] | ||
| + | [[pt:Manipulação de arquivos]] | ||
| + | [[de:Dateiverarbeitung]] | ||
| + | [[es:Manejo de archivos]] | ||
| + | [[en:File Handling]] | ||
| + | |||
| + | [[Category:Dmis_Tutorial]] | ||
Latest revision as of 14:34, 6 June 2018
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)