We are using version 3.12. We used a bracketed function name, DATE_FORMAT, in the Output Format field of a dictionary field for a date. Now no SELECT statements using this dictionary field will work. A LIST displays the dates correctly. What can we do to make the SELECT statement work?
What's in the input format field?
Can you give examples of the code in the DATE_FORMAT routine?
What happens if you take out the DATE_FORMAT from the dictionary?
I don't see an "input format field." We have DATE as the Data Type and D2/ or (D) as the Validation Patterns. Does that answer your question?
Here's the code for the function:
FUNCTION DATE_FORMAT(D1,D2,D3,D4)
D4=OCONV(D2,"D2/":XLATE("TABLE",1,11,"X")) ;* where the xlate gets a conversion character, either null or "E".
RETURN D4
If we take out the DATE_FORMAT and use D2/ it works perfectly.
Thanks for the help,
Lisa Wright
Lisa,
From what you explained, "DATE_FORMAT" is a "user defined conversion". Although your function DATE_FORMAT is not programmed correctly for a "user defined conversion".
I have noticed two possible problems.
1) You are declaring it as a "FUNCTION" and not as a "SUBROUTINE".
2) You have no "ICONV" conversion.
It should be more like this…
SUBROUTINE DATE_FORMAT(TYPE,VALUE,BRANCH,RETURN_VALUE)
BEGIN CASE
CASE TYPE EQ 'ICONV'
RETURN_VALUE=ICONV(VALUE,'D')
CASE TYPE EQ 'OCONV'
RETURN_VALUE=OCONV(VALUE,'D2/':XLATE('TABLE',1,11,'X'))
END CASE
RETURN
END
That works wonderfully! We were just feeling our way through this and have no documentation (that we could find, anyway). Where did you get your information? We would love to get our hands on it!
Thanks so much,
Lisa Wright
Lisa,
I can not remember where I got the original information from. I think it was in the documentation or from an AREV user group meeting.
These info bits might help you.
1) The arguments passed for the subroutine are as follows…
RETURN_VALUE=TYPE(VALUE,'SUB_NAME,BRANCH')
A) TYPE, valid values are ICONV and OCONV.
B) VALUE, string to be converted.
C) BRANCH, optional extra data.
D) RETURN_VALUE, the actual converted string.
2) You might want to set the STATUS() variable as follows…
A) STATUS()=0 if conversion is good.
B) STATUS()=1 if conversion failed.
C) STATUS()=2 if TYPE is invalid.
D) STATUS()=3 if conversion failed and you do not want AREV to display an error message.
3) At the beginning of the subroutine, I would make RETURN_VALUE=VALUE. Then if the conversion is good, set RETURN_VALUE to the good conversion.
User_Defined_Conversion info (and much more) can be found on this site in the AREV Knowledgebase 8/20/98 - System Subroutines and ….
This info was originally DOCed in an Appendix Disk with ARev v2.x or something published before the dawn of time.
Note that an LIST command will invoke the user-defined conversion (UDC) with the input conversion setting but using the output conversion code, so your UDC must be able to process output conversion codes as input conversions. This was discussed in some detail by Sprezzatura in Revmedia volume 2, Issue 5.
Page 408 of the ARev R/Basic Manual also documents them. Do you have those manuals? My last is dated 9/1992 for Version 3.0.
We've got the R/Basic manual. I guess we just didn't know what to look for. Thanks a lot, all of you.
Lisa Wright