At 11:31 PM 4/13/2005, Chuck Finley wrote:

I'm parsing some imported data and want to determine if a
string is a valid date prior to putting it into a variable
with a type of 'date'. If that function is not available,
is there a way to capture and error code to a variable
(without stopping program execution) so if I try to put it
in the variable and it fails, I can take the appropriate
action?

Chuck,

Here's one way:

SET VAR vCheckForDate DATE = NULL

SET ERROR MESSAGE 2178 OFF
SET VAR vCheckForDate = .vYourString
SET ERROR MESSAGE 2178 ON

IF vCheckForDate IS NULL THEN
   SET VAR vPauseMsg = ('Invalid Date!'+(CHAR(009)))
   CLS
   PAUSE 2 USING .vPauseMsg +
   CAPTION 'Your Pause Caption Here ....' +
   ICON STOP +
   BUTTON 'Press any key to re-enter ...' +
   OPTION BACK_COLOR WHITE +
   |MESSAGE_COLOR WHITE +
   |MESSAGE_FONT_COLOR RED +
   |BUTTON_COLOR WHITE
   GOTO whatever
ENDIF

Hope that helps!

Very Best R:egards,

Razzak.



Reply via email to