Supposedly baseConvert can, erm, convert, Hexadecimal number into Decimal ones: but this does not seem to be true:
-
-
-
Base Conversions
Forum rules
Be kind.
Be kind.
- richmond62
- Posts: 3896
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Base Conversions
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 3896
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Base Conversions
Another LC-inconsistency:
- -
A Hex number that contains ONLY digits does NOT need double quotes, but a Hex number that contains alphabetics needs double quotes.
- -
A Hex number that contains ONLY digits does NOT need double quotes, but a Hex number that contains alphabetics needs double quotes.
https://richmondmathewson.owlstown.net/
- richmond62
- Posts: 3896
- Joined: Sun Sep 12, 2021 11:03 am
- Location: Bulgaria
- Contact:
Re: Base Conversions
What is interesting is that while that works in the MessageBox,
it does NOT seem to in a button:
The script gets stuck at the baseConvert.
it does NOT seem to in a button:
Code: Select all
on mouseUp
put empty into fld "SCL"
ask "Start of Unicode range in Hexadecimal: "
put it into HEXK
put quote before HEXK
put quote after HEXK
put baseConvert(HEXK, 16, 10) into KOUNT
https://richmondmathewson.owlstown.net/
- tperry2x
- Posts: 2475
- Joined: Tue Dec 21, 2021 9:10 pm
- Location: Somewhere in deepest darkest Norfolk, England
- Contact:
Re: Base Conversions
You could try this. It tries with the quoted and unquoted form, and outputs in the message box:richmond62 wrote: ↑Tue Oct 08, 2024 9:31 am What is interesting is that while that works in the MessageBox,
it does NOT seem to in a button:
The script gets stuck at the baseConvert.Code: Select all
on mouseUp put empty into fld "SCL" ask "Start of Unicode range in Hexadecimal: " put it into HEXK put quote before HEXK put quote after HEXK put baseConvert(HEXK, 16, 10) into KOUNT
Code: Select all
on mouseup
ask "Start of Unicode range in Hexadecimal: "
put it into hHex
try
put baseConvert(hHex, 16, 10) into hCount
catch e
if e is not "" then
put "error while trying unquoted: " & hHex into e
-- try with quotes
put QUOTE & hHex & QUOTE into hHex
try
put baseConvert(hHex, 16, 10) into hCount
catch e
put "error while trying unquoted & quoted approaches: " & hHex into e
end try
end if
end try
if e is "" then
put hCount
else
put e
end if
end mouseup
- OpenXTalkPaul
- Posts: 2266
- Joined: Sat Sep 11, 2021 4:19 pm
- Contact:
Re: Base Conversions
If 'unquoted' how would the script engine know if it's a variable name or a hexadecimal literal? (that's a rhetorical question)richmond62 wrote: ↑Tue Oct 08, 2024 9:00 am Supposedly baseConvert can, erm, convert, Hexadecimal number into Decimal ones: but this does not seem to be true:
The '0x' (like 0x12AF) I believe according to the docs '0x' is supposed to be recognized by the interpreter as a hex literal value, but I don't think it's ever worked the few times I've tried to use it.
I've never had baseConvert not work though.
At some point I think I've rolled my own routine for Decimal<>Hex
I also acquired a script ( sometime in the late 1980s) that does decimal to binary 'bits' (as a string of '0's and '1's) that is about as fast as a compiled external function, even on a 0.6MHz Motorola 68K CPU .
Who is online
Users browsing this forum: No registered users and 2 guests