Call 63: string to number conversion – Rockwell Automation 1771-DB BASIC MODULE User Manual

Page 252

Advertising
background image

Chapter
Call Routines 0–68

12

12 -62

Use this routine to convert the first decimal number found in the string you
specify to a number, and place this 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.

Input and Output Arguments

This routine has one input argument and two output arguments. The input
argument is the number of the string you want to convert. The first output
argument is the validity value. The second output argument is the
converted 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 output argument indicating that no valid number was in the string).
If the string does not contain a legal value, a zero is returned. A valid
value is between 1 and 255.

Syntax

PUSH

value to be converted

CALL 63

POP

validity value

POP

actual value

Example

>10 STRING 100,14

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

>30 PUSH 1: REM CONVERT STRING 1

>40 CALL 63: REM DO THE CONVERSION

>50 POP V,N

>60 IF V<>0 THEN PRINT $(1),” “,N: GO TO 80

>70 PRINT “INVALID OR NO VALUE FOUND”

>80 END

CALL 63: String to Number
Conversion

Advertising