NOTES‎ > ‎

OPEN, INPUT, OUTPUT


example #1:

!-- Getting NCC Table D1.13 values 

dim value_use[], value_rate[] 

filename= "NCCTableD113.txt" 
ch1=OPEN("TEXT",filename,"SEPARATOR='\t',MODE=RO,LIBRARY") 

!--counting the total number of rows 
row=0 
do 
row= row+1 
n=INPUT(ch1,row,1,string1) 
while n>-1 

!--reading the first column for NCC_TableD113_Use 
for k= 1 to row-1 
n=INPUT(ch1,k,1,string1) 
value_use[k]= string1 
next k 

!--reading the second column for NCC_TableD113_Rate 
for m= 1 to row-1 
n=INPUT(ch1,m,2,string2) 
value_rate[m]= string2 
next m 

CLOSE (ch1) 

VALUES "NCC_TableD113_Use" value_use, custom 


example #2:

!--> file names added 
f1= "File01.txt" 
f2= "File02.txt" 
f3= "File03.txt" 

!--> LIBRARY keyword added 
ch1 = open ("TEXT", f1, "mode = ro,LIBRARY") 
ch2 = open ("TEXT", f2, "separator = '\n', mode = wo,LIBRARY") 
ch3 = open ("TEXT", f3, "separator = '\n', mode = wo,LIBRARY") 


!--> script continues as before 
i = 1 
1: 
n = input (ch1, i, 1, var1, var2, var3, var4) 
if n <> -1 then 
output ch2, 1, 0, var1, var2, var3, var4 
output ch3, 1, 0, var1, var2, var3, var4 
i = i + 1 
goto 1 
else 
goto 2 
endif 
2: 
close ch1 
close ch2 
close ch3 
end


References:
Comments