AppendText

Top  Previous  Next

 

The AppendText command allows you to add text to an existing text file. A common use for this is to write information to custom data files or log files.

lamp Important: If the specified file is not a text file, the text will not be written and an error will be thrown.

Command Syntax

 

AppendText:[TargetFileName],[NewText],[NewLineOption]

 

The colon after the command and the comma between parameters are compulsory. Any additional spaces or characters will cause an error to be thrown. The command itself is not case sensitive, but parameters may be depending on the operating system and locale.

 

Parameters:

 

TargetFileName: The fully qualified path and file name of the file to which the text should be appended

NewText: The text to be appended

NewLineOption: Text equivalent to a member of the NewLineOption enumeration which determines whether the text has new lines before or after the appended text.

 

The TargetFileName and NewText parameters are compulsory. If the parameter is missing an error will be thrown.

 

The NewLine parameter is optional. Valid values are:

 

None - no new line characters will be added. If you do not specify a parameter this is the default setting.

NewLineAfter - the NewLine character or character set for the current operating system will be added after the new text.

NewLineBefore - the NewLine character or character set for the current operating system will be added before the new text.

NewLineBeforeIfNotPresent - the NewLine character or character set for the current operating system will be added before the new text .

NewLineBeforeAndAfter - the NewLine character or character set for the current operating system will be added before and after the new text.a blank line will be added before  the remark text.

NewLineBeforeIfNotPresentAndAfter - the NewLine character or character set for the current operating system will be added before the new text if a Newline character does not already exist, and a further NewLine will be added after the text.

 

The TargetFileName parameter must be surrounded by quotation marks. The NewText parameter can be any text, but must have a value and must be surrounded by quotation marks if it contains any characters that could be detected as special characters, such as the colon, backslash, forward slash, etc.It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts

 

Example:

 

Append text only:

 

AppendText:"C:\Test Text.txt","This is the new text",None

 

Append text with a blank line before and after:

 

AppendText:"C:\Test Text.txt","This is the new text",NewLineBeforeAndAfter

 

See Also: Special Functions Variables Subs