Premise global variables and go to statement in premise?

Motorola Premise

etc6849

Senior Member
Q1: Since Premise is based on VBScript, I am thinking it does not support a go to statement for programming flow. Is this true? It seems you can do stop statements though.

Q2: Are global variables a good idea? Is it better to create a new property in an object and store to it's value?

Q3: Not really a question, but a statement. The extension relationship is really useful instead of global variables.
The situation for I ran into is I have a keypad and I want to store the name of the last button that was pressed. To do this initially, I just made a hidden button and write the name to the description of that hidden button.

However, from a recent post 123 has made, I reworked this method to extend a string property on the keypad class by creating a new class naming the text property "LastButtonPressed." This adds a text property to the keypad under home that I can easily access through code. Neat!
 
Q1: Since Premise is based on VBScript, I am thinking it does not support a go to statement for programming flow. Is this true? It seems you can do stop statements though.
It is important to understand that Premise's underlying engine is called SYS and it is not "based on VBScript". SYS is written in C++ and is combination of an object-based data-store, a library of core classes, and several functional services (scheduling, communications, web server, etc). VBScript was chosen as the scripting language for the purpose of creating programming logic.

Premise both extends and constrains VBScript. For example, it adds the concept of "this" (self-referential object) and eliminates some VBscript features like "sleep". "this" is an important concept for object-oriented programming. "sleep" suspends execution for a defined time period and is not permitted in Premise because all Modules execute in a single thread; you cannot have a statement halt the execution of all Modules. Timers are used in the place of "sleep". Premise is heavily object-oriented and event-driven; "goto" is incompatible with Premise's programming model.

Q2: Are global variables a good idea? Is it better to create a new property in an object and store to it's value?
It is important to understand the difference between a class and an object. A class represents the instructions for creating something. An object is the result of following the class's instructions. A class is the recipe for cake. An object is the cake.

You create properties and methods in a class and then you instantiate it as an object. Modules let you define new classes or extend existing ones. Objects are created in Home based on the classes you define in Modules.

It is preferable to create proper classes that have all properties necessary to handle the problem at hand. Global variables can be used for communicating information between Modules.

Q3: ...The extension relationship is really useful instead of global variables ... extend a string property on the keypad class by creating a new class naming the text property "LastButtonPressed." This adds a text property to the keypad under home ..
You've experienced the power of object-oriented design. If an existing class lacks properties you require, you can extend it without actually modifying its original definition! The technique is to create a new class, with an extension relationship with the old class, to append new capabilities. There's a beautiful example of this concept in the old Support forum (can't find it at the moment) where the Button class is extended so that it keeps count of how many times a Button is pressed.
 
Back
Top