Difference between revisions of "Command:DeclareVariable"

From Lavish Software Wiki
Jump to navigation Jump to search
Line 40: Line 40:
 
*[[LavishScript:Commands|Commands]]
 
*[[LavishScript:Commands|Commands]]
 
{{Command-Stub}}
 
{{Command-Stub}}
 +
[[Category:LavishScript]]
 +
[[Category:LavishScript Commands]]

Revision as of 22:30, 25 May 2005

Syntax

Command Difficulty Rating
DeclareVariable
Usage Intermediate
Level of Understanding Intermediate
Computer Savvy Beginner
Logic Intermediate

DeclareVariable <varname|varname[array extents]> [type] [global|script|local] [default value]

Description

Name

The name must consist of alphanumeric characters and underscores, and may not start with a number. Variable names must be unique in all accessible scopes (see below).

Type

The type is any currently available Data Type. These may be built into LavishScript, an application such as Inner Space or Fury, or an extension such as ISXGenHack. If the type is not given when creating the variable, the variable will default to the string type.

Scope

There are three possible scopes for variables -- global, script, and local. The global scope is accessible anywhere in LavishScript -- other scripts, from console commands, etc. The script scope is accessible only within the current script. The local scope is accessible only within the current function. If the scope is not given when creating the variable, the variable will default to global if not created within a script, or local if it is created within a script.

Default Value

Valid variable values are dependent on the data type. For example, strings contain any text, and ints contain any whole numbers. If the value is not given when creating the variable, the variable will default to whatever the data type says is default -- generally what would be considered empty or equal to zero.


Examples

declarevariable astring string global Something

allocates a globally-accessible variable named astring that is type 'string' with a value of "Something"


declarevariable anarray[5] int script


declarevariable avar bool local false



See Also