Revision history for KeyPgFreefile


Revision [21950]

Last edited on 2017-10-11 03:05:42 by fxm [Added a link to FileAttr]
Additions:
- ##[[KeyPgFileattr|FileAttr]]##


Revision [21825]

Edited on 2017-08-19 18:13:54 by MrSwiss [Replaced 'integer' with 'long' in Example Code (proper FreeFile return)]
Additions:
Dim buffer As String, f as long
dim as long fr, fs
dim as long fr, fs
Deletions:
Dim buffer As String, f as integer
dim fr as integer, fs as integer
dim fr as integer, fs as integer


Revision [20932]

Edited on 2016-03-13 01:50:10 by fxm [Formatting]
Additions:



Revision [20250]

Edited on 2016-02-10 16:00:47 by DkLwikki [Update link format]
Additions:
[[KeyPgDeclare|declare]] [[KeyPgFunction|function]] **Freefile** ( ) [[KeyPgAs|as]] [[KeyPgLong|long]]
Returns the number of the next free file number with valid values ##1## to ##255##, or ##0## if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen|Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers.
##**Freefile**## will always return the smallest free file number. The file number returned by ##**Freefile**## will not change until that file number is ##[[KeyPgOpen|Open]]##ed, or until a smaller file number is ##[[KeyPgClose|Close]]##d. For this reason, it is wise to use ##**Freefile**## immediately before its corresponding ##[[KeyPgOpen|Open]]##, to ensure that the file number is not returned and opened elsewhere first.
When using multiple ##**Freefile**## statements, ##**Freefile**## should be used immediately before the ##[[KeyPgOpen|Open]]## statement:
- ##[[KeyPgOpen|Open]]##
- ##[[KeyPgPutfileio|Put (File I/O)]]##
- ##[[KeyPgGetfileio|Get (File I/O)]]##
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Freefile** ( ) [[KeyPgAs as]] [[KeyPgLong long]]
Returns the number of the next free file number with valid values ##1## to ##255##, or ##0## if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers.
##**Freefile**## will always return the smallest free file number. The file number returned by ##**Freefile**## will not change until that file number is ##[[KeyPgOpen Open]]##ed, or until a smaller file number is ##[[KeyPgClose Close]]##d. For this reason, it is wise to use ##**Freefile**## immediately before its corresponding ##[[KeyPgOpen Open]]##, to ensure that the file number is not returned and opened elsewhere first.
When using multiple ##**Freefile**## statements, ##**Freefile**## should be used immediately before the ##[[KeyPgOpen Open]]## statement:
- ##[[KeyPgOpen Open]]##
- ##[[KeyPgPutfileio Put (File I/O)]]##
- ##[[KeyPgGetfileio Get (File I/O)]]##


Revision [17497]

Edited on 2015-04-01 11:45:44 by DkLwikki [integer => long]
Additions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Freefile** ( ) [[KeyPgAs as]] [[KeyPgLong long]]
Deletions:
[[KeyPgDeclare declare]] [[KeyPgFunction function]] **Freefile** ( ) [[KeyPgAs as]] [[KeyPgInteger integer]]


Revision [15068]

Edited on 2011-04-12 12:26:11 by CountingPine [integer => long]
Additions:
' The WRONG way:
Deletions:
' The WRONG way:


Revision [15067]

Edited on 2011-04-12 12:24:37 by CountingPine [More clarification on usage]
Additions:
Returns the number of the next free file number with valid values ##1## to ##255##, or ##0## if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers.
Make sure to always close files when no longer needed, otherwise you will get a file number leak, and won't be able to open any files anymore after 255 filenumbers are exhausted while your program is running.
##**Freefile**## will always return the smallest free file number. The file number returned by ##**Freefile**## will not change until that file number is ##[[KeyPgOpen Open]]##ed, or until a smaller file number is ##[[KeyPgClose Close]]##d. For this reason, it is wise to use ##**Freefile**## immediately before its corresponding ##[[KeyPgOpen Open]]##, to ensure that the file number is not returned and opened elsewhere first.
' The CORRECT way:
OPEN "File2" FOR INPUT AS #fs
fs = FREEFILE '' fs has taken the same file number as fr
OPEN "file2" FOR INPUT AS #fs '' error: file number already opened
Deletions:
Returns the number of the next free file number with valid values ##1## to ##255##, or ##0## if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers. Make sure to always close files when no longer needed, otherwise you will get a filenumber leak, and won't be able to open any files anymore after 255 filenumbers are exhausted while your program is running. All opened files will get closed automatically at program termination.
' The CORRECT WAY:
OPEN "file2" FOR INPUT AS #fs
OPEN "file2" FOR INPUT AS #fs


Revision [14880]

Edited on 2010-10-16 21:38:04 by CountingPine [ZERO to zero/0, Close *#f* in example, formatting]
Additions:
The next available file number, if any, otherwise zero (##0##).
Returns the number of the next free file number with valid values ##1## to ##255##, or ##0## if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers. Make sure to always close files when no longer needed, otherwise you will get a filenumber leak, and won't be able to open any files anymore after 255 filenumbers are exhausted while your program is running. All opened files will get closed automatically at program termination.
Close #f
Deletions:
The next available file number or ZERO.
Returns the number of the next free file number with valid values 1 to 255, or ZERO if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers. Make sure to always close files when no longer needed, otherwise you will get a filenumber leak, and won't be able to open any files anymore after 255 filenumbers are exhausted while your program is running. All opened files will get closed automatically at program termination.
Close


Revision [14864]

Edited on 2010-10-14 21:13:16 by DoS386 [0.21 has 254 ||| 0.22 has 255 limit]
Additions:
The next available file number or ZERO.
Returns the number of the next free file number with valid values 1 to 255, or ZERO if there are already 255 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers. Make sure to always close files when no longer needed, otherwise you will get a filenumber leak, and won't be able to open any files anymore after 255 filenumbers are exhausted while your program is running. All opened files will get closed automatically at program termination.
- Besides ""FreeBASIC's"" limit of 255 files per program opened at same time, there is an OS limit of total amount of opened files, but usually you won't touch it except in DOS, where the limit may be as low as 15 files total.
Deletions:
The next available file number.
Returns the number of the next free file number with valid values 1 to 254, or ZERO if there are already 254 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers. Make sure to always close files when no longer needed, otherwise you will get a filenumber leak, and won't be able to open any files anymore after 254 filenumbers are exhausted while your program is running. All opened files will get closed automatically at program termination.
- Besides ""FreeBASIC's"" limit of 254 files per program opened at same time, there is an OS limit of total amount of opened files, but usually you won't touch it except in DOS, where the limit may be as low as 15 files total.


Revision [14860]

Edited on 2010-10-12 02:05:43 by DoS386 [fixed leak]
Additions:
Returns the number of the next free file number with valid values 1 to 254, or ZERO if there are already 254 files opened. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers. Make sure to always close files when no longer needed, otherwise you will get a filenumber leak, and won't be able to open any files anymore after 254 filenumbers are exhausted while your program is running. All opened files will get closed automatically at program termination.
- Besides ""FreeBASIC's"" limit of 254 files per program opened at same time, there is an OS limit of total amount of opened files, but usually you won't touch it except in DOS, where the limit may be as low as 15 files total.
Deletions:
Returns the number of the next free file number. This value is a required argument to ##[[KeyPgOpen Open]]## a file. ##**Freefile**## is useful when opening files in complex programs where the programmer can't keep track of the used file numbers.


Revision [12700]

The oldest known version of this page was created on 2008-03-11 16:36:18 by JeffMarshall [fixed leak]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki



sf.net phatcode