1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 06:15:52 +00:00
QB64-PE/internal/help/FOR_(file_statement).txt
SMcNeill 6e01fc8dce Altered string compare routines (<,<=,>,>=) so they don't give false results with CHR$(0).
Added new _STRCMP and _STRICMP commands for quick string comparisons.
Cleaned up QB64 to finish removing the QUI (quick user insert) code and folders.
Altered UCASE and LCASE routines to be faster in some situations for us.
2014-09-22 08:19:03 -04:00

62 lines
2 KiB
Plaintext

{{KW|FOR (file statement)|FOR}} is used in a {{KW|OPEN}} statement to select the filemode to open the file with.
{{PageSyntax}}
:{{KW|OPEN}} ... {{KW|FOR (file statement)|FOR}} {APPEND|BINARY|INPUT|OUTPUT|RANDOM}
{{PageDescription}}
* If {{KW|FOR (file statement)|FOR}} isn't used in a {{KW|OPEN}} statement then the default filemode {{KW|RANDOM}} is used.
** {{KW|APPEND}} - Keeps the information of the file intact while you can insert information at the end of it, writing permission only.
** {{KW|BINARY}} - Opens the file in binary mode, use this with binary files.
** {{KW|INPUT (file mode)|INPUT}} - Opens the file for viewing only.
** {{KW|OUTPUT}} - The entire contents of the file is erased while you can put new information inside it, writing permission only.
** {{KW|RANDOM}} - The default, you can get/put records defined by a record length (the variables type or LEN=length).
{{PageExamples}}
'''Warning:''' ''Make sure you don't have a file named test.tst before you run this! It will be overwritten if so!''
{{CodeStart}}
{{Cl|CLS}}
{{Cl|OPEN}} &quot;test.tst&quot; {{Cl|FOR (file statement)|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1
{{Cl|PRINT (file statement)|PRINT}} #1, &quot;If test.tst didn't exist:&quot;
{{Cl|PRINT (file statement)|PRINT}} #1, &quot;A new file was created named test.tst and then deleted.&quot;
{{Cl|PRINT (file statement)|PRINT}} #1, &quot;If test.tst did exist:&quot;
{{Cl|PRINT (file statement)|PRINT}} #1, &quot;It was overwritten with this and deleted.&quot;
{{Cl|CLOSE}} #1
{{Cl|OPEN}} &quot;test.tst&quot; {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #1
{{Cl|DO}} {{Cl|UNTIL}} {{Cl|EOF}}(1)
{{Cl|INPUT (file statement)|INPUT}} #1, a$
{{Cl|PRINT}} a$
{{Cl|LOOP}}
{{Cl|CLOSE}} #1
{{Cl|KILL}} &quot;test.tst&quot;
{{Cl|END}}
{{CodeEnd}}
{{OutputStart}}
If test.tst didn't exist:
A new file was created named test.tst and then deleted.
If test.tst did exist:
It was overwritten with this and deleted.
{{OutputEnd}}
{{PageSeeAlso}}
* {{KW|OPEN}}
{{PageNavigation}}