IonicWind Software

IWBasic => IWB3.x Bug Reports => IW2.0 Bug Reports => Topic started by: Andy on October 24, 2011, 12:35:55 AM

Title: DATE$ problem?
Post by: Andy on October 24, 2011, 12:35:55 AM
I'm now on the latest version of IW & compiler.

Why does the date$ function not return any values?

This example works in EB but does not print any values in IW now I have upgraded it.

DEF dat1$,dat2$,dat3$,dat4$:string

OPENCONSOLE

dat1$ = MID$(date$,1,2)
dat2$ = MID$(date$,4,2)
dat3$ = MID$(date$,7,4)

dat4$ = dat1$+"-"+dat2$+"-"+dat3$

PRINT DATE$
PRINT dat1$
PRINT dat2$
PRINT dat3$
PRINT dat4$

DO:UNTIL INKEY$ <> ""
End

is this a bug (or more likely me?)
Thanks,
Andy.
Title: Re: DATE$ problem?
Post by: Andy on October 24, 2011, 01:05:06 AM
Just a quick note,

I have found one solution, you can use:

PRINT DATE$("dd MM yyyy")
dat4$ = DATE$("dd MM yyyy")

Both of these will return a date value, but not date$ on it's own.

Andy.
Title: Re: DATE$ problem?
Post by: LarryMc on October 24, 2011, 07:45:09 AM
Evidently, Sapero changed the source for that function because it should use the default format string if none is provided.

Did a little more research.
As it turns out the DATE$ function itself wasn't changed.

When Sapero was going through the parser code and fixing things he tried to get rid of all the little patches of code that were exceptions to the rules.
There is a rule that when you have an OPTIONAL parameter in a call to a function that you declare the function and supply a default value like
OPT myparam=0 AS INT
The DATE$ function wasn't declared that way.
No default was specified in the declaration statement.

So, by cleaning up the original parser code, that particular piece of code was broken.

The fix is easy.
LarryS needs to modify the iwbstd.incc file.
This entry:
$command DATE$(OPT strFormat as STRING),HEAP
needs to be changed to:
$command DATE$(OPT strFormat="dd-MM-yyyy" as STRING),HEAP

As Andy noted, the function will work fine if you pass it a formating string.

It also should be noted that the help file is incorrect.
It states:
QuoteDefault format is DD-MM-YYYY
That has never been the case.
The default is
QuoteMM-dd-yyyy


LarryMc
Title: Re: DATE$ problem?
Post by: Brian on October 24, 2011, 12:50:35 PM
Larry, that's a great fix! I've put it into my incc file. Works a treat
for this side of the Pond!

Brian
Title: Re: DATE$ problem?
Post by: Rock Ridge Farm (Larry) on October 25, 2011, 07:15:48 AM
I fixed the .incc file - testing latest version now.
Will post when ready for download.

Larry
Title: Re: DATE$ problem?
Post by: Andy on October 26, 2011, 04:04:41 AM
Just thought i'd say thanks everybody!

Yes all looks good for me too, no problems now.

Thanks again,
Andy.
:)