Page 1 of 1

FormatStr() on Linux (ppc) - unexpected result

Posted: Fri Jan 16, 2026 10:06 am
by gerograph
If using this code on windows and Hollywood 10:

Code: Select all

Function p_getDateYYYYMMDD()
	mo$ = "1" 
	mo$ = FormatStr("%02s", mo$)
	tag$ = "12" 
	tag$ = FormatStr("%02s", tag$)
	Return ("2026"..mo$..tag$)
EndFunction

str$ = p_getDateYYYYMMDD()
DebugPrint(str$)
It will properly output: 20260112

Using the same code in Void Linux on my X1000 it gives me: 2026 112. Seems like Linux interpretes "0" as "space"

Re: FormatStr() on Linux (ppc) - unexpected result

Posted: Fri Jan 16, 2026 1:12 pm
by Flinx
Your syntax is incorrect. You are attempting to output a string with two digits and a leading zero. But this is only defined for numbers, so to fix just this line:

Code: Select all

mo$ = FormatStr("%02d", ToNumber(mo$))
But your function doesn't seem to make sense to me at all. Why don't you use FormatDate()?

I don't know why the incorrect format string produces different results in Linux and Windows, but that doesn't really matter.

Re: FormatStr() on Linux (ppc) - unexpected result

Posted: Fri Jan 16, 2026 3:29 pm
by gerograph
@Flinx
Thanx :-)
I don't know why the incorrect format string produces different results in Linux and Windows, but that doesn't really matter.
True, but still strange...
But your function doesn't seem to make sense to me at all. Why don't you use FormatDate()?
Didn't know this function existed (yeee! RTFM)...I found part of my code somewhere here on the forum... but seems FormatDate() does what I want. Thanx for the hint.