Option GlobalKeys Enabled 
Option Speed 9

' -------------------------------------- Slots
Variable Numeric Slot_MotorX =  1
Variable Numeric Slot_MotorY =  2
Variable Numeric Slot_MotorZ =  3

' -------------------------------------- X limits
Variable Numeric Xmin = 0
Variable Numeric Xmax = 999
Variable Numeric Ymin = 0
Variable Numeric Ymax = 999
Variable Numeric Zmin = 0
Variable Numeric Zmax = 999

' -------------------------------------- Key Jog Speed
Variable Numeric KeyJog_Speed  = 100

' ----------------------------------------- KEYS
Key Up       Gosub ExecKeys
Key Down     Gosub ExecKeys
Key Left     Gosub ExecKeys
Key Right    Gosub ExecKeys
Key Pageup   Gosub ExecKeys
Key Pagedown Gosub ExecKeys

Controls OpenTextBox
Controls ClearTextBox
Print CRLF + " PRESS KEYBOARD ARROWS" + CRLF
Stop

' ====================================================================
'  JOG with keyboard
' ====================================================================
Label ExecKeys
	Variable Numeric JogSpeed
	JogSpeed = KeyJog_Speed / 100
	Select True
		Case Key("SHIFT")
			JogSpeed = JogSpeed * 0.1
		Case Key("CTRL")
			JogSpeed = JogSpeed * 0.01
		Case Key("ALT")
			JogSpeed = JogSpeed * 0.001
	EndSelect
	'
	If Key("Up")
		Slot(Slot_MotorY) = Limit(Slot(Slot_MotorY) + JogSpeed, Ymin, Ymax)
	EndIf
	If Key("Down")
		Slot(Slot_MotorY) = Limit(Slot(Slot_MotorY) - JogSpeed, Ymin, Ymax)
	EndIf
	'
	If Key("Left")
		Slot(Slot_MotorX) = Limit(Slot(Slot_MotorX) - JogSpeed, Xmin, Xmax)
	EndIf
	If Key("Right")
		Slot(Slot_MotorX) = Limit(Slot(Slot_MotorX) + JogSpeed, Xmin, Xmax)
	EndIf
	'
	If Key("PageUp")
		Slot(Slot_MotorZ) = Limit(Slot(Slot_MotorZ) + JogSpeed, Zmin, Zmax)
	EndIf
	If Key("PageDown")
		Slot(Slot_MotorZ) = Limit(Slot(Slot_MotorZ) - JogSpeed, Zmin, Zmax)
	EndIf
	'
	If LimitReached
		Load "Sound\ButtonClick3.wav"
	EndIf
	'
	Gosub PrintValues
Return

' ====================================================================
'  PRINT COORDINATES
' ====================================================================
Label PrintValues
	Controls OpenTextBox
	s1 = " " + PadRight("X=" + Format(Slot(Slot_MotorX), "0.000"), 11)
	s1 = s1  + PadRight("Y=" + Format(Slot(Slot_MotorY), "0.000"), 11)
	s1 = s1  + PadRight("Z=" + Format(Slot(Slot_MotorZ), "0.000"), 11)
	Print CRLF + s1
Return


'EXEC Sin2 = Sin(33)
