Writing Text Data To A File


[Note: This webpage is intended for users of SiMPLE.]

Click Here to Read About SiMPLE


In Dos-SiMPLE (and in Win-SiMPLE too), all disk files are accessed through "Channels." There are seven channels (designated by the letters A-G) available for use. To create a particular output file you must first open one of the seven channels and specify the name (or path) to the file that you wish to create. You can then begin writing output to the file. When you are finished, you should close the channel so that it knows not to expect any more data.

The following short example program will output 3 lines of text to a file named myfile.txt in the current project folder:

       open a ("write myfile.txt")
       write line a ("This is just some text.")
       write line a ("And this is even more text.")
       write line a ("I think I'll stop now.")
       close a

The program first invokes the system library's opena task to assign an output file named myfile.txt to channel A and open it for writing. (We could have used any of the seven channels.) The program then invokes the writelinea task 3 times to output 3 lines of text. And finally, the closea task is invoked to close the channel.

Another Way Of Doing It

An alternate (but less general) way of having your program generate a text file is to invoke SiMPLE's Output task with the "Output Mode" set to 2. [Output Mode 1 (the default) directs all of Output's output to the screen. Mode 2 directs it to a file named "OUTPUT" in the current project folder. Mode 3 directs it to both places.]:

       output mode (2)
       output ("This is just some text.")
       output ("And this is even more text.")
       output ("I think I'll stop now.")



  [ Webmaster | FAQ's | Home Page | Contact Us ]