Hi, in my new DIR program i need to convert a typed string to a number:
When you type:
$11+[RETURN]
working with $7a and $7b pointers i know that "$" is typed and where is the string null terminated to check, typically in $0200-$0258 range, but how to store the value $0B = #11 in any location/register.
In ML, how to convert a string to a number ?
Moderator: Moderators
I think one way to do it is to call $CD9E to evaluate Basic expression. It will set $0D depending on whether it is a number, string, variable (?) etc. I did this in the fastloader to pick up file name. I don't have more docs about this, but have a look what the mentioned routine does for different input.
Anders Carlsson
thanks carlsson
using the call $CD9E the basic in $0D set the value $ff if is a string like "9ABCD" but if i type 9ABCD without quote the value in $0d is $0 so since for my routines if i type A it's always a syntax error i check for myself if the user type number only (spaces and ":" accepted) and after to convert to a number i've used this method:
now Y/A contain the 16bit integer value (low/high byte) NOT A/Y as in documentation.
using the call $CD9E the basic in $0D set the value $ff if is a string like "9ABCD" but if i type 9ABCD without quote the value in $0d is $0 so since for my routines if i type A it's always a syntax error i check for myself if the user type number only (spaces and ":" accepted) and after to convert to a number i've used this method:
Code: Select all
lda $7a ;write the string starting point present in $7a-$7b
sta $22 ;to INDEX1 $0022-$0023, First utility pointer
lda $7b
sta $23
lda string_length
jsr $d7b5 ;Convert string starting at $0022-$0023 of length (A) to FLPT value in (FAC)
jsr $d1aa ;Convert (FAC) to integer in (Y/A) lo/hi.