'╔══════════════════════════════════════════════════════════════╗
'║     Name: WinGoSCARA_ZM1M2_V3.txt          Date: 11 Mar 2022 ║
'║   Author: Leonardo DE PALO Ph.D.                             ║
'║    Scope: SCARA management                                   ║
'╟──────────────────────────────────────────────────────────────╢
'║ Hardware: Standard Master and stepper driver                 ║
'║           Limit switches                                     ║
'║           Vacumm motor, valve and sensor                     ║
'║           Red/Green light                                    ║
'║           Voice messages                                     ║
'╚══════════════════════════════════════════════════════════════╝
' ============================= HARDWARE
' MicroStepper stepper 1/32 stepper as  step for run
' Gear ratio for M0 and M1 1:4   Step x mm = 800 x 360 / 360 = 59.556 ???????????
' Leadscrew: 4mm for one turn
'
' ============================= HARDWARE SET UP DVR8825
' Motor M1 current 200 mA
' Microstep "ABC" 32 Speed 40000 Acc 250 Step/mm 74.2   reduction ratio   4:1
' Motor M2 current 200 mA
' Microstep "ABC" 32 Speed 50000 Acc 250 Step/mm 74.2   reduction ratio   4:1
' Motor Z current 200 mA
' Microstep " BC"  8 Speed  3000 Acc 100 Step 400       leadscrew: 4mm for one turn

Load SCARA_Z_M1_M2.jpg
TTS SelectVoice "ENG M"
TTS SetVolume 100
TTS SetSpeed -1
s1 = TTSvoices

StartRobotOperations
Wait Seconds 0.5
Controls OpenTextBox
Option Speed 9
RestoreVars
DisableAllButtons


Button 1 Text Home
Button Home Text "Home"
Button Home Color SkyBlue

Button 2 Text HomeMZ
Button HomeMZ Text "Home MZ"
Button HomeMZ Color SkyBlue

Button 3 Text HomeM1
Button HomeM1 Text "Home M1"
Button HomeM1 Color SkyBlue

Button 4 Text HomeM2
Button HomeM2 Text "Home M2"
Button HomeM2 Color SkyBlue

'Button 5 Text Joy
'Button Joy Text "Joy"

Button 6 Text StartPump
Button StartPump Text "Start Pump"

Button 7 Text StopPump
Button StopPump Text "Stop Pump"

Button 8 Text EnableMotors
Button EnableMotors Text "Enable Motors"

Button 9 Text DisableMotors
Button DisableMotors Text "Disable Motors"

Button 10 Text EditSequence
Button EditSequence Text "Edit sequence"
Button EditSequence Color PaleGreen

Button 11 Text RunSequence
Button RunSequence Text "RUN SEQUENCE"
Button RunSequence Color Aqua

Button 12 Text SelectSequence
Button SelectSequence Text "Select Sequence"
Button SelectSequence Color PowderBlue

Button 15 Text CloseAll
Button CloseAll Text "CLOSE ALL"
Button CloseAll Color Red

Load Theremino_HAL\Theremino_HAL.exe
Load Theremino_HAL\theremino_SlotViewer.exe
'Load Theremino_HAL\theremino_Gamepad.exe

' ---------------------------------------- Software limits
M1max = 277
M1min =  86
M2max = 320
M2min =  38
MZmax = 159
MZmin =  61

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

ShowSequenceName
'DisableMotors
EnableAllButtons
StopPump
Button DisableMotors Disabled
Load Hide
Stop                                                                 '

' ╔════════════════════════════════════════════╗
' ║ INITIALIZATIONS                            ║
' ╚════════════════════════════════════════════╝
Variable Numeric Slot_MotorM1		=  1
Variable Numeric Slot_MotorM2		=  3
Variable Numeric Slot_MotorMZ		=  7
Variable Numeric Slot_Vacuum        =  5
Variable Numeric Slot_LedR			=  6
Variable Numeric Slot_LedG			=  9
Variable Numeric Slot_EnableMotors	= 10
Variable Numeric Slot_Pump       	= 11
Variable Numeric Slot_Limits        = 12
Variable Numeric Slot_SignalScope   = 13

Variable Numeric M1max
Variable Numeric M1min
Variable Numeric M2max
Variable Numeric M2min
Variable Numeric MZmax
Variable Numeric MZmin

