Repeat loops using Hexadecimal?

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: Repeat loops using Hexadecimal?

Post by richmond62 » Sat Dec 28, 2024 5:28 pm

Indeed. 8)

The 'advantage' with Fortran and its ilk was that variables were numeric, and strings were strings, do if one put 'A' into a string constant, say $X, the machine would interpret that as a letter, and if it were put into a variable it would be interpreted as a number.

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Repeat loops using Hexadecimal?

Post by dunbarx » Sat Dec 28, 2024 7:18 pm

Richmond.
and if it were put into a variable it would be interpreted as a number.
Long time since I wrote any Fortran, but are you saying Fortran would return "true" with (pseudo):

Code: Select all

REAL :: tVar
if tVar = C then answer (C-5) = 7
Craig

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10317
Joined: Wed May 06, 2009 2:28 pm

Re: Repeat loops using Hexadecimal?

Post by dunbarx » Sat Dec 28, 2024 7:27 pm

Richmond.

Are you still trying to use 0-F as a suite of integers in LC? I am sure you can create a gadget that translates those sixteen chars into numbers, and proceed from there.

No?

Or can you post an example of what you are trying to do with them?

Craig

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: Repeat loops using Hexadecimal?

Post by richmond62 » Sat Dec 28, 2024 7:31 pm

Both.

Reason lost in time.

Still interested just for fun.

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 10096
Joined: Fri Feb 19, 2010 10:17 am

Re: Repeat loops using Hexadecimal?

Post by richmond62 » Sat Dec 28, 2024 8:00 pm

Here's a quick dose of pseudo-code:

Code: Select all

put 1 into CYCLE
            repeat until CYCLE > 0x100
            -- do something
            add 1 to CYCLE
            end repeat
That should repeat 256 times (i.e. hex 100).

SparkOut
Posts: 2944
Joined: Sun Sep 23, 2007 4:58 pm

Re: Repeat loops using Hexadecimal?

Post by SparkOut » Sat Dec 28, 2024 11:24 pm

This bit
richmond62 wrote:
Mon Oct 07, 2024 4:13 pm

Code: Select all

for (i=0x0; i < 0x30; i++) { print("0x0" + i.toString(16) +" = " + i) }
only initialises the two values to control the loop from the hex values 0x0 and 0x30. There's no functional difference in specifying those values as decimal integers 0 and 48. Internally, the loop stores those values presumably as binary floats. Or piles of pebbles. Or whatever. The loop is not counting in hex - the output has to be constructed by creating a string from "0x0" and the value of the loop index converted to a string representation in base 16 with the appropriate syntax. That's no less "fudgy" than using LC baseConvert syntax.

It should be very straightforward to use baseConvert in the pseudocode loop you mentioned to make this real code, without bending it much.

Post Reply