1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-26 16:45:53 +00:00
QB64-PE/internal/help/OUTPUT.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

49 lines
1.4 KiB
Plaintext

The '''OUTPUT''' file mode is used in an [[OPEN]] statement to send new data to Files or Ports.
{{PageSyntax}}
:: OPEN FileName$ FOR OUTPUT AS #1
* OUTPUT mode erases all previous data in an existing file or clears a port receive buffer!
* Creates an empty file if the filename does not exist. Use [[APPEND]] if previous file data is to be preserved.
* Mode can use [[PRINT (file statement)|PRINT]], [[WRITE (file statement)|WRITE]] or [[PRINT USING (file statement)|PRINT USING]] to output file data.
''Example:'' Writes new data to a text file sequentially and reads it back to the program screen.
{{CodeStart}} '' ''
filename$ = &quot;testfile.dat&quot;
x = 1: y = 2: z$ = &quot;Three&quot;
{{Cl|OPEN}} filename$ {{Cl|FOR...NEXT|FOR}} {{Cl|OUTPUT}} {{Cl|AS}} #1 'opens and clears an existing file or creates new empty file
{{Cl|WRITE (file statement)|WRITE}} #1, x, y, z$
{{Cl|CLOSE}} #1
{{Cl|PRINT}} &quot;File created with data. Press a key!&quot;
K$ = {{Cl|INPUT$}}(1) 'press a key
{{Cl|OPEN}} filename$ {{Cl|FOR (file statement)|FOR}} {{Cl|INPUT (file mode)|INPUT}} {{Cl|AS}} #2 'opens a file to read it
{{Cl|INPUT (file statement)|INPUT}} #2, a, b, c$
{{Cl|CLOSE}} #2
{{Cl|PRINT}} a, b, c$
{{Cl|END}} '' ''
{{CodeEnd}}
''See also:''
* [[APPEND]], [[RANDOM]]
* [[INPUT (file mode)]], [[BINARY]]
* [[WRITE]], [[INPUT (file statement)]]
{{PageNavigation}}