Quantcast
Channel: LiveCode Forums
Viewing all articles
Browse latest Browse all 672

Getting Started with LiveCode - Complete Beginners • Re: Repeat loops using Hexadecimal?

$
0
0
Well, err, yeah . . .

Instead of this sort of thing:

CODE:

put 1 into KOUNTrepeat until KOUNT > 10-- do somethingadd 1 to KOUNTend repeat
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,F
so it can pump out Hex numbers, so that loop (for the sake of argument) goes round '10' (Sixteen) times?

What you are requesting doesn't make much sense. I'm pretty sure there is not a single language that does this, but I may be wrong.

The loop you give in your example will never use hex digits because the counter never goes above 10.
You can't make a loop "that loop round 10 (Ten) times" starting from 1 and make it count up to F in hexadecimal ;)
Presumably you meant to write

CODE:

repeat until KOUNT > 16
If you need to iterate base-10 numbers and pass them as base-16, you could iterate 1 to 16 and convert the current iteration number to hexadecimal using

CODE:

baseConvert(<number>, <originalBase>, <destinationBase>)-- or in your case:baseConvert(KOUNT, 10, 16)

Statistics: Posted by stam — Mon Oct 07, 2024 12:01 pm



Viewing all articles
Browse latest Browse all 672

Trending Articles