Fopen

The following command opens a file:
Format:
SPECTRA> fo$*$pen file_name[.dat]

Description:
The C run-time function fopen is called to open a file.
/fptr=pointer_symbol
The value of the file pointer is stored in the symbol pointer_symbol. The default symbol name is FILE_PTR.
/access=access_mode
The access mode has to be specified according to the conventions of the language C: 'w' (default), 'r' and 'a'. The attributes for a new file are: 'rat=cr', 'rfm=var'.

e.g.:
In this first example inquire use a symbol (ptr1) to get the file pointer. The symbol has been created by the fopen/acc=r/fptr=ptr1 test command. Eventually fclose/fptr=ptr1 closes the file and deletes the symbol ptr1.

! 
! create test.dat, the file pointer value will 
! be stored internally 
! 
fopen test 
! 
! write three line to test.dat 
! 
say/fptr "das Datum "date() 
say/fptr "die Zeit "time() 
say/fptr "die dritte Zeile " 
fclose 
! 
! inspect the contents of test.dat 
! the file pointer will be stored in PTR1
!
fopen/acc=r/fptr=ptr1 test 
loop: 
! 
! read one line and store it in symbol s1 
! 
inquire/fptr=ptr1 s1 
! 
! use gra_status() to test the eof condition 
! 
if !gra_status() 
  fclose/fptr=ptr1   
  end 
endif 
! 
! display the line 
! 
say s1 
wait 1
goto loop
e.g.:
In the second example inquire uses the internally stored file pointer.

! 
! create test.dat, the file pointer value will 
! be stored internally 
! 
fopen test 
! 
! write three line to test.dat 
! 
say/fptr "das Datum "date() 
say/fptr "die Zeit "time() 
say/fptr "die dritte Zeile " 
fclose 
! 
! inspect the contents of test.dat 
! the file pointer will be stored internally
!
fopen/acc=r test 
loop: 
! 
! read one line and store it in symbol s1 
! 
inquire/fptr s1 
! 
! use gra_status() to test the eof condition 
! 
if !gra_status() 
  fclose
  end 
endif 
! 
! display the line 
! 
say s1 
goto loop