PutString - write a string to a file

Return to Introduction  Previous page  Next page

PutString("text",filename,{create | append}[,onErrorLabel:])

 
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.
onErrorLabel:is 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 $FILEERROR 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

' This script writes the screen contents to a file.

'

$FileName = f:\script\PutStringFile.txt

$Position = 1

$Columns = 80

$MaxPosition = 1920

 

' Write Screen contents line by line to the file

LOOP:

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

$Position = $Position,+,$Columns

if $Position < $MaxPosition then GoTo LOOP:

 

Exit

 

See Also:

 

GetString Command

Script Command Summary

Script Variables

Using the Scripting Language

 


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