Hardware manual

Impact Reference Guide Basic Program Examples
5-31 Datalogic Automation Inc.
’ example (65). It assigns the string value "A" to the variable
’ char_string.
char_string = chr(asc_value)
Example 4
’ This example uses the HEX function to find the hex value of
’ the number assigned to the variable asc_value in the
’ previous examples (65). It assigns the string value
’ "41" to the variable hex_string.
hex_string = hex(asc_value)
Example 5
’ This example demonstrates the string concantenation
’ function (&). First, it assigns the integer value 5 to the
’ string variable blobs_int. It then joins two string constants
’ with the integer value inserted between them, and assigns
’ that string to the string variable resulting_string.
blobs_int = 5
resulting_string = "Found a total of " & blobs_int & " blobs"
Example 6
’ This example uses the function MID to extract a string from
’ the middle of the string variable resulting_string (which
’ was created in the previous example). It starts extracting at
’ character 7, and continues for 7 characters. It
’ assigns the extracted string ("a total") to the string
’ variable mid_string.
mid_string = mid(resulting_string,7,7)
Example 7
’ This example uses the function LEN to return the length
’ of the variable resulting_string (which was used in the
’ previous example). The returned integer (24) is assigned to
’ the integer variable length_int.
length_int = len(resulting_string)
Example 8
’ This example uses the function INSTR to find the beginning
’ position of the string constant "a tot" inside the string
’ resulting_string (which was used in the previous example).
’ The result is the integer 7 (the string starts at character
’ position 7). It is assigned to the integer variable num_int.
num_int = instr(resulting_string,"a tot")
Example 9
’ This example uses the function UCASE to convert the
’ string variable resulting_string (which was used in the
’ previous example) to all upper case, then assign it to the
’ string variable upper_string.
upper_string = ucase(resulting_string)
Example10
’ This example uses the function LCASE to convert the
’ string variable resulting_string (which was used in the
’ previous example) to all lower case, then assign it to the
’ string variable lower_string.
lower_string = lcase(resulting_string)
Example11
’ This example uses the function STRREVERSE to reverse
’ the string variable resulting_string (which was used in the
’ previous example) and assign the result to the string