Download smartBASIC Core Functionality

Transcript
smart BASIC Core Functionality
User
We Manual
will now print each varaible on screen
0
0
0
0
0
0
0
0
0
0
Variable Scope
The scope of a variable defines where it can be used within an application.

Local Variable – The most restricted scope. These are used within functions or subroutines
and are only valid within the function or subroutine. They are declared within the function
or subroutine.

Global Variable – Any variables not declared in the body of a subroutine or a function and
are valid from the place they are declared within an application. Global Variables remain
in scope at the end of an application, which allows the user or host processor to
interrogate and modify them using the ? and = commands respectively.
As soon as a new application is run, they are discarded.
Note:
If a local variable has the same name as a global variable, then within a function or a
subroutine, that global variable cannot be accessed.
Variable Class
smart BASIC supports two generic classes of variables:

Simple – Numeric variables. There is currently one type: INTEGER.
Simple variables are scalar and can be used within arithmetic expressions as described
later.

Complex – Non-numeric variables. There is currently only one type: STRING.
STRING is an object of concatenated byte characters of any length up to a maximum of
65280 bytes but for platforms with limited memory, it is further limited and that value can be
obtained by submitting the AT I 1004 command when in Interactive mode and using the
SYSINFO(1004) function from within an application.
For example, in the BL600 module, the limit is 512 bytes since it is always the largest data
length for any attribute.
Complex variables can be used in expressions which are dedicated for that type of
variable. In the current implementation of smart BASIC, the only general purpose operator
that can be used with strings is the '+' operator which is used to concatenate strings.
//Example :: DimEx2.sb (See in Firmware Zip file)
DIM i$ as STRING
DIM a$ as STRING
a$ = "Laird"
i$ = a$ + "Rocks!"
//Here we are concatenating the two strings
print i$
Expected Output:
LairdRocks!
Embedded Wireless Solutions Support Center:
http://ews-support.lairdtech.com
www.lairdtech.com/bluetooth
53
Laird Technologies
Americas: +1-800-492-2320
Europe: +44-1628-858-940
Hong Kong: +852-2268-6567 x026