Difference between revisions of "ScriptBasic:UsersGuide 12.3"

From ScriptBasic
Jump to: navigation, search
(New page: [Contents]<br /> :12. File Handling<br /> =12.3. Switching between binary and text mode= [<<<] [[...)
 
(No difference)

Latest revision as of 23:02, 27 December 2007

[Contents]

12. File Handling

12.3. Switching between binary and text mode

[<<<] [>>>]


@cinde binary mode files

Whenever you have opened a file in a mode you may want to switch the mode. You can not switch between reading and writing mode, but you can switch between binary and textual mode. To do this there are two commands:


binmode [#] fn

and


textmode [#] fn

The sign # is optional. The argument fn should be the file number of an opened file. These commands are implemented on the Windows operating system, but can also be used under UNIX with no effect. The use of these commands under UNIX results more portable code.

There are two files automatically opened in almost any environment. These are the standard input and the standard output. You can switch the mode how the program handles these files using these commands. You can say


Binmode input
Binmode output

to switch the standard input and output to binary mode and also


Textmode input
Textmode output

to switch the standard input and output to text mode. Use of these commands is extremely useful writing Windows NT cgi programs that output binary data, for example a png file.


[<<<] [>>>]