Writing messages to a file (#MSG SAVE)
The command #MSG SAVE saves data directly from the NC program to a file on a storage device (e.g. hard disk). The possibilities of structuring a message text and logging data are fully identical to the scope of the commands #MSG or #MSG INFO.
Syntax: |
#MSG SAVE [EXCLUSIVE] [CONTINUE] ["<message_text>"] |
It is not necessary to specify a mode (SYN) or a receiver ID (e.g. HMI) as this would produce an error message since the message is written directly to the report file in the NC program after evaluation.
The message text must be enclosed in quotation marks "...". Every time #MSG SAVE is called, the message text is added to the end of the report file that already exists. To create a new report file, the user should delete an existing file before NC program start .
#MSG SAVE ["message text "] writes the message text to the report file in the format
< time stamp >
"message text".
#MSG SAVE EXCLUSIVE ["message text"] writes the message text to the report file without time stamp in the format
"message text”
.
#MSG SAVE CONTINUE ["message text"] can suppress a line break at the end of the message text. The next #MSG SAVE command then writes in the same line as the previous #MSG SAVE command.
The name of the report file can be previously defined with the command #FILE NAME. If this command is not used, #MSG SAVE automatically writes to a file with the name message.txt.
The output file path is defined in the start-up list by P-STUP-00018 using the path type P-STUP-00020. If no path information is entered for the report file, a default path is used depending on the control platform or the report file is stored in the main directory of the NC controller.
Programing Example
Writing messages to a file
: |
|
#FILE NAME [MSG="example.txt"] | ;Name of output file |
: | |
#MSG SAVE["Hello World %d",12345] | ;Write text "Hello World 12345" in output file example.txt |
: |
|