91 lines
2.3 KiB
Plaintext
91 lines
2.3 KiB
Plaintext
compile SUBROUTINE VISION_DT_FORMAT( charstr CONV, charstr ANS, charstr BRANCH, charstr RETURN_DATA)
|
|
*
|
|
* VISION_DT_FORMAT is an example of a developer's custom prompt formatting
|
|
* routine using the square brackets call.
|
|
*
|
|
* It should be placed in square brackets, like this:
|
|
*
|
|
* [VISION_DT_FORMAT]
|
|
*
|
|
* This subroutine should be used as the first and only "Input Validation" in
|
|
* a window prompt. Placed in "Output Format", it properly formats internal dates
|
|
* to the YYYYMMDD format used by IR's Vision system
|
|
* 5/13/05 - John C. Henry - J.C. Henry & Co - Cloned from ZIP_FORMAT
|
|
|
|
!
|
|
begin condition
|
|
pre:
|
|
post:
|
|
end condition
|
|
|
|
* Subroutine declarations
|
|
|
|
$insert msg_equates
|
|
|
|
declare function msg
|
|
|
|
* Local Equates
|
|
* The STATUS() variable is used to indicated the error condition of the
|
|
* pattern. They are:
|
|
EQU VALID$ TO 0 ;* Successful
|
|
EQU INVALID_MSG$ TO 1 ;* Bad Data - Print error message window
|
|
EQU INVALID_CONV$ TO 2 ;* Bad Conversion - " "
|
|
EQU INVALID_NOMSG$ TO 3 ;* Bad but do not print the error message window
|
|
|
|
EQU THREEDGRAY$ TO 192
|
|
|
|
* Begin Conversion
|
|
|
|
RETURN_DATA = ""
|
|
|
|
IF ANS NE "" THEN
|
|
thisDate = ANS
|
|
ANS = ""
|
|
STATUS() = VALID$
|
|
|
|
IF NUM(thisDate) THEN
|
|
IF CONV = 'ICONV' THEN
|
|
IF LEN(thisDate) = 8 THEN
|
|
Tmp = ICONV(thisDate[5,2]:' ':thisDate[7,2]:' ':thisDate[1,4],'D')
|
|
IF Tmp NE '' THEN
|
|
RETURN_DATA = Tmp
|
|
RETURN
|
|
END
|
|
END
|
|
ErrorMsg = thisDate:' is not a valid Vision Date (YYYYMMDD).'
|
|
GOSUB DisplayError
|
|
STATUS() = INVALID_NOMSG$
|
|
|
|
END ELSE
|
|
* This is the oconv
|
|
Tmp = OCONV(thisDate,'D4/')
|
|
Month = Tmp[1,'/']
|
|
Day = Tmp[COL2()+1,'/']
|
|
Year = Tmp[COL2()+1,'/'] - 28 ;* Dates in Vision are 'backed up' by 28 years
|
|
Year = Year[-2,2] ;* Use just the last two digits
|
|
|
|
RETURN_DATA = Year:Month:Day
|
|
RETURN
|
|
END
|
|
|
|
END ELSE
|
|
STATUS() = INVALID_NOMSG$
|
|
RETURN
|
|
END ;* End of check for numeric data passed in
|
|
END
|
|
|
|
RETURN
|
|
|
|
|
|
|
|
DisplayError:
|
|
msgrec = ""
|
|
msgrec<MCAPTION$> = "Data Validation Error"
|
|
msgrec<MTEXT$> = ErrorMsg
|
|
msgrec<MBKCOLOR$> = THREEDGRAY$:@VM:THREEDGRAY$:@VM:THREEDGRAY$
|
|
msgrec<MJUST$> = 'L'
|
|
result = msg( "", msgrec)
|
|
return
|
|
|
|
|