var
Username:  
Password:
  > Home
> User Guide
v Reference
    > Introduction
    > CROFT
    > BEE Variables
    > BEE Syntax
    v BEE Commands
       v Variable Operations
          o var
          o link
          o clear
          o group
       > Conditional
       > Loop
       > Module Calling
       > Remote Calling
       > Authentication
       > Data Access
       > Socket
       > Special Functions
    > Database Operation
    > Content Management
    > Objects and Classes
    > Interface with others
    o Glossary
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> Reference >> BEE Commands >> Variable Operations >> var <=  =>      <  1  >  
var – assign a value to a variable, create an object, or display a value

The "var" command is the mother of all BEE Commands.  It has some variance in syntax to performance different operations.  The reason that these operations are not separated into different commands is that it reads more naturally to have an equal sign in it.  It would be easier to learn as variance of one "assignment" command instead of many others with different parameters one needs to remember.

To ease the burden of the documentation of the "mother", we have the "link" command separated into a different section following this one.

Variable Mode:

BEE Script:   [var] var [=[!] value] [conv=convSpec];

 

BEE Tag:     <bee[var] var=var [value=value] [conv=convSpec]>

 

Constructor Mode:

BEE Script:   [var] var[%] = new constructor [name=value ...];

 

BEE Tag:     <bee[var] var=var%function:new value=constructor>
<beevar%new [name=value ...];

 

Display Mode:

BEE Script:   display value [conv=convSpec];

 

BEE Tag:   <bee[var] value=value [conv=convSpec]>

 

 

Syntax Notes:

The command name "var" can be omitted in both BEE Script and BEE Tag syntax.  This is because "var" is the centre piece of the BEE Tag repertoire, and has been made the default tag.

Variable Mode

In the Variable Mode, the command accepts a value and assigns it to the BEE Variable.  The operation is "silent" (no display).  If the "= value" part is omitted, the variable will still be accessed, but there will be no effect nor any display.  One exception though of the "value-less var" operation is scheme file loading.  e.g. var scheme%myschmfile&;.  In this case, the command name "var" cannot be omitted.  (Otherwise, it will be taken as a function call syntax-wise.)  For details, please see "scheme" under the "Variable Name" section.)

Constructor Mode

Constructor Mode is for creating an object (or class).  The constructor is the name of the function that defines the characteristics of the object and is generally taken as the object name.  The name=value pairs are the parameters for the constructor.  For details, please see "Objectes and Classes".

In BEE Tag, there is no one single command to create an object.  It is done by assigning the "new" function of the object by the constructor name, then call the function with var%new followed by the constructor's parameters.

Display Mode

The Display Mode is characterised by the omission of the variable name.  In fact, the "display" in BEE Script syntax is not a BEE Command.  It is only an alias (shorthand writings) for the "var" command without the variable name var.  That is why there is no "display" BEE Tag.  The omission of var from the "var" BEE Tag indicates a display operation.

 

Parameters

var is the variable name.  Please see the "Variable Name" section.

value is the value in the form of "(type)string".  The value type is one of the followings: "literal" (or "lit", the default), "expression" (or "expr"), "var", "database" (or "db"), and "array".  The whole value (type and string) is evaluated for BEE Variables before being used for assignment (Variable Mode) or display (Display Mode).  For details of variable evaluation, please see the "Variable Value" section.

Type

String

literal
lit
(default)

A string to be literally assigned or displayed.  It is the default type, and therefore the type specification (literal or lit) is usually omitted.

expression
expr

An expression to be arithmetically evaluated before being assigned or displayed.

database
db

A database result name (see "database" tag).  The database record of the current position will be retrieved and the fields assigned to the BEE Variable as individual elements.  The position will move forward to the next database record after the retrieval.  ("database" type is for assignment only.  Display Mode will display nothing, but the position in the record set will still move forward.)

var

A variable name.  The "var" type is different from the "literal" type.  While "literal" is always a string, "var" can be a string or an array (if there is no element part in the variable name.)  This is useful in array assignment or for BEE Conversions (conv=...) that require array input.

array

A comma separated list with each item being in the form of either "[string]" or "[key]=>[string]".

In the Variable Mode, the resulting array will be assigned to the BEE Variable.  (If the variable to be assigned to has an element part, the element part will be ignored.)

In Display Mode, it will display nothing unless the array is converted into a string through a BEE Conversion (conv=...).

Example:

"Dog, Cat, Guinea Pig" would produce an array of three values: "Dog", "Cat" and "Guinea Pig".

"John=>Dog, Mary=>Cat, Sam=>Guinea Pig" would produce the same array with their owner's name as keys (the element indexes).

In the array value (the "[string]" part), leading and trailing spaces will be trimmed off unless quoted with single quotation mark.  Comma inside an item can be escaped with a backslash to avoid being taken as a separator.

Please note that there are different forms to represent a variable in the "value" parameter.  There is one simple rule: {...} always evaluate to a string.

(var)class%name      The array in variable class%name, whether it contains single or multiple elements.

(var)class%name:elemet      The string in the variable element class%name:elemet.

(var)class%name:      The default element of the class%name array.  (The trailing ':' is compulsory to distinguish it from the array form.)

{class%name}      Same as (var)class%name:, NOT (var)class%name

{class%name:elemet}      Same as (var)class%name:elemet.

{class%name:}      Same as (var)class%name: (but the trailing ':' is optional, and usually omitted.)

(If the "class%" part is "value%", it can be omitted.)

Notes:

If you do not want BEE to evaluate the value for BEE Variables, you can precede the parameter name "value" with an exclamation mark ('!') (as mentioned in "General Syntax").  However, for BEE Script form, there is no parameter name.  In that case, you can add the '!' after the equal sign but leaving at least one white space before the value.

Examples:

var var1 = "abc";
var var2 =! "{var1}";   // var2 will get "{var1}" literally, not "abc".

                  // "{var1}" will be evaluated with "var2" later.

var var1 = "def";

display "{var2}";       // will display {var2} at the time

// i.e. display "def", not "abc";

 

// Beware of the syntax

var a = ! "xyz";   // Good

var a =! "xyz";   // Good

var a=! "xyz"; // Good

var a=!"xyz";  // Bad! Taken as: var a = "!xyz";

 

 

conv is the BEE Conversion, which is a function applied after the value has been evaluated for BEE Variables but before it is assigned or displayed.  For details, please see the "BEE Conversion" section.

name is not really a fixed parameter.  The name name can be anything (except for the parameter names above) and can be more than one.  They are used to pass parameters to the remote function (as indicated by the Attribute Name-Value Pairs in the syntax description).  If a value is preceded by an "@" sign, the rest of the content indicates a JavaScript expression (instead of a BEE expression.)

 

Previous Page       Next Page

Accsoft Computer Technology Pty Ltd     ABN: 98 065 617 549
PO Box 892, Epping NSW 1710         Level 1, Epping Office Park, 242 Beecroft Rd, Epping NSW 2121, Australia
Tel: Sydney - (02)98691668     National - 1300-881668         Fax: (02)98691866
© Copyright 2003 Accsoft Computer Technology Pty Ltd