' ╔════════════════════════════════════════════╗
' ║ CLOSE ALL                                  ║
' ╚════════════════════════════════════════════╝

Label CloseAll
	SaveVars
	Window Sizable
	Load CloseApps
	'DisableMotors
End                                                                   '

' ╔════════════════════════════════════════════╗
' ║ STOP EVENT (when pressing stop button)     ║
' ╚════════════════════════════════════════════╝
Label EventStop
	SayEndOfProgram
	SaveVars
	EnableAllButtons
	Window Sizable
	'DisableMotors
	Slot(Slot_SignalScope) = 0
End                                                                   '

' ╔════════════════════════════════════════════╗
' ║ SAVE LOAD and CLEAR VARS                   ║
' ╚════════════════════════════════════════════╝
Label SaveVars
	S1 = SequenceName
	Save Vars
Return

Label RestoreVars
	Load Vars
	SequenceName = S1
Return

' ╔════════════════════════════════════════════╗
' ║ ENABLE/DISABLE BUTTONS                     ║
' ╚════════════════════════════════════════════╝
Label EnableAllButtons
	For v1 = 1 To 32
		Button v1 Enabled
	Next
Return

Label DisableAllButtons
	For v2 = 1 To 32
		Button v2 Disabled
	Next
Return

' ╔════════════════════════════════════════════╗
' ║ LED COLORS                                 ║
' ╚════════════════════════════════════════════╝
Label RedOn
	TTS Speak "Status red."
	Slot Slot_LedR = 1000
	Slot Slot_LedG = 0
	Wait TTSready
Return

Label GreenOn
	TTS Speak "Status green."
	Slot Slot_LedR = 0
	Slot Slot_LedG = 1000
	Wait TTSready
Return

Label RgbOff
	Slot Slot_LedR = 0
	Slot Slot_LedG = 0
Return

Label RedBlink
	RedOn
	GreenOn
Return


' ╔════════════════════════════════════════════╗
' ║ HOME MOTORS                                ║
' ╚════════════════════════════════════════════╝
Label Home
	HomeMZ
	Slot Slot_MotorM2 = Slot(Slot_MotorM2) - 30
	HomeM1
	HomeM2
Return

' ╔════════════════════════════════════════════╗
' ║ HOME MOTOR -Z-  -M1-  -M2-                 ║
' ╚════════════════════════════════════════════╝
Label HomeMZ
	SayHomeProcedureIsStarted
	EnableMotors
	SlotMotor = Slot_MotorMZ
	SlotSensor = Slot_Limits
	SpeedSearch = +0.2
	SpeedReturn = -0.01
	DeclaredSwitchPos = 95
	InitialPosition = 94
	HomeMotor
	PrintValues
Return

' ╔════════════════════════════════════════════╗
' ║ HOME MOTOR -M1-                            ║
' ╚════════════════════════════════════════════╝
Label HomeM1
	EnableMotors
	SlotMotor = Slot_MotorM1
	SlotSensor = Slot_Limits
	SpeedSearch = +0.1
	SpeedReturn = -0.01
	DeclaredSwitchPos = 280
	InitialPosition = 180
	HomeMotor
	PrintValues
Return

' ╔════════════════════════════════════════════╗
' ║ HOME MOTOR -M2-                            ║
' ╚════════════════════════════════════════════╝
Label HomeM2
	EnableMotors
	SlotMotor = Slot_MotorM2
	SlotSensor = Slot_Limits
	SpeedSearch = +0.2
	SpeedReturn = -0.01
	DeclaredSwitchPos = 322
	InitialPosition = 180
	HomeMotor
	PrintValues
Return

' ╔════════════════════════════════════════════╗
' ║ HOME MOTOR                                 ║
' ╚════════════════════════════════════════════╝
Variable Numeric SlotMotor
Variable Numeric SlotSensor
Variable Numeric SpeedSearch
Variable Numeric SpeedReturn
Variable Numeric DeclaredSwitchPos
Variable Numeric InitialPosition

Label HomeMotor
	DisableAllButtons
	EnableMotors
	Button 15 Enabled
	' ------------------------- detach if sensor is active
	If Slot(SlotSensor) > 500 Or Key("CTRL")
		Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn
	EndIf
    ' ------------------------- search the sensor
