![]() ![]() |
|
Conversion Code ExtensionsWith jBASE it is possible to extend the scope of the conversion codes used with the jBC OCONV() and ICONV() functions. As an example, suppose you want to support a conversion code of "XF". The calling jBC source may look like this:
Under normal circumstances, this would fail and the debugger would be entered with an illegal conversion code message. To write an extension for this conversion code, create a normal subroutine with the name JBCUserConversions with five parameters. For example:
Be sure that the cataloged subroutine is visible from the JBCOBJECTLIST environment variable. The subroutine's five parameters are:
NotesThere can be only one JBCUserConversions subroutine which would handle all customized conversion codes. This is a simple matter of extending the above example such that each CASE would handle a different conversion code. Should any extensions to conversion codes clash with those provided by jBASE, the jBASE version will take precedence. For example, you cannot write your own version of the existing "MT" conversion code. Likewise you could not write your own version of any conversion code starting with "D" as these are reserved for 'date' type conversions. In most cases, customized conversion codes can also be used as conversions or correlatives in dictionary definitions for use with jQL sentences. One instance where this is not true, for example, is when the conversion code starts with "B" as this is reserved for calling jBC (Basic) subroutines. If JBCUserConversions is called from jQL then the type is set to -1. This gives the user some control as to whether the subroutine was called from jBC or jQL. jQL |