Navigation:  Операции с файлами и директориями >

Пример2 работы с файлами

Previous pageReturn to chapter overviewNext page

DEFINE FILE

FILE(test),name('test4.fms'),create,driver(ASCII),record(var0(10),var1(10),var2(2))

FILE(test2),name('test4.fm'),create,driver(BASIC),record(var0(20),var1(20),var2(20)),separator(';'),quotes('"')

FILE(out),name('outd.txt'),create,oem,driver(DOS),record(var0(10),var1(10),var2(2))

enddefine

 

open file test OF:READ

open file test2 OF:READWRITE

 

loop 30 times

read file test

if [:FILEERRORCODE:] <> 0

  log ERROR: [:FILEERROR:]

  break

endif

write file test2

if [:FILEERRORCODE:] <> 0

  log TEST2: ERROR: [:FILEERROR:]

  break

endif

endloop

close file test

close file test2

 

open file test2 OF:READWRITE

open file out OF:READWRITE

loop

read file test2

if [:FILEERRORCODE:] <> 0

  log ERROR: [:FILEERROR:]

  break

endif

write file out

if [:FILEERRORCODE:] <> 0

  log out: ERROR: [:FILEERROR:]

  break

endif

endloop

close file out