Label SearchHome
	Slot(SlotMotor) = Slot(SlotMotor) + SpeedSearch
	Wait Seconds 0.001
	If Slot(SlotSensor) > 500 Or Key("CTRL")
		Slot(SlotMotor) = Reset
		Wait Seconds 0.1
		Slot(SlotMotor) = 0
		Wait Seconds 0.1
		Goto DetachSensor
	EndIf
Goto SearchHome
    ' ------------------------- detach from the sensor
Label DetachSensor
	Slot(SlotMotor) = Slot(SlotMotor) + SpeedReturn
	Wait Seconds 0.001
	If Slot(SlotSensor) < 500
		Slot(SlotMotor) = Reset
		Wait Seconds 0.1
		Slot(SlotMotor) = DeclaredSwitchPos
		Wait Seconds 0.1
		Goto SetFinalValues
	EndIf
Goto DetachSensor
    ' ------------------------- reset and move to InitialPos
Label SetFinalValues
	Slot(SlotMotor) = InitialPosition
	WaitAllMotors
	EnableAllButtons
Return

' ╔════════════════════════════════════════════╗
' ║ WAIT ALL MOTOR - Wait until motors stopped ║
' ╚════════════════════════════════════════════╝
Label WaitAllMotors
	Wait Seconds 0.1 ' <<< ensures that motors are really started
	Variable Numeric WAM1
	For WAM1 = 1 To Infinity
		If Abs(Slot(Slot_MotorM1 + 1)) < 0.01
			If Abs(Slot(Slot_MotorM2 + 1)) < 0.01
				If Abs(Slot(Slot_MotorMZ + 1)) < 0.01
					Exit
				EndIf
			EndIf
		EndIf
		Wait Seconds 0.01
	Next
Return

' ╔════════════════════════════════════════════╗
' ║  JOG with keyboard                         ║
' ╚════════════════════════════════════════════╝
Label ExecKeys
	Variable Numeric JogSpeed = 10
	'
	Select True
		Case Key("SHIFT")
			JogSpeed = JogSpeed * 0.1
		Case Key("CTRL")
			JogSpeed = JogSpeed * 0.01
		Case Key("ALT")
			JogSpeed = JogSpeed * 0.001
		CaseElse
			'
	EndSelect
	'
	If Key("Right")
		Slot(Slot_MotorM1) = Limit(Slot(Slot_MotorM1) - JogSpeed, M1min, M1max)
	EndIf
	If Key("Left")
		Slot(Slot_MotorM1) = Limit(Slot(Slot_MotorM1) + JogSpeed, M1min, M1max)
	EndIf
	'
	If Key("Up")
		Slot(Slot_MotorM2) = Limit(Slot(Slot_MotorM2) + JogSpeed, M2min, M2max)
	EndIf
	If Key("Down")
		Slot(Slot_MotorM2) = Limit(Slot(Slot_MotorM2) - JogSpeed, M2min, M2max)
	EndIf
	'
	If Key("PageUp")
		Slot(Slot_MotorMZ) = Limit(Slot(Slot_MotorMZ) + JogSpeed, MZmin, MZmax)
	EndIf
	If Key("PageDown")
		Slot(Slot_MotorMZ) = Limit(Slot(Slot_MotorMZ) - JogSpeed, MZmin, MZmax)
	EndIf
	PrintValues
	EnableMotors
	'YellowOn
Return

' ╔════════════════════════════════════════════╗
' ║ JOYSTICK MANAGEMENT                        ║
' ╚════════════════════════════════════════════╝
Label Joy
	EnableMotors
	v3 = Slot(13)
	If v3 > 550 								'move to Right M0
		Slot(1) = Slot(1) - (v3 - 550) * 0.01 	'incremental move
	EndIf
	If v3 < 450									'move to Left M0
		Slot(1) = Slot(1) + (450 - v3) * 0.01	'incremental move
	EndIf
	v3 = Slot(14)
	If v3 > 550 							    'move to left M1
		Slot(3) = Slot(3) - (v3 - 550) * 0.01 	'incremental move
	EndIf
	If v3 < 450 							    'move to right M1
		Slot(3) = Slot(3) + (450 - v3) * 0.01	'incremental move
	EndIf
	v3 = Slot(15)
	If v3 > 550 		   					    'move to up M2 (Z)
		Slot(5) = Slot(5) + (450 - v3) * 0.001	'incremental move
	EndIf	 					                'nota: joy Z verticale difettoso
	If v3 < 450 							    'move to down M2 (Z)
		Slot(5) = Slot(5) - (v3 - 550) * 0.001 	'incremental move
	EndIf
	If Slot(23) < 550
		Slot(12) = 0							'stop pump
	Else
		Slot(12) = 1000							'start pump
	EndIf
	If Slot(26) > 500 							'Button 4 to exit joy mode
		Return
	EndIf
