bbb Home
Variables Contents        

VARIABLES

VARIABLE TYPES

TYPE DESCRIPTION EXAMPLES
Integer Holds whole numbers

iCount = 23

iTemp = -11

Float Holds real numbers

fTemp = 98.6

fAvogadro = 6.02E23

String Holds characters

sName= "Me"

sAddress = "100 Kenwood"

Boolean Only true or false. Can use 0 to represent false and 1 to represent true.

bFlag = true

isNumber = false

SCOPE - Global vs. Local


EXAMPLE

Font: 8pt   12pt   20pt   24pt   Width: Min. 50%   75%   100%   

PRACTICE

  1. Which of the following variable names are not legal? num, num1, 1num, _num, &num, n&um, num 1
  2. Create a page to show how global variables can be accessed from all functions. Make sure the page meets the following requirements:
    1. It has a textbox, a button labelled "assign" and a button labelled "display".
    2. It has a variable declared globally.
    3. It has a function called "assign()" that assigns the value from the textbox to the global variable.
    4. It has a function called "display()" that displays the global variable in an alert.
    5. When the assign button is clicked, the function assign() is called.
    6. When the display button is clicked, the function display() is called.
  3. Modify #2 to demonstrate how local variables can not be accessed from other functions.

SELF-QUIZ