"Fossies" - the Fresh Open Source Software Archive

Member "FreeBASIC-1.05.0-linux-x86_64/examples/manual/fileio/open.bas" (31 Jan 2016, 762 Bytes) of package /linux/privat/FreeBASIC-1.05.0-linux-x86_64.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Visual Basic source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 '' examples/manual/fileio/open.bas
    2 ''
    3 '' NOTICE: This file is part of the FreeBASIC Compiler package and can't
    4 ''         be included in other distributions without authorization.
    5 ''
    6 '' See Also: http://www.freebasic.net/wiki/wikka.php?wakka=KeyPgOpen
    7 '' --------
    8 
    9 ' Create a string and fill it.
   10 Dim buffer As String, f As Integer
   11 buffer = "Hello World within a file."
   12 
   13 ' Find the first free file number.
   14 f = FreeFile
   15 
   16 ' Open the file "file.ext" for binary usage, using the file number "f".
   17 Open "file.ext" For Binary As #f
   18 If Err>0 Then Print "Error opening the file":End
   19 
   20 ' Place our string inside the file, using number "f".
   21 Put #f, , buffer
   22 
   23 ' Close all open files.  
   24 Close
   25 
   26 ' End the program. (Check the file "file.ext" upon running to see the output.)
   27 End