HP 3000 Manuals

CONVERT [ HP Business BASIC/XL Reference Manual ] MPE/iX 5.0 Documentation


HP Business BASIC/XL Reference Manual

CONVERT 

This statement converts a string into a number, with an option for
specifying a line number or label to branch to if an error occurs.
Similar to the VAL function, the CONVERT statement translates a string of
ASCII characters into a numeric value that is assigned to a supplied
numeric variable.  Unlike VAL, the CONVERT statement converts the numeric
value to the type of the numeric variable supplied.  If a line label or
number is supplied and an error occurs, CONVERT branches to the
designated line without requiring an ON ERROR statement.

Syntax 

                 {TO}         [{,}         ]
CONVERT str_expr {, } num_var [{;} line_ref]
                 {; }

Parameters 

Str_expr         A string, substring, or other string expression.

                 The string representation is CONVERTed using the
                 following syntax:

                           ['+']
                 [space]...['-'] num_char [num_char]...['.']

                              [{'e'}['+']                     ]
                 [num_char]...[{'l'}['-']num_char[num_char]...]
                              [{'d'}                          ]

                 num_char is a numeric character in the range [0, 9].  If
                 a syntax error occurs before conversion of the first
                 numeric character, error 32 is generated if line_ref is
                 not supplied.  Once the first numeric character has been
                 converted, if a syntax error occurs, then the value
                 assigned to num_var is the value converted immediately
                 prior to the syntax error.  An HP Business BASIC/XL
                 error number is not generated for this condition.  The
                 string is deblanked before it is converted.

num_var          A numeric variable.

line_ref         A line label or line number that is in the same
                 procedure as the CONVERT statement.  Specification of a
                 line_ref supersedes the error handling action specified
                 in an ON ERROR statement.

Examples 

     10  A$="123"
     20  CONVERT A$ TO A     !A is now 123, and its type is the default numeric.
     99  END

     10  A$="123abc"
     20  CONVERT A$ TO A     !A is now 123, and its type is the default numeric.
     99  END



MPE/iX 5.0 Documentation