Goto Joy
Return


' ╔═════════════════════════════════════════════════════╗
' ║  S U B R O U T I N E   A R E A                      ║
' ╚═════════════════════════════════════════════════════╝
' ╔════════════════════════════════════════════╗
' ║ ENABLE / DISABLE MOTORS                    ║
' ╚════════════════════════════════════════════╝
' ╔════════════════════════════════════════════╗
' ║ ENABLE / DISABLE PUMP                      ║
' ╚════════════════════════════════════════════╝
Label StartPump
	Slot(Slot_SignalScope) = 1000
	Wait Seconds 0.1
	Slot(Slot_Pump) = 1000
	Button StartPump Disabled
	Button StopPump Enabled
	Wait Seconds 0.8
	If Slot(Slot_Vacuum) > 55
'		Beep "500, 300, 0, 300"
'		SayVacuumProblem
'		RedOn
'		StopPump
'		Print "Vacuum Problem" + CRLF
'		Print "Execution stopped" + CRLF
'		RedBlink
'		End
	EndIf
Return

Label StopPump
	Slot(Slot_Pump) = 0
	Button StopPump Disabled
	Button StartPump Enabled
Return

Label EnableMotors
	Slot(Slot_EnableMotors) = 1000
	Button EnableMotors Disabled
	Button DisableMotors Enabled
	'Wait Seconds 0.1
Return

Label DisableMotors
	Slot(Slot_EnableMotors) = 0
	Wait Seconds 0.1
	Button DisableMotors Disabled
	Button EnableMotors Enabled
Return

Label SignalScope_ON
	Slot (Slot_SignalScope) = 1000
Return

Label SignalScope_OFF
	Slot (Slot_SignalScope) = 0
Return

' ╔════════════════════════════════════════════╗ █▀█
' ║ SEQUENCES                                  ║ █ █
' ╚════════════════════════════════════════════╝ █▄█
Label InitSequencePaths
	Variable String EditorFolder
	Variable String EditorApp
	Variable String SequencePathAndName
	Variable String SequenceName
	'
	EditorFolder = ".\Apps\Theremino_Editor\"
	'
	EditorApp = EditorFolder + "Theremino_Editor.exe"
	'
	SequencePathAndName = EditorFolder + "Sequences\" + SequenceName
Return

Label RunSequence
	SayStartCoinRoutine
	Controls ClearTextBox
	DisableAllButtons
	Button EditSequence Enabled
	Button CloseAll Enabled
	InitSequencePaths
	Button RunSequence Color Flashing8 Yellow Orange
	SequenceToExecute = SequencePathAndName
	SignalScope_ON
	Home
	Variable Numeric ExitFromSequenceLoop
	For v4 = 1 To 9e99
		ExecSequence
		If ExitFromSequenceLoop > 0
			ExitFromSequenceLoop = 0
			Exit
		EndIf
	Next
	Button RunSequence Color Aqua
	EnableAllButtons
Return

Label EditSequence
	InitSequencePaths
	If FileExists(SequencePathAndName)
		Load EditorApp + " " + SequencePathAndName
	EndIf
Return

