Is it built in or …

Xojo has a pretty handy language feature called “extension methods”

They can be used by anyone to add functionality to any existing class. And they cane/have been used by Xojo to do exactly this.

For instance, the currency class has no built in functions to convert itself to a string, from a string, etc. Yet when you enter code like

Dim c As Currency

s = Currency.

and press tab you will see various methods presented.

You can see some of this when you select one option and then view the hint at the bottom of the editor

Normally it doesnt matter that a function is or isnt done this way.

Unless you expect things in XojoScript to also have these functions. They wont exist because the module(s) that provide all these handy functions are not part of the framework available to XojoScript.

And so code that would work in Xojo may not work in XojoScript.

3 Replies to “Is it built in or …”

  1. As far as I see there is a module named “Currency” in the framework (not in XojoScript), with a function with this declaration:

    Function ToString(Extends value As Currency, optional locale As Locale) as string

    And if you use ToString, you call that.

    You can’t yourself create a module named Currency. But if you do it, e.g. with renaming one in Arbed, you get an error telling you that the re is already a module named Currency!

    1. Yeah there are a bunch of things that aren not available in XojoScript that are in Xojo
      This is but one more

      Even calling Str and passing a string gives you an error in XojoScript
      ie/
      dim s as string
      s = str( "123" )

      I’ve filed a number of bug reports about some of the differences I’ve run into

Comments are closed.