User Defined Conversion Codes (U)
Users may add their own conversion codes to the system by writing a QMBasic subroutine to perform the conversion. Pick style user exits are provided in this way.
The format of the conversion code is
The subroutine should have four arguments:
subrname(result, src, status, oconv)
See the U50BB subroutine in the BP file of the QMSYS account for an example of a Pick user exit routine.
Handling Undefined Conversion Codes
The U conversion code prefix is primarily intended for emulation of the "user exits" found in Pick style systems. QM provides a more generalised mechanism for handling undefined conversion codes. If a conversion is attempted using a conversion code that QM does not recognise, including U codes for which there is no catalogued handler, it will check for the presence of a catalogued function named UNDEFINED.CONV. If this is present, it is called in a similar manner to the user exit handlers described above but with an fifth argument that contains the conversion code.
UNDEFINED.CONV(result, src, status, oconv, conv.code)
The following example subroutine implements a UDT conversion code which converts a combined date/time value as returned by SYSTEM(1005) to a text representation or vice versa.
SUBROUTINE DT(RESULT, SRC, STATE, IS.OCONV)
IF SRC = '' THEN
RESULT = ''
END ELSE IF IS.OCONV THEN
D = IDIV(SRC, 86400)
T = REM(SRC, 86400)
RESULT = OCONV(D, 'D2/DMY') : ' ' : OCONV(T, 'MTS')
D = FIELD(SRC, ' ', 1)
T = FIELD(SRC, ' ', 2)
RESULT = ICONV(D, 'D2/DMY') * 86400 + ICONV(T, 'MTS')
STATE = 0