Label SelectSequence
	InitSequencePaths
	s1 = SelectFile(EditorFolder + "Sequences\")
	If s1 <> ""
		SequenceName = s1
		ShowSequenceName
	EndIf
Return

Label ShowSequenceName
	Button SelectSequence Text "Sequence" + CRLF + SequenceName
Return

' ███████████████████████████████████████████████████████████████
' ██ SEQUENCE LOADING AND EXECUTION                            ██
' ███████████████████████████████████████████████████████████████
Variable String  SequenceToExecute
Variable String  Sequence
Variable String  SequenceCmd
Variable Numeric SequenceIndex
Variable Numeric SequenceLength
Variable Numeric N1

Label ExecSequence
	Load Sequence SequenceToExecute
	If Len(Sequence) = 0
		Controls OpenTextBox
		Print CRLF + " Sequence file not found: " + SequenceToExecute
		Beep
		Stop
	EndIf
	'
	Print CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute)
	Print " started at " + Format(Now, "HH:mm:ss") + CRLF + Chars("-", 65) + CRLF
	' ----------------------------------------------------------
	Variable Numeric ExecSequenceStartTime
	ExecSequenceStartTime = ElapsedTime
	' ----------------------------------------------------------
	SequenceLength = GetSeparatedStringCount(Sequence, CRLF)
	For SequenceIndex = 0 To SequenceLength - 1
		' ------------------------------------------------------
		SequenceCmd = GetSeparatedString(Sequence, SequenceIndex, CRLF)
		SequenceCmd = Replace(SequenceCmd, Chr(9), " ") 'TABS to SPACES
		' ------------------------------------------------------ Do not print lines containing ''
		If GetSeparatedStringCount(SequenceCmd, "''") < 2
			Print " Exec: " + SequenceCmd + CRLF
		EndIf
		' ------------------------------------------------------ Trim and remove comments
		SequenceCmd = Trim(RemoveComments(SequenceCmd))
		' ------------------------------------------------------
		If SequenceCmd <> ""
			Select GetSeparatedString(SequenceCmd, 0)
            	' ---------------------------------------------- End sequence
				Case "EndSeq"
					Exit
				' ---------------------------------------------- STOP
				Case "Stop"
					ExitFromSequenceLoop = 1
					Exit
		    	' ---------------------------------------------- ACTIONS
				Case "WaitAllMotors"
					WaitAllMotors
				'	---------------------------------------------- LED COLORS
				Case "RedOn"
					RedOn
				Case "GreenON"
					GreenOn
				Case "RGBOFF"
					RgbOff
				'' ---------------------------------------------- VACUUM PUMP
				Case "StartPump"
					StartPump
				Case "StopPump"
					StopPump
				' ---------------------------------------------- Enable/Disable motors
				Case "EnableMotors"
					EnableMotors
				Case "DisableMotors"
					DisableMotors
				' -------------------------------------------- Motor fixed angles
				Case "Home"
					Home
				Case "HomeMZ"
					HomeMZ
				Case "HomeM1"
					HomeM1
				Case "HomeM2"
					HomeM2
	            ' -------------------------------------------- With parameters
				Case "WriteSlot"
					N1 =  GetSeparatedString(SequenceCmd, 1)
					Slot(N1) = GetSeparatedString(SequenceCmd, 2)
				Case "ResetStepper"
					N1 =  GetSeparatedString(SequenceCmd, 1)
					Slot(N1) = Reset
					Wait Seconds 0.05
					Slot(N1) = GetSeparatedString(SequenceCmd, 2)
					Wait Seconds 0.05
					Slot(N1) = GetSeparatedString(SequenceCmd, 3)
				Case "Move_MZ"
					Slot(Slot_MotorMZ) = GetSeparatedString(SequenceCmd, 1)
					WaitAllMotors
				Case "Move_M1"
					Slot(Slot_MotorM1) = GetSeparatedString(SequenceCmd, 1)
					WaitAllMotors
				Case "Move_M2"
					Slot(Slot_MotorM2) = GetSeparatedString(SequenceCmd, 1)
					WaitAllMotors
				Case "MOVE_M1M2"
					Slot(Slot_MotorM1) = GetSeparatedString(SequenceCmd, 1)
					Slot(Slot_MotorM2) = GetSeparatedString(SequenceCmd, 2)
					WaitAllMotors
				Case "MOVE_M1M2MZ"
					Slot(Slot_MotorM1) = GetSeparatedString(SequenceCmd, 1)
					Slot(Slot_MotorM2) = GetSeparatedString(SequenceCmd, 2)
					'Wait Seconds 0.005
					Slot(Slot_MotorMZ) = GetSeparatedString(SequenceCmd, 3)
					WaitAllMotors
					
				Case "Pause"
					Wait Seconds GetSeparatedString(SequenceCmd, 1)
				CaseElse
					Controls OpenTextBox
					Print CRLF + " Unrecognized command: " + SequenceCmd + CRLF
					Beep
					Stop								'
			EndSelect
		EndIf
	Next
	Print Chars("-", 63) + CRLF + "Sequence " + GetFileNameWithoutPath(SequenceToExecute)
	Print " executed in " + Format(ElapsedTime - ExecSequenceStartTime, "0.00") + " sec" + CRLF
