Skip to content

New Language Features

With 2014 Release 3, Xojo has some new language features: Auto, Global, Text and Using.

The new language features are available for all project types, not just iOS.

Auto

Auto is a new data type that can contain any other type. In this way it is similar to a Variant. But unlike a Variant, an Auto cannot automatically convert to different types. Because Variant attempts (sometimes unsuccessfully) to convert values to other types when used, you can often cause hard-to-find bugs in your code.

Using Auto is much safer because you can only assign a value in Auto to a variable of its original type.

Global

The Global prefix is used to refer to something in the global namespace that may otherwise be inaccessible because the local scope overrides the item in the global scope.

Text

Text is a new data type that is a modern replacement for the String data type. Text is intelligent about encodings and the actual textual data, making it much more reliable with all languages and providing better support for case sensitivity.

In addition, Text has a slicker set of methods and properties for accessing information, including: BeginsWith, EndsWith and a Character iterator.

You can automatically convert Text values back to a String, so you can use Text in desktop, web and console projects without difficulty.

And you can also convert String values to Text using the String.ToText method.

Using

The Using keyword is used with namespaces. A namespace is a module that contains other project items, such as classes. When you do this, you have to refer to the class by using the module prefix, for example: MyModule.MyClass.

If you need to refer to MyClass a lot, this can result in a lot of extra typing. Instead you can put a Using MyModule command in the method so that you can refer simply to MyClass in the method and the compiler will know you actually mean MyModule.MyClass.

This is helpful for your own namespaces, but also because the new Xojo framework is contained in namespaces. With iOS projects this does not matter much because the Shared Build Setting “Simple References” is ON so you never have to include the full namespace.

But with desktop, web and console projects you have access to the Xojo.Core namespace and may want to take advanage of Using to make it easier to use the new Dictionary or other classes that are available to you.