LavishScript:Variables

From Lavish Software Wiki
Jump to navigation Jump to search

Introduction

Variables are 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 that supports variables. 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 five possible scopes for variables -- global, script, local, object, and globalkeep. 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. The object scope declares a variable to be only usable within the object that declares it. The globalkeep scope is the same as the 'global' scope except that it will not be deleted when the script ends. 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 can be created dynamically through the DeclareVariable command, or as part of script structure through the variable keyword.

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 type-specific "Set" methods

Examples

See Also