FormatStr() on Linux (ppc) - unexpected result

Report any Hollywood bugs here
Post Reply
gerograph
Posts: 68
Joined: Thu Mar 04, 2010 9:38 pm

FormatStr() on Linux (ppc) - unexpected result

Post 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"
Flinx
Posts: 351
Joined: Sun Feb 14, 2021 9:54 am
Location: Germany

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

Post 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.
gerograph
Posts: 68
Joined: Thu Mar 04, 2010 9:38 pm

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

Post 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.
Post Reply