Return


' ====================================================================
'  PRINT COORDINATES
' ====================================================================
Label PrintValues
	s1 =       "MZ=" + Format(Slot(Slot_MotorMZ), "0.000")
	s1 = s1 + " M1=" + Format(Slot(Slot_MotorM1), "0.000")
	s1 = s1 + " M2=" + Format(Slot(Slot_MotorM2), "0.000")
	Print CRLF + s1
Return

' ╔════════════════════════════════════════════╗ █▀▀▀ █▀▀█ █▀▀█
' ║  SPOKEN MESSAGES                           ║ ▀▀▀█ █▀▀▀ █  █
' ╚════════════════════════════════════════════╝ ▄▄▄█ █    █▄▄█
Label SayPowerSwIsOn
	Select TTSlanguage
		Case "ENG"
			TTS Speak "Power switch is on?"
		Case "FRA"
			TTS Speak "L'interrupteur d'alimentation est allumé ?"
		Case "ITA"
			TTS Speak "Hai acceso l'alimentazione?"
		Case "ZHO"
			TTS Speak "电源开关是否打开？"
	EndSelect
	Wait TTSready
Return

Label StartRobotOperations
	Select TTSlanguage
		Case "ENG"
			TTS Speak "Start robot operations."
		Case "FRA"
			TTS Speak "Démarrez les opérations du robot."
		Case "ITA"
			TTS Speak "Avviata la disponibilta del robot."
		Case "ZHO"
			TTS Speak "启动机器人动作序列。"
	EndSelect
	'Wait TTSready
Return

Label SayStartBallRoutine
	Select TTSlanguage
		Case "ENG"
			TTS Speak "Start sequence of pick and place of ping pong ball."
		Case "FRA"
			TTS Speak "Commencez la séquence de sélection et de placement de la balle de ping-pong."
		Case "ITA"
			TTS Speak "Avvia la sequenza di prelievo e posizionamento della pallina da ping pong."
		Case "ZHO"
			TTS Speak "开始乒乓球的取放顺序。"
	EndSelect
	'Wait TTSready
Return

Label SayStartCoinRoutine
	Select TTSlanguage
		Case "ENG"
			TTS Speak "Coin sequence management has been launched."
		Case "FRA"
			TTS Speak "La gestion des séquences de pièces a commencé."
		Case "ITA"
			TTS Speak "Avviata la gestione della sequenza della moneta."
		Case "ZHO"
			TTS Speak "硬币顺序管理开始。"
	EndSelect
	'Wait TTSready
Return

Label SayHomeProcedureIsStarted
	Select TTSlanguage
		Case "ENG"
			TTS Speak "Home procedure is started."
		Case "FRA"
			TTS Speak "La procédure d'accueil est lancée."
		Case "ITA"
			TTS Speak "La procedura di azzeramento è iniziata."
		Case "ZHO"
			TTS Speak "家庭程序开始。"
	EndSelect
	'Wait TTSready
Return

Label SayVacuumProblem
	Select TTSlanguage
		Case "ENG"
			TTS Speak "Vacuum Problem."
		Case "FRA"
			TTS Speak "Problème de vide."
		Case "ITA"
			TTS Speak "Problema con la pompa del vuoto."
		Case "ZHO"
			TTS Speak "真空问题。"
	EndSelect
	'Wait TTSready
Return

Label SayEndOfProgram
	Select TTSlanguage
		Case "ENG"
			TTS Speak "The program is terminated."
		Case "FRA"
			TTS Speak "Le programme est terminé."
		Case "ITA"
			TTS Speak "Il programma è terminato."
		Case "ZHO"
			TTS Speak "程序终止。"
	EndSelect
	'Wait TTSready
Return

Label SayNowTheLanguageIsEnglish
	TTS Speak "Now the language is English."
	Wait TTSready
Return
Label SayNowTheLanguageIsItalian
	TTS Speak "Ora parla Italiano."
	Wait TTSready
Return
Label SayNowTheLanguageIsChinese
	TTS Speak "现在语言是中文"
	Wait TTSready
Return


'WATCH New watch
'WATCH Language
'EXEC ExitFromSequenceLoop = 1
