XojoScript and TCPSocket

I’m trying to test using XojoScript on a project I’m working on. This project will talk to various devices via SSH, TelNet and TCPSockets.

I’ve created a new class “ScriptEngine” that the superclass is “XojoScript”.
On the “ScriptEngine” class, I’ve added a property of “oTCPSocket1” of type “TCPSocket” with the scope of “Public”

Here’s some boiled down code:

DIM oScriptEngine AS NEW ScriptEngine oScriptEngine.oTCPSocket1 = NEW TCPSocket oScriptEngine.Source = "oTCPSocket1.Address = ""cully.biz""" self.Context = self DIM sScriptResult AS String = oScriptEngine.Evaluate()

I’m getting the following error: “Undefined identifier” when referencing the oTCPSocket1 object.

Is XojoScript not able to interrogate properties and classes other than strings, integers, and doubles?

You can’t use framework classes, like TCPSocket, in XojoScript

Thanks Norman. I was afraid of that.

Your Context can use objects and have object properties, but your script cannot access them. You have to define interface methods that cause the context to manipulate those objects. Your interface methods can only pass and return scalar values, but can maintain the state of the objects in the background.

Hi Tim,

Can you provide an example ?

I think I’ve got this figured out.

From my example above, if I added a method called “ScriptEngine.TCPOperation( sAddress AS String, nPort AS Integer)”
and then called that method from within the script …

oScriptEngine.Source = "TCPOperation("wikipedia.org", 80)

Within the TCPOperation method, I can use the full power of the Xojo language to do whatever I like. If I returned a value to the script, it would need to be of type String, Integer, Double, Boolean or another type that XojoScript supports.

Hope this helps. Thanks to all that chimed in.

[quote=129859:@Kevin Cully]I think I’ve got this figured out.
[/quote]

I was precisely looking into the Context property of the XojoScript as a way of interfacing with TCPSocket. Since TCPSocket communicates through strings, it looks feasible.

You seem to have used the same approach :slight_smile:

[quote=129859:@Kevin Cully]I think I’ve got this figured out.

From my example above, if I added a method called “ScriptEngine.TCPOperation( sAddress AS String, nPort AS Integer)”
and then called that method from within the script …

oScriptEngine.Source = "TCPOperation("wikipedia.org", 80)

Within the TCPOperation method, I can use the full power of the Xojo language to do whatever I like. If I returned a value to the script, it would need to be of type String, Integer, Double, Boolean or another type that XojoScript supports.

Hope this helps. Thanks to all that chimed in.[/quote]

Yes