LavishScript:Variables

From Lavish Software Wiki
Revision as of 07:34, 28 March 2005 by Lax (talk | contribs)
Jump to navigation Jump to search

Introduction

Variables are Top-Level Objects that can be created at any time.

Properties

Variables have a few different properties, each of which are initially set upon creation. The Value may be changed later.

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.

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.

Creation

Variables are created exclusively through the DeclareVariable command.

Usage

Reading

Variables are used exactly like Top-Level Objects, though they cannot be accessed from outside their scope. For example, a variable called "MyVariable" is used as ${MyVariable} -- just as a Top-Level Object called "Return" is used as ${Return}. As the name implies, these are objects, and all objects have members. In turn, each object member is another object. So this of course is perfectly valid: ${Return.Left[12].Right[3]} -- Return is a string, string.Left[#] gives a string, and string.Right[#] also gives a string. See Syntax for detailed information.

Writing

Variable values are changed through the VarSet, VarCalc and VarData commands. Each have specific uses.

Examples

See Also