Using Variables
Username:  
Password:
  > Home
v User Guide
    > Introduction
    v Hello World
       o Authoring program set up
       o Your first BEE Web Page
       o Your first BEE Section
       o Using Variables
       o What is the time now
       o More on conversions
    > Flow Control
    > Function Calls
    > Authentication
    > Database access
    > Content Management
    > Remote Calling
    > Object-Oriented
    > Other Features
> Reference
> Portal Object
> Development Guide


Shortcuts
sys Class
debug Class
Intrinsic Conversions
>> User Guide >> Hello World >> Using Variables <=  =>      <  1  >  
Using Variables

There is only one type of intrinsic data structure in BEE: array of strings.  Simple variables are in fact single element array.  In that case, the element index to the array is omitted and assumed to be blank ("").  We call this the default element.

var a = "x";

display "{a}<br> ";  // Output: x

display "{a|list}<br> ";  // Output: =>x

 

(The "|list" part specifies a Conversion that converts an array to a presentable string.  Conversion is discussed in the next section.)

Now let's illustrate the idea by storing the string "Hello World" into a variable and having the script display the variable instead:

<script language="bee">
var hw = "Hello World";

display "<h1>{hw} </h1> ";

</script>

 

The same can be done using BEE Tag, without the BEE section definition (<script ...> and </script>):

<bee var="hw" value="Hello World">

<bee value="<h1>{hw} </h1> ">

 

Please note that each BEE tag (<bee ...>) is a BEE Section itself and is therefore replaced by its output before the web page is sent to the client browser.  However, white spaces between BEE Tags are not part of the BEE Section and therefore are sent to the client browser untouched.  The above example can be written as:

<bee var="hw" value="Hello World">

<h1><bee value="{hw}">

</h1>

 

BEE makes it easy to display variable, even "naked".  Look at this:

<bee var="hw" value="Hello World">

<h1>${hw}

</h1>

 

Here ${hw} is translated to <bee value="{hw}">.  BEE Values in the form of {var} is interpreted as such only within BEE Section.  When it is not in a BEE Section (naked), a dollar sign must be put in front of a BEE Value to allow the parser to pick it up (i.e. dressing up the "naked" BEE Value.)

As a side-topic, you can count the number of elements in an array or the number of characters in an element string using the "sizeof" operator ({#...}).  However, please be careful when using "sizeof".  It counts the number of elements in an array unless the element is explicitly specified, even if it is the default element.

var arr = "(array)one,two,three,four";

 

// Number of elements in array arr

display "{#arr} ";  // Output: 4

 

// Number of characters in the second element of arr (first is 0)

display "{#arr:#1} "; // Output: 3

 

var v = "hello";

 

// Number of elements in array v

display "{#v} ";  // Output: 1

 

// Number of characters in the default element of v

display "{#v:} "; // Output: 5

 

 

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