OpenDCL Forums

OpenDCL => Runtime/AutoLISP => Topic started by: khann on March 24, 2010, 02:01:03 AM

Title: dcl_Calendar_SetCurSel Return Value
Post by: khann on March 24, 2010, 02:01:03 AM
Code (autolisp) Select

(setq *Inst_Day_Text "20100230")
(setq *YYYY (substr *Inst_Day_Text 1 4))
(setq *MM (substr *Inst_Day_Text 5 2))
(setq *DD (substr *Inst_Day_Text 7 2))

(setq *Temp_Date (list (read (strcat *YYYY ".0")) (read *MM) (read *DD)))

(setq *Chk_Date (dcl_Calendar_SetCurSel Calendar_form_calTemp *Temp_Date))



Hi,
The above is my test code of dcl_Calendar_SetCurSel  to check the
*Inst_Day_Text is valid.

I need the T or nil return value but this returns ADS request error.
Someone help this, please.
Thanks.
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: Fred Tomke on March 24, 2010, 02:39:09 AM
Hi, don't use (list 2010 3 024) for date but (list 2010.0 3 24) for the date.

Fred
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: Kerry on March 24, 2010, 02:53:09 AM
Fred
in the posted example *Temp_Date will evaluate to (2010.0 2 30), so I don't think that's the trouble.
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: khann on March 24, 2010, 02:53:40 AM
Hi, Fred.

Yes. I did.

Code (autolisp) Select
(strcat *YYYY ".0")

I checked this list : (2010.0 2 30) .

I need the nil Return.
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: Fred Tomke on March 24, 2010, 04:12:04 AM
Quote from: Kerry Brown on March 24, 2010, 02:53:09 AM
in the posted example *Temp_Date will evaluate to (2010.0 2 30), so I don't think that's the trouble.

Sorry, my look was too short to recognize this. I'm just at a customer training.

Fred
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: owenwengerd on March 24, 2010, 06:17:23 AM
Quote from: khann on March 24, 2010, 02:01:03 AM
I need the T or nil return value but this returns ADS request error.

The exception is by design. Since there are potentially other reasons why the function might return NIL, I don't think it's a good idea to use that function for the purpose of validating a date, however I'm open to other opinions.
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: khann on March 24, 2010, 05:47:32 PM
Hi.
I was coding Date Validation routine.
*Inst_Day_Text is 8 digit formatted user input string.

For checking leap year February's 29 day, I tried the
dcl_Calendar_SetCurSel .

Has got any better idea?
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: owenwengerd on March 24, 2010, 08:50:13 PM
It's a kludge, but you can do something like this:

Code (autolisp) Select
(defun ValidateDate (date / result)
  (dcl_suppressmessages T)
  (setq result (vl-catch-all-apply 'dcl_calendar_setcursel (list <CONTROL> date)))
  (dcl_suppressmessages NIL)
  result
)


You could also get fancy and use the ActiveX Windows date time picker control in a similar way.
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: khann on March 24, 2010, 09:54:02 PM
Thanks, it's so good.
And you tell me the usage of  dcl_suppressmessages  

But I wonder the Help page of "dcl_Calendar_SetCurSel "
-----------------------------------------------------------------------------------------------------
Syntax  :        (dcl_Calendar_SetCurSel  form_Calendar Date [as Date])
Return Type  : Boolean (T if successful; otherwise NIL)
-----------------------------------------------------------------------------------------------------

If it fails why does not return NIL ?
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: owenwengerd on March 24, 2010, 11:06:56 PM
When a function throws an exception, it does not return.
Title: Re: dcl_Calendar_SetCurSel Return Value
Post by: khann on March 24, 2010, 11:53:56 PM
Mmm. I see.

Thanks for your reply.