-

G-Code Macro $ System Functions


System Functions ¶ 

CommandDescription
$PushModal Save modal state to a stack
$PopModal Load the last saved modal stack off the stack


$Msg Blocks execution with OK dialog
$MsgBOOL Blocks execution with yes/no confirmation dialog
$MsgLREAL Blocks execution asking for a decimal value
$MsgDINT Blocks execution asking for an integer value


$Terminate Clears all buffers, motion is stopped, and all   NC (Internal)   Active    processing is stopped
$InSimulation Returns 1 if in a simulation run, else 0


$NULL Null constant, equivalent to #0
$PI System’s best representation of , approximately 3.141592653589793
$E System’s best representation of , approximately 2.718281828459045


$Alarm Issues an Alarm. See example below.
$Warning Issues a Warning. See example below.
$Info Issues an Info message. See example below.

$PushModal & $PopModal

$MsgBOOL

Example:

// yes/no message box for the user

IF[ $MsgBool["Proceed with cutting operation?"] == 0 ]

G28 XYZ // go home

M30 // end the program here

END

// User selected "ok" rest of the program...

G01  X 100   Y 100

G01  X 150

...


$MsgLREAL

Example:

// get a decimal number from the user

# 100  = $MsgLREAL["Enter feed rate value"]

IF[ #100 == #0] // user must have canceled the dialog

G28 XYZ // go home

M30 // end the program here

END

IF[ #100 <= 0]  $Msg["Feed rate too low! Ending program."]

G28 XYZ // go home

M30 // end the program here

END

IF[ #100 > 1000] // limit the feed rate value to 1000
# 100  = 1000

END

// Now proceed with the program at the given feedrate

G01  X 100   Y 100  F#100

G01  X 150

...


$Alarm, $Warning, and $Info

Example:

# 100  = 0

//Check for divide by zero error

IF[ #100 == 0]

$Alarm["#100 cannot be zero"]

END

# 101  = 50 / #100

...


The UI would display the string variable with the string “Alarm: #100 cannot be zero” and the alarm level integer would be set to 1, allowing conditional coloring, for example setting the background to red. The $Alarm function issues a $Terminate-like command, immediately halting execution. If a warning or info type message were used, execution would proceed uninterrupted. The log file would be prepended with the string and time stamp.

Example Log File:

5-15-2025 14:13.01 Alarm: #100 cannot be zero

5-15-2025 14:10:17 Warning: something might happen

5-13-2025 09:33:59 Info: just so you know...

...


#0

Used for checking if a variable is set or not.

 


This is the latest version of Compass Online help and the content may refer to features not available in previously released versions of Compass.

Copyright © 2026 YASKAWA America, Inc.