Overloading the handler with a local variable

I try to create a object of my SUT to work with the different systems.
The current implementation will create an recursive call.
How can I tell the function connect to call the system connect function and stop itself afterwards?

File device.script:
Properties
	Name:"",	
	OS:"",
	Type:"",
	HostName:"",
End properties
To connect
	put my HostName into host
	Connect host
End connect

File main.script:
put new "device" with {
	Name:"Sys012",	
	OS:"Linux",
	Type:"Hardware",
	HostName:"system.user.com",
} into device01

run device01.connect

I added “helped by device” for new device01 object. I also had to rename the handler to not collide with the system command.

device.script:

Properties
    Name:"",
    OS:"",
    Type:"",
    HostName:"",
End properties

To connectDevice
    put my HostName into host
    Connect host
End connectDevice

master.script:

put new "device" with {
    Name:"Sys012",
    OS:"Linux",
    Type:"Hardware",
    HostName:"WebSUT",
} helped by device into device01

run device01.connectDevice
1 Like

Yes, renaming the connect handler is the simplest way to avoid having the handler call itself with infinite recursion.

If it’s really important to you to use connect as the name, you can do it like this:

To connect
    put my HostName into host
    tell SenseTalk to Connect host
End connect

Using tell SenseTalk sends the “connect” message directly to the back-end so you can avoid the recursion.

1 Like

Thank you both, now it works.