Call 63 – string to number conversion, Call 63 – string to number conversion -4, Example – Rockwell Automation 1746-BAS BASIC LANGUAGE User Manual

Page 246: Purpose, Syntax

Advertising
background image

Publication 1746-RM001A-US-P

15-4 String Functions

Example

>1

REM EXAMPLE PROGRAM

>10 STRING 100,14

>20 INPUT “ENTER A NUMBER TO CONVERT TO A STRING ”,N

>30 PUSH N : REM NUMBER TO CONVERT TO STRING

>40 PUSH 1 : REM CONVERT NUMBER TO STRING 1

>50 CALL 62 : REM DO THE CONVERSION

>60 PRINT $(1)

>70 END

READY

>RUN

ENTER A NUMBER TO CONVERT TO A STRING 2E3

2000

READY

>RUN

ENTER A NUMBER TO CONVERT TO A STRING 1.233

1.233

READY

>

CALL 63 – String to
Number Conversion

Purpose

Use CALL 63 to convert 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.

If the string does not contain a legal value, a 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 of the value, then POP the actual value. If a string
contains a number followed by an E and a letter or non-numeric character, it is
assumed that no number was found since the letter is not a valid exponent. (CALL
63 returns a zero in the first argument popped indicating that no valid number was
in the string.)

Syntax

PUSH [string number to convert]
CALL 63
POP [validity of the value]
POP [actual value]

Advertising