Variable Naming Convention
Moderator: Martin
Variable Naming Convention
It would be most helpful if you include the rules for naming variables.
-
- Posts: 27
- Joined: 01 Dec 2012 08:13
Re: Variable Naming Convention
From the documentation you can use almost any word as a variable. The only exceptions to that are the keywords that are listed in the documentation and the variable names already associated with the various components. Also, remember that variables that begin with global_ are global in scope so all flows can see them and the survive application/device restarts.
Re: Variable Naming Convention
The documentation does not include any rules that are typically specified within the naming convention. Such as:
Allowable characters?
Disallowed characters?
Whether lower case is differentiated from upper case?
Must first character be a letter?
Maximum length?
Allowable characters?
Disallowed characters?
Whether lower case is differentiated from upper case?
Must first character be a letter?
Maximum length?
Re: Variable Naming Convention
The naming follows the same rules used by java. The language is case sensitive. A variable name must start with a letter, a currency symbol (such as "$") or a connecting punctuation character (such as "_") but no digit. The rest of the variable name can also contain digits.
I generally use US-ASCII lowercase letters and underscore characters for the variables supplied to flows (for example dock_state, battery_percentage etc.).
The length of a variable name is not artificially limited.
I will update the documentation accordingly.
For historical reasons, almost all valid strings can be used as a variable name using the functions getValue and setValue, but I discourage the use of this feature.
I generally use US-ASCII lowercase letters and underscore characters for the variables supplied to flows (for example dock_state, battery_percentage etc.).
The length of a variable name is not artificially limited.
I will update the documentation accordingly.
For historical reasons, almost all valid strings can be used as a variable name using the functions getValue and setValue, but I discourage the use of this feature.
Re: Variable Naming Convention
I am still a very new user, But this is what i use. Do you have any background in programming. I have named my variable such as thisVyza wrote:Naming variables.
D.GetWifiState (where D is fake Device class just for funn, and GetWifiStatus is like a method implemented. This helps me remember and reuse the variables)
global_D.RingerState
SMS triggers like D.SetWifiOff would trigger a flow called "D.SetWifi" and upon getting sms keyword "D.SetWifi" and execute on or off depending upon what follows.