Subj : File access - BAJA
To : Jim King
From : PistolGrip
Date : Mon Apr 02 2001 02:58 pm
RE: File access - BAJA
BY: Jim King to ALL on Mon Apr 02 2001 06:12 pm
> Would someone be willing to write and explain a simple (short) program
> that reads from and writes to a file in Baja?
This is an example using a binary file.
##### START ##############################################################
!include file_io.inc
# Variable Definitions
int file_handle
int number
int number2
# Sets a variable to a value
set number2 25
# Open file
fopen file_handle O_RDWR "%n..\baja\somedir\somefile.dat"
if_false
print "\r\n\r\nnError Loading File"
pause
return
end_if
fread file_handle number 4 # reads 4 bytes from file
fset_pos file_handle 20 SEEK_CUR # sets file position ahead 20 bytes
fwrite file_handle number2 4 # writes number2 to file with 4 bytes
fclose file_handle
##### END ##############################################################
Hope this helps.
PG
---
� Synchronet � WasteLand BBS � telnet://wasteland.darktech.org