Well, I don't know how "clever" it is, it just uses signal on syntax:

/* Date Validator */
   parse arg format, date
   signal on syntax name baddate
   b = date('B', date, format)
   return 1
   baddate: return 0

Slightly modified for invocation from the command line:

C:\Documents and Settings\Maint>validate.rex N 13 Mar 2013
      3 *-* parse arg format date
        >>>   "N"
        >>>   "13 Mar 2013"
      4 *-* signal on syntax name baddate
      5 *-* b = date('B', date, format)
        >V>   "13 Mar 2013"
        >V>   "N"
      6 *-* return 1

C:\Documents and Settings\Maint>validate.rex S 20130102
      3 *-* parse arg format date
        >>>   "S"
        >>>   "20130102"
      4 *-* signal on syntax name baddate
      5 *-* b = date('B', date, format)
        >V>   "20130102"
        >V>   "S"
      6 *-* return 1

C:\Documents and Settings\Maint>validate.rex S 01/02/13
      3 *-* parse arg format date
        >>>   "S"
        >>>   "01/02/13"
      4 *-* signal on syntax name baddate
      5 *-* b = date('B', date, format)
        >V>   "01/02/13"
        >V>   "S"
      7 *-* baddate:
        *-* return 0

C:\Documents and Settings\Maint>validate.rex U 01/02/13
      3 *-* parse arg format date
        >>>   "U"
        >>>   "01/02/13"
      4 *-* signal on syntax name baddate
      5 *-* b = date('B', date, format)
        >V>   "01/02/13"
        >V>   "U"
      6 *-* return 1

C:\Documents and Settings\Maint>

-Chip-

On 2/1/2013 10:58 Mark Miesfeld said:
> On Fri, Feb 1, 2013 at 7:05 AM, Staffan Tylen <[email protected]
> <mailto:[email protected]>> wrote:
>
>     Similar problem to a previous posting of mine, does anybody have a
>     'good' way to validate if a string is a valid date or time? I've
>     tried with the .DateTime class but it gives a syntax conditions if
>     the input is wrong. If nothing else I will need to use to signal
>     on I guess.
>
>
> I don't have any clever method here.  Some of the old-time Rexx users
> probably do.  I was hoping that more ooRexx users would participate on
> this list.
>
> I would bet that Chip might have a good method here.
>
> However, based on your 'similar problem' language, what might be a
> good idea for you is to write a utility class.  Maybe call it
> Validater and add some validate methods to it.  You could use signal
> on in the methods to trap errors and return true if there is no trap
> and false if not.
>
> ::class Valdater public
>
> ::method validFile
>      use strict arg fileName
>      ...
>
> ::method validDate
>      use strict arg date
>      ...
>
>
> The implementation of the methods would not necessarily be clever,
> just correct.  Then you wouldn't need to look at the. perhaps ugly,
> implementation code, just use the class.
>
> --
> Mark Miesfeld
>
>
>
> ------------------------------------------------------------------------------
> Everyone hates slow websites. So do we.
> Make your web apps faster with AppDynamics
> Download AppDynamics Lite for free today:
> http://p.sf.net/sfu/appdyn_d2d_jan
>
>
>
> _______________________________________________
> Oorexx-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/oorexx-users
>


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_jan
_______________________________________________
Oorexx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/oorexx-users

Reply via email to