1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-20 19:45:15 +00:00
qb64/internal/help/OUTPUT.txt
Luke Ceddia b586eafd3b Integrated _BLINEINPUT into regular LINE INPUT for BINARY files
LINE INPUT will now use the faster method if passed a file handle
that has been opened FOR BINARY. As such, the _BLINEINPUT command
has been removed.

qb64.bas now takes advantage of this for reading from '$include files,
at least in Include Manager 1. Some tweaking of internal/source/main.txt
was required to get things into a sane state, so I'm holing off changing
the compiler any further so the auto-builder can make sure everything's
smoothed over.

Note: Everything should still compile as normal; I'm just being overcautious.
2014-07-27 00:06:17 +10: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$ = "testfile.dat"
x = 1: y = 2: z$ = "Three"
{{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}} "File created with data. Press a key!"
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}}