Hex Compiling

Anything QL Software or Programming Related.
Post Reply
Derek_Stewart
Font of All Knowledge
Posts: 3928
Joined: Mon Dec 20, 2010 11:40 am
Location: Sunny Runcorn, Cheshire, UK

Hex Compiling

Post by Derek_Stewart »

Hi,

What is the way to compile Hexadecimal numbers with Qliberator and SMSQ/E.

SMSQ/E can display hexadecimal numbers prefixed with a $ symbol.

Unfortunatley, Qliberator gives an error when trying to compile the statement.

Strangely enough, Turbo compiles this with no errors and works as expected.


Regards,

Derek
User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Hex Compiling

Post by tofro »

Derek,

There's an utility somewhere on Per's site (just recently re-opened), I believe, that replaces all hexadecimal constants in S*Basic programs with decimals for compilation. Should come in handy here.

(Thus, this is a just-in.time question)

Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
User avatar
JonS
Bent Pin Expansion Port
Posts: 76
Joined: Fri Nov 11, 2011 3:54 pm
Location: Cumbria

Re: Hex Compiling

Post by JonS »

Why not use HEX command?


User avatar
tofro
Font of All Knowledge
Posts: 2685
Joined: Sun Feb 13, 2011 10:53 pm
Location: SW Germany

Re: Hex Compiling

Post by tofro »

JonS wrote:Why not use HEX command?
You can use that. But if you have a lot of these hex constants in a program, this might
  1. be quite some work
  2. be slow (runtime-wise): QLiberator is not smart enough to see that HEX("<constant>") is still a constant and uses valuable time to do the conversion at run-time. Replacing the hex constant with a "real", numerical constant is much faster
Tobias


ʎɐqǝ ɯoɹɟ ǝq oʇ ƃuᴉoƃ ʇou sᴉ pɹɐoqʎǝʞ ʇxǝu ʎɯ 'ɹɐǝp ɥO
EmmBee
Trump Card
Posts: 240
Joined: Fri Jan 13, 2012 5:29 pm
Location: Kent

Re: Hex Compiling

Post by EmmBee »

tofro wrote: There's an utility somewhere on Per's site (just recently re-opened), I believe, that replaces all hexadecimal constants in S*Basic programs with decimals for compilation. Should come in handy here.
Yes, I've found it here ... http://www.knoware.no/
It can be found under ENTER / GO SUB / DeHex
It looks like a very neat procedure.

Regarding Turbo, I note that it's not possible to compile a $0 or %0.
Those cases would have to use a plain 0.

Michael


Post Reply