Output Formatting question

How do I do this in Xojo?
printf $outputfilehandle “%02X”, $myinteger8;

#in perl this gives me:

I tried this, but cannot figure out how to get leading zeros

#in xojo I get

Const myinteger8 = 2869283847
stdout.Write(Str(myinteger8)) + EndOfLine
stdout.Write(Hex(myinteger8)) + EndOfLine

For me shows:


I should have been more precise in my question. It was late when I posted it.

If In perl I do:
my $myint = 5;
printf “%04X”, $myint;

I get “0005” on standard out.

If in Xojo I do (dont have a console lincese)
dim myint16 as int16 = 5
msgbox hex(myint16)

I get “5” in my message box.

My usage needs the leading zeros

Have you looked at the Format method?

Format(myint16, "0000")

[quote=88200:@Bill Gookin]Have you looked at the Format method?

Format(myint16, "0000")

That’s going to give the output as an Integer, not hex.

The only thing I know to do off the top of my head is something like:

stdout.Write(Right("0000000000" + Hex(myinteger8), 10)) + EndOfLine

10 being how many places you want to see of course. You could write that into a method easily enough.

Thank you

Ah, I was typing without thinking. :slight_smile: