PutString - write a string to a file

Return to Introduction  Previous page  Next page

PutString "text",filename,{create | append}[,label:]

Where:

textis the text to write to the file.        
filenameis the full filename, including drive letter and path name for the output file. This file must be a text file. Enclose the filename in double quotation marks ("") if it contains embedded spaces or commas.
createCreate a new file. If a file with the same name already exits, it is deleted.
appendAppend text to an existing file. If the file does not exist, it is created.
labelis the label of an error handler routine. The script branches to this routine if the I/O fails. The I/O error handler routine can use the $FILESTAT variable to get the cause of the error. If this parameter is omitted, the user will be prompted with the script error dialog box which allows the command to be retried or ignored.

 

text and filename may be variables.

The PutString command writes a line of text to a file.

Examples

PutString        "This is a test",c:\test.txt,create

PutString        "This is a test",c:\test.txt,create,IOError:

PutString        $SCREEN(1,80),$FileName,append

Sample Script

* PutString.txt

* Sample script to write to a file

*

SetVar $FileName,f:\script\PutStringFile.txt

SetVar $Position,1

SetVar $Columns,80

SetVar $MaxPosition,1920

 

* Write Screen contents line by line to the file

LOOP:

PutString $SCREEN($Position,$Columns),$FileName,append

CalcVar $Position,$Position,+,$Columns

if $Position,LT,$MaxPosition,LOOP:

 

Exit

 

See Also:

 

Script Command Summary

Script Variables

Using the Scripting Language

GetString Command


TN3270 Plus is continually being improved. To learn more about the latest enhancements, please review our Version History web page.