Oxygen Basic
Programming => Problems & Solutions => Topic started by: chrisc on April 25, 2018, 08:08:58 AM
-
In PB there is a FREEFILE function which gets the next available file number or channel
before we can open a new file
http://manmrk.net/tutorials/basic/PowerBASIC/pbcc/freefile_function.htm (http://manmrk.net/tutorials/basic/PowerBASIC/pbcc/freefile_function.htm)
which i think is not needed in O2. am i correct?
-
If you are using whole files then we have GetFile and PutFile which do not require handles. Otherwise, a sys variable is used as a file handle:
use corewin
string s
sys e,f
'EQUIVALENT TO: S=GETFILE "T.TXT"
f=fopen "t.txt","r" 'open for reading
print f 'file handle or null
fseek f,0,2 'end of file
e=ftell f 'get position
print e 'length of file
fseek f,0,0 'beginning of file
s=nuls e 'create buffer to fit
fread s,1,e,f 'load buffer
fclose f 'close file
-
Thanxx a lot Charles
O2 is much better than the PB FREEFILE and other file functions as it involves more code lines to read a file
in your program above, i notice that you can read the entire file into a buffer string s
then what would be the maximum file size that can be read into this string s ?
is this process called a Binary file read ?
-
For GetFile and PutFile, there is no distinction between binary and text, and the theoretical upper limit for an OLEstring is around 2 Gig: 0x7FFFFFFF, so you will have to split your DVD files down a bit for editing :)