Page 1 of 1

isNumber vs isDate

Posted: Mon Oct 08, 2012 7:01 pm
by lohill
I can use isNumber to determine if an input field has had a number entered but I'm not sure how to tell if what was just entered is a legitimate date. There does not appear to be an isDate function that returns true or false like isNumber. I have tried converting the input to dateItems and looking at that result but even a plain number will cause dateitems to give a date. Do you have a suggestion for looking at the input on closeField to tell whether the input is really a date.

Thanks,
Larry

Re: isNumber vs isDate

Posted: Mon Oct 08, 2012 7:10 pm
by Klaus
Hi Larry,

you CAN in fact do this:
...
answer ("10/8/12" is a date)
## -> true
...
:D

Although there is no function "isDate".


Best

Klaus

Re: isNumber vs isDate

Posted: Mon Oct 08, 2012 7:28 pm
by mwieder
Klaus-

The problem isn't with determining what is a date, but what isn't a date.

put 1234 is a date
==> true

the date functions are so flexible and forgiving of user inputs that it's harder for something to fail date verification.

Re: isNumber vs isDate

Posted: Mon Oct 08, 2012 9:06 pm
by Klaus
Hi Mark,

yes, you are right, always forget this :-/

Re: isNumber vs isDate

Posted: Mon Oct 08, 2012 9:42 pm
by Mark
Hi,

I believe the isNumber and isDate are SuperCard syntax.

If a string is a number, then it is probably not date, but it could be seconds or milliseconds.

Code: Select all

put ("10/10/10" is not a number) and ("10/10/10" is a date)
--> true

put ("123456" is not a number) and ("123456" is a date)
--> false

put ("abcdefgh" is not a number) and ("abcdefgh" is a date)
--> false

The following is slightly problematic:
put ("10/10" is not a number) and ("10/10" is a date)
--> true
You might want to check that the date consists of 3 items in the last case.

Kind regards,

Mark

Re: isNumber vs isDate

Posted: Tue Oct 09, 2012 1:30 am
by dunbarx
This goes way, way back. It can be managed easily, but talk about too flexible. You always have to remember to make sure that what you WANT to be a date is the only form that is allowed.

Craig