Instead of this sort of thing:
Code: Select all
put 1 into KOUNT
repeat until KOUNT > 10
-- do something
add 1 to KOUNT
end repeat
so it can pump out Hex numbers, so that loop (for the sake of argument) goes round '10' (Sixteen) times?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Code: Select all
put 1 into KOUNT
repeat until KOUNT > 10
-- do something
add 1 to KOUNT
end repeat
richmond62 wrote: ↑Mon Oct 07, 2024 11:18 amWell, err, yeah . . .
Instead of this sort of thing:
which will send that loop round 10 (Ten) times, is there a way I can make my loop count up 1,2,3,4,5,6,7,8,9,A,B,C,D,E,FCode: Select all
put 1 into KOUNT repeat until KOUNT > 10 -- do something add 1 to KOUNT end repeat
so it can pump out Hex numbers, so that loop (for the sake of argument) goes round '10' (Sixteen) times?
Code: Select all
repeat until KOUNT > 16
Code: Select all
baseConvert(<number>, <originalBase>, <destinationBase>)
-- or in your case:
baseConvert(KOUNT, 10, 16)
I am sure I did manage this in Zilog in about 1984.I'm pretty sure there is not a single language that does this
Err: why not: after all our Maths teacher had us doing this with dried peas in 1975/6?What you are requesting doesn't make much sense.
No, I did not: had I 'presumed' there would have been no point in my asking the question.Presumably you meant to write
Really, you set up as:I am sure I did manage this in Zilog in about 1984.
Code: Select all
repeat with y = 1 to F
Code: Select all
repeat with y = 1 to F
if y = "C" then answer "You made it to a dozen. Congrats"
Javascript, like most (all?) programing languages, knows how to handle Hexadecimal.
Code: Select all
for (i=0x0; i < 0x30; i++) { print("0x0" + i.toString(16) +" = " + i) }
Code: Select all
put 0x1 into KOUNT
repeat until KOUNT > 0xF
--do something
add 1 to KOUNT
end repeat
Code: Select all
on mouseUp
put empty into fld "SCL"
put 1 into LYNE
put 0x1 into KOUNT
repeat until KOUNT > 0xF
put KOUNT into line LYNE of fld "SCL"
add 1 to LYNE
add 0x1 to KOUNT
end repeat
end mouseUp
Code: Select all
on mouseUp
put empty into fld "SCL"
put 1 into KOUNT
repeat until KOUNT > 0xF
put baseConvert(KOUNT, 10, 16) into line KOUNT of fld "SCL"
add 1 to KOUNT
end repeat
end mouseUp
Hi Richmond,richmond62 wrote: ↑Mon Oct 07, 2024 4:24 pmThis:
####
spits out this:
####
which, while being preferable to a poke in the face with a sharp stick, is a fudge.
Code: Select all
on mouseUp
local KOUNT, tHex
put empty into fld "SCL"
put 0 into KOUNT
put empty into tHex
repeat until KOUNT > 1024
put baseconvert(KOUNT, 10, 16) into tHex
put KOUNT & ": "& "0x" & tHex into line KOUNT + 1 of fld "SCL"
add 1 to KOUNT
end repeat
end mouseUp
But well documented:richmond62 wrote: ↑Tue Oct 08, 2024 10:04 amOh, "YUM!": serious inconsistency here:
So a Hex number that contains ONLY digits does NOT need double quotes, but a Hex number that contains alphabetics needs double quotes.
Kind regardsThe number to be converted, expressed in its original base. The number
must be an integer between zero and 4,294,967,295 (2^32 - 1). If the
number includes non-digits (as, for example, a base-16 number can
include letters A-F), enclose the number in quotes.
Code: Select all
on mouseUp
put "2D80" into MAGIC
put baseConvert(MAGIC,16,10)
end mouseUp
You have the ability to make it less confusing, simply by ALWAYS quoting the number in quotes regardless of whether it is simple digits or mixed digits/alphabetical.