At 04:17 PM 1/21/2009, Jason Kramer wrote:

The problem is especially strange because if I have SET TRACE ON in my
code, the problem does not happen.

Jason,

That is the result of "WHILEOPT OFF" when the TRACE command in invoked.

Looking at your code and testing everything in detail (yes, I had some
spare time to have some fun ...), is there a particular reason to use
WHILE ... ENDWHILE loop simply to get the Date and Time?

For any reason, if you really have to use the WHILE...ENDWHILE loop to
get the DATETIME using the DIALOG command, follow the modified code as
"Example 1" to get going. Otherwise, use the "Example 2" that explains
the technique without using the WHILE...ENDWHILE loop.

Let me know if you need the actual test files used in my experiment to
have some fun on Wednesday afternoon.

-- Example 1
-- Getting_DATETIME_Using_WHILE_Loop.RMD
CLEAR VARIABLES vMessage,vDans,vEndKey,vTempDt,vReqDateTime
SET VAR vMessage TEXT = NULL
SET VAR vDans TEXT = NULL
SET VAR vEndKey TEXT = NULL
SET VAR vTempDt DATETIME = NULL
SET VAR vReqDateTime TEXT = NULL
LABEL Start
    SET VAR vMessage = 'Double click to show a calendar and clock.'
    SET VAR vDans = NULL
    SET WHILEOPT OFF
    WHILE vDans IS NULL THEN
       DIALOG 'Please enter the date and time this request is needed.' +
       vDans=32 vEndKey 1 +
       CAPTION 'Date and Time Needed' +
       ICON Question +
       OPTION POPUP_ENABLED ON +
       |POPUP_DIALOG_TYPE DATETIME +
       |DIALOG_EDIT_HINT &vMessage +
       |THEMENAME Sports Blue
       IF vEndKey = '[Esc]' THEN
          GOTO Done
          BREAK
       ENDIF
       IF vDans IS NOT NULL THEN
          SET VAR vTempDt = .vDans
       ENDIF
       IF vTempDt IS NOT NULL THEN
          IF vTempDt < .#NOW THEN
             PAUSE 2 USING 'Please enter a time in the future.' +
             CAPTION 'Invalid Time' ICON ERROR
             SET VAR vDans = NULL
          ENDIF
       ELSE
          SET VAR vDans = NULL
       ENDIF
    ENDWHILE
    SET WHILEOPT ON
    SET VAR vReqDateTime = .vDans
    CLS
    PAUSE 2 USING .vReqDateTime +
    CAPTION 'Final Result ...' +
    OPTION THEMENAME Sports Blue
LABEL Done
CLEAR VARIABLES vMessage,vDans,vEndKey,vTempDt,vReqDateTime
RETURN

-- Example 2
-- Getting_DATETIME_Without_WHILE_Loop.RMD
CLEAR VARIABLES vMessage,vDans,vEndKey,vTempDt
SET VAR vMessage TEXT = NULL
SET VAR vDans TEXT = NULL
SET VAR vEndKey TEXT = NULL
SET VAR vTempDt DATETIME = NULL
SET VAR vMessage = 'Double click to show a calendar and clock.'

LABEL Start
    CLS
    SET VAR vDans = NULL
    DIALOG 'Please enter the date and time this request is needed.' +
    vDans=32 vEndKey 1 +
    CAPTION 'Date and Time Needed' +
    ICON Question +
    OPTION POPUP_ENABLED ON +
    |POPUP_DIALOG_TYPE DATETIME +
    |DIALOG_EDIT_HINT &vMessage +
    |THEMENAME Sports Blue
    IF vEndKey = '[Esc]' THEN
       GOTO Done
     ENDIF
     IF vDans IS NOT NULL THEN
        SET VAR vTempDt = .vDans
        IF vTempDt IS NOT NULL THEN
           IF vTempDt < .#NOW THEN
              PAUSE 2 USING 'Please enter a time in the future.' +
              CAPTION 'Invalid Date and Time ...' ICON ERROR +
              OPTION THEMENAME Sports Blue
              GOTO Start
           ENDIF
        ELSE
           PAUSE 2 USING 'Please enter a time in the future.' +
           CAPTION 'Missing Date and Time ...' ICON ERROR +
           OPTION THEMENAME Sports Blue
           GOTO Start
        ENDIF
    ENDIF
    CLS
    PAUSE 2 USING .vDans +
    CAPTION 'Final Result ...' +
    OPTION THEMENAME Sports Blue
LABEL Done
CLEAR VARIABLES vMessage,vDans,vEndKey,vTempDt
RETURN

Have fun!

Razzak.


Reply via email to