Appendix A 485
Additional Lab Exercises
Using Strings and Globals
Key Points
n String Objects and Functions:
StrTrim(str) first strips off any
spaces or tabs from the front and back of the name.
StrPosChar(str1,
" ")
yields the index of the space character between the firstname
and
lastname. StrLen(str), of course, gives the length of the string.
All of these were performed using the string objects, but they could also
be done using string functions within a
Formula object.
n Formula Object:
StrFromThru(A,B+1,C-1) takes the string from
input
A, adds 1 to the index of the space from input B, and subtracts 1
from the string length at input
C. (Recall that all indexing is zero-based.)
n Set Variable: Notice how easily you can set a global variable called
lastname, which can then be referenced in any expression field, such as
the
Formula object in this example.
n Optimizing: The three formulas could be combined into one formula. It
is recommended to leave
strTrim() on its own since its output is used
multiple times, but the others could be combined into one to optimize
speed. (This could reduce readability, however.)