MCL Scripting: Puts Command

Purpose

The purpose of the puts command is to output values from an MCP controller to an external device or the the built-in terminal window. It can be used for communication with external hardware or for debugging an MCL script under development.

Format

The format of this puts command is as follow:

puts stream,[{modifier}Data0,…,{modifier}DataN]

The call to puts, as well as the stream and data arguments are all required, however the modifiers are optional. The stream parameter sets what port on the MCP the data is sent over. The modifiers are used to alter data values so that they display or are interpreted properly when sent to the output device. Below are two tables listing the stream and modifier options.

Stream Parameter

Stream Value Description
0 USB Virtual Communications Port
1 CAN (CANOpen or raw CAN)
2 TTL UART
3 RS232 UART

Output Modifier Parameter

Modifier Value Description
DEC Decimal
SDEC Signed Decimal
HEX Hexadecimal
IHEX Indicated ($) Hexadecimal
REP Repeat character n times
REAL Floating point number with decimal point
STR Write specified number of characters(can be used to copy arrays)

Examples

temp var word
temp = 1234

puts 0,[temp] ;sends the value 1234

temp var word
temp = 1234

puts 0,[DEC temp] ;print the string “1234”

temp var word
temp = 0x12ab

puts 0,[HEX temp] ;prints the string “0x12ab”

temp var float
temp = 3.142

puts 0,[REAL temp] ; prints the string “3.142”