Page 1 of 1
[Implemented] Extension for VAL()
Posted: Wed Mar 26, 2003 8:27 pm
by BackupUser
Restored from previous forum. Originally posted by GPI.
for example val("$1234") and val("%01001011").
PII 333, 256MB, Asus TNT2Ultra 32MB, AWE Gold 64 4MB
Posted: Sat Mar 29, 2003 9:18 am
by BackupUser
Restored from previous forum. Originally posted by Amiga5k.
You could use Hex() or Bin() within the Val() statement to achieve this, I think.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
Posted: Sat Mar 29, 2003 12:08 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by Amiga5k
You could use Hex() or Bin() within the Val() statement to achieve this, I think.
Nope, because the strings they create are in hexadecimal which brings you to the same point that GPI is at...how to convert a string in a non-decimal number base to a number.
I think the MathExtras user library has the commands IBin and IHex which does what GPI is looking for.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
Posted: Sat Mar 29, 2003 8:11 pm
by BackupUser
Restored from previous forum. Originally posted by Amiga5k.
I'm thinking that GPI wants to accept a string from a user or manipulate a string suring runtime and get it's 'real' value? If not, wouldn't Val($1234) or Val(%01001011) work? (without the quotes). Haven't tried this, though.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***
Posted: Sat Mar 29, 2003 8:50 pm
by BackupUser
Restored from previous forum. Originally posted by tinman.
Originally posted by Amiga5k
I'm thinking that GPI wants to accept a string from a user or manipulate a string suring runtime and get it's 'real' value?
Yes, that seems to be the case.
If not, wouldn't Val($1234) or Val(%01001011) work? (without the quotes).
No, because:
1) Val does not convert number bases other than decimal
2) Without the quotes you are passing the wrong type of parameter to Val - it has to be a string.
3) If you had $1234 in a numeric variable then you would not need to convert it with Val. A number is the same number no matter what base it is displayed in for our understanding.
--
I used to be a nihilist but I don't believe in that any more.
(Win98first ed. + all updates, PB3.62, external editor)
Posted: Sun Mar 30, 2003 10:08 pm
by BackupUser
Restored from previous forum. Originally posted by Amiga5k.
Bummer.
Russell
***Commodore 64 - Over one million cycles per second, 16 vibrant colors, 3 incredible audio channels and 38,911 Basic Bytes Free! Who could ask for anything more?***