The GetFreeFile function returns the Index of a File Channel that is currently NOT in use.
FACTS:
* GetFreeFile will return a ZERO if there are no free channels.
Mini Tutorial:
This examples Requests a free File index, then creates a files and displays it.
; Create file name File$=TempDir$()+"PB_TestFile.txt" ; Get a Free File Channel Index MyFile=GetFreeFile() ; CReate a File for writing data to WriteFile File$,MyFile ; Write a String of the Integer value 5000 WriteString MyFile,"Play Basic" ; Close this file channel CloseFile MyFile Print "============================" Print "Reading File:"+File$ Print "============================" ; Get a Free File Channel Index MyFile=GetFreeFile() ; Open a file to READ with READFILE ReadFile File$,MyFile ; Read and display the String from the file Print ReadString$(myFile) ; Close this file channel CloseFile MyFile If FileExist(file$) Then DeleteFile file$ ; Display the screen and wait for a key press Sync WaitKey |
This example would output. ============================ Reading File:C:\Windows\Temp\Pb_testFile.txt ============================ PlayBasic |
|