May 29, 2024, 06:05:03 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


DATE$ problem?

Started by Andy, October 24, 2011, 12:35:55 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

Andy

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.
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Larry, that's a great fix! I've put it into my incc file. Works a treat
for this side of the Pond!

Brian

Rock Ridge Farm (Larry)

I fixed the .incc file - testing latest version now.
Will post when ready for download.

Larry

Andy

Just thought i'd say thanks everybody!

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

Thanks again,
Andy.
:)
Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.