Page 2 of 2

Posted: Fri Jan 02, 2004 2:21 pm
by blueznl
do .. loop is common in a number of dialects, true, often combined with exit (if)

Code: Select all

do
  whatever
  if a!=true
    exit
  endif
loop

hey, psycho, you wanna' turn purebasic into an even more non-basic basic? :-)

an alternative syntax for do .. loop i've seen is repeat .. forever :-)

re aliases... gfabasic (16) just implemented each and every flavour of each command, including some very weird ones... type casting: L: W: B:... alternative peeks {WORD} {CARD} etc. although they sometimes went a little overboard...

Posted: Fri Jan 02, 2004 2:43 pm
by Wayne Diamond
Here's a Purebasic version of what i meant with the Hex function. It's not as efficient as i'd like but it'll do for now.

Code: Select all

Procedure.s HexEx(inValue.l, inLength.l)
 outHex.s = Hex(inValue): minLen.l = Len(outHex): outHex = Space(inLength) + outHex
 outHex = ReplaceString(outHex, " ", "0", 1, 1): If minLen < inLength: minLen = inLength: EndIf
 outHex = Right(outHex, minLen): ProcedureReturn outHex
EndProcedure
 
MessageRequester("HexEx Test", HexEx(1212, 8), 0)  ;// returns 000004BC

Posted: Fri Jan 02, 2004 3:24 pm
by tinman
Wayne Diamond wrote:Thanks, but Right/Left pads it out with spaces, not the "0" numeric char which is needed for such a Hex function, but it'll be easy to knock up in asm - looks like that'll be on tonights menu ... :)
Doh. I thought Hex() always produced an 8 character string with leading zeros. If that's not the case then you can use RSet(Hex(20), 6, "0") for a 6 character hex string padded with leading zeros.

Posted: Fri Jan 02, 2004 4:52 pm
by Wayne Diamond
then you can use RSet(Hex(20), 6, "0")
Yep that works well, nice one :)