Rockwell Automation 1771-DB Basic Module User Manual - Series A User Manual

Page 119

Advertising
background image

Operating Functions

Chapter 5

5–82

5.10.3.4
String to Number Conversion – CALL 63

This routine converts the first decimal number found in the specified string
to a number on the argument stack. Valid numbers and associated
characters are: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, ., E, +, -. The comma (,) is not a
valid number character and terminates the conversion. Two bytes are
POPed after the CALL:

validity of the value

actual value

If the string does not contain a legal value a 0 (zero) is returned. A valid
value is between 1 and 255. PUSH the number of the string to convert.
Two POPs are required. First POP the validity value, then POP the value.
If a string contains a number followed by an E followed by a letter or
non-numeric character, it is assumed that no number was found since the
letter is not a valid exponent (UAB701EA returns a zero in the first
argument popped indicating that no valid number was in the string).

Example:

u10 STRING 100,14

u20 INPUT “ENTER A STRING TO CONVERT”,$(1)

u30 PUSH 1: REM CONVERT STRING 1

u40 CALL 63: REM DO THE CONVERSION

u50 POP V,N

u60 IF V tu 0 THEN PRINT $(1),“ ”,N: GO TO 80

u70 PRINT “INVALID OR NO VALUE FOUND” 80 END

5.10.3
String Support Calls
(continued)

Advertising