Class Parameter - %Library.FilemanDate
Hi,
I am trying to use the LogicialToDate method in the %Library.FilemanDate class. In the class documentation it talks about the parameter STRICTDATA (see below). I would like to set the STRICTDATA to a 1 but I am not sure how to do that when using this method because the method does not reference this as a parameter to be passed into it. (see below).
How do I set the parameter?
Thanks
1/0 flag which determines if the LogicalToFormat conversions will process imprecise logical FileMan Date values Default setting is STRICTDATA=0 Parameter affects the generation of the LogicalToDisplay and LogicalToOdbc methods When STRICTDATA=1, imprecise or invalid dates will not be changed to a valid FileMan Date value. For example, if Logical FileMan Date value is 31110, when STRICTDATA=0 this will translate to 3111001 (Sept 01, 2011). If STRICTDATA=1, this transformation will not take place and the invalid/imprecise Logical value will get an error when converted to Display or Odbc format.
• classmethod LogicalToDate(%val As %Library.FilemanDate ) as%Library.Date
Converts FILEMAN format DATE (CYYMMDD) to %Date format DATE (+$H)
Comments
Datatype parameters can be set as properties parameters.
In your case you have a property somewhere:
Property myDate %FilemanDate;You need to modify it like this:
Property myDate %FilemanDate(STRICTDATA=1);And recompile the class.
Thank you for your answer but I don't have a property that is using the %FilemanDate as a datatype.
The situation is that I have code which is reading a data file that contains a field for the date birth which is in a Fileman format and the code is trying to convert it to $H, thus the code is calling out to the##class(%Library.FilemanDate).LogicalToDate() method. However the data in the field is sometimes bad and when calling the method it errors. We were thinking that if the STRICKDATA was set to a 1 it would either try not to convert it or it would return a null string. It would error more gracefully.
I know that I can add code before calling the method to make sure that the DOB I pass in is the correct Fileman format and is a valid date but I was hoping that the method/class could handle that for me. However I can't figure out how to set the STRICTDATA parameter.
thanks
Kris
Extend %Fileman class:
Class MyFilemanDate Extends %FilemanDate {
Parameter STRICTDATA = 1;
}
And call it:
##class(MyFilemanDate).LogicalToDate()Ok. Thank you!