Home About us Development Training Support |
Create a low level fileThis simple example uses FCREATE() to create a new file. It then writes some text to it and closes the file.
*-- Create a new file ...
lnFileHandle = FCREATE ('fred.txt') *-- ... write some text into the file ... FWRITE (lnFileHandle, 'Hello Mum') *-- ... and close it. FCLOSE (lnFileHandle) This example has ignored any possible errors in the return values from the functions. The most important of these is that FCREATE() returns a value of -1 as the file handle if it cannot create the file. In a real application you must check that you have a valid file handle before you use it in any of the other low-level functions. Another factor I've ignored is the location of the new file. I have just given a simple name for the file so the file will be created in FoxPro's current folder - not necessarily in the same folder as the sample program. By default FCREATE() will create a file with Read/Write access. You can pass a second parameter to create a Hidden, Read-Only or System file. Be careful. The numeric codes for this function are not the same as the codes for the FOPEN() function. WarningYou will have the file locked from the time you open it to the time that you close it. Remember to release the file by calling FCLOSE(). The general command CLOSE ALL will also close any files you have open for low-level access. Other low level topicsLow level overview | FOPEN() | FCLOSE() | FREAD() | FWRITE() |
Hints & tips
The textbox class in Visual FoxPro 9 has a new Autocomplete
property which shows the user the previous values that have
been entered in that textbox.
More...
|