XojoScript Difference between Desktop and Web


I have a Textfield, a Button and a XojoScript Object.

If I use this code (in the Buttons pressed event) on Web, it runs fine.

XojoScript1.Context = TextField1
XojoScript1.Source = "text = text + ""abc"""
If XojoScript1.Precompile(XojoScript.OptimizationLevels.None) Then
End If

If I do the same on Desktop it fails. Is this another Feature or an Bug?


It would be helpful to know how it fails

CompilerError raises with “NamespaceAsValue”

Personally, I would use a custom class as the context rather than giving the script full access to the TextField instance. The custom class can have a method that adds the text to the TextField. You would setup the custom class with the TextField as a property before running the script. This way the custom class can manipulate the TextField.

“Text” is tricky. It’s a data type (from API 1.5, now deprecated) and a property name.

In the case of Web projects, the Text property is actually a computed property because it has to trigger an event to send updated info to the browser, so really it’s a pair of methods.

It sounds like the XojoScript compiler is having trouble with it as a simple property.

But I agree with @Brandon_Warlick, make a custom class as your context and have that do the actual work. You’ll probably have better luck that way.

So there should be a reserverd Object like Super or Self, to get these properties.