Description: |
| | Assigns the value of an expression to the a property of an Object. In Basic syntax, the optional keyword Let can precedes the Assignment Statement. |
Syntax: |
| | The following shows the format of the Assignment Statement syntax.
| Visual Basic & BASIC | C & Java |
| [Let] <id> = <expression> | <id> = <expression>; |
The following table lists the elements of the Assignment Statement syntax.
| Element | Description |
| <id> | An Identifier that specifies which Variable or Object and property to be assigned a value. |
| <expression> | Value assigned to the Variable or Object's property specified in <id> |
|
Operation: |
| | When an Assignment Statement is encountered during the program's execution, the value of the Object Property specified by the <id> element is assigned the value specified by the <expression> elements. With some objects, such as serial ports or LCD Displays, it is useful to assign multiple values at once as a string of characters. This can be done by assigning a string value. I.E. A.Vstring = "Hello World". When an Assignment Statement like this is encountered during the program's execution, the value of the Object Property specified by the <id> element is assigned the values of each character in the string sequentially. See Chapter 13 of the Programmers guide for more detail. Note: Assigning an expression of one numeric data type to a variable of a different numeric data type coerces the value of the expression into the data type of the resulting variable. I.E. If a Byte value of 3 was assigned to a Bit variable, the resulting Bit variable value would be 1 because it only has 1-bit to store its value in. |
Remarks: |
| | In the Basic syntax, the optional Let keyword is most often omitted. The value specified by the <expression> element can be assigned to the Object's property specified by <id> only if they are of the same type. |
Example: |
| | The following example shows an Assignment Statement that sets the value of A to 5. In the Basic syntax, the Let keyword is optional and both examples function identically.
| Visual Basic & BASIC | C & Java |
A = 5 | A = 5; |
Let A = 5 |
The following example shows an Assignment Statement that sets the value of A to the ASCII value of "T", then sets the value of A to the ASCII value of "e", then sets the value of A to the ASCII value of "s", then sets the value of A to the ASCII value of "t".
| Visual Basic & BASIC | C & Java |
A = "Test" | A = "Test"; |
|
Related Items:
|
| | Using Strings. (Chapter 13 of the Programmers guide.) |
Version History and Bug List: |
| | Firmware Ver A1: Introduced. Bugs: No known bugs. |