' F_LOAD.LST
' load any file
' _____________
FILESELECT "\*.*","",file$
'
' Load only if file exists
IF EXIST(file$)
  PRINT "The file"'file$'"exists."
  ' Determine file length
  file$=file$+CHR$(0)
  VOID GEMDOS(78,L:VARPTR(file$),55)
  length%=LPEEK(GEMDOS(47)+26)
  PRINT "File length:"'length%
  '
  ' Reserve memory space
  ' for example, of string when length%<32767 bytes
  d$=SPACE$(length%)
  d%=VARPTR(d$)
  ' or, for example, reserve field, in GFA BASIC 2.0
  DIM a%(length%/4+4)
  d%=VARPTR(a|(0))
  ' or, for example, reserve field, in GFA BASIC 3.0
  DIM a|(length%)
  d%=VARPTR(a%(0))
  ' allocate fixed memory space, in GFA BASIC 2.0
  RESERVE 10000
  d%=GEMDOS(72,L:length%)
  ' allocate fixed memory space, in GFA BASIC 3.0
  RESERVE 10000
  d%=MALLOC(length%)
  '
  ' Load file
  BLOAD file$,d%
  '
  ' execution of program here
  '
  ' release memory space
  ' character string
  CLR d$
  ' Field, GFA BASIC 2.0
  ERASE a|()
  ' Field, GFA BASIC 3.0
  ERASE a%()
  ' Fixed memory space, GFA BASIC 2.0
  VOID GEMDOS(73,L:d%)
  RESERVE
  ' Fixed memory space, GFA BASIC 3.0
  VOID MFREE(d%)
  RESERVE
ENDIF
