Pseudo functions

The pseudo code includes pseudo functions to represent common functions used in your application. These are not actual Bank Wizard functions because you need to develop them to meet your needs. For example logBWCondition is a pseudo function which represents the writing of information to a system log; the actual solution you develop will depend on your operating system, the type of logging that you use and the information you want to include in the log. Using pseudo functions helps you identify the functions that you need to consider during your application design and makes the pseudo code more concise and readable.

logBWCondition(h,type,event)

When called, the handle and a description of the event are passed. The function uses the handle to determine all condition codes and associated message strings. Because something has occurred which may need further investigation, the function logs all conditions in a system log. The event parameter is a system specific value or string which describes what your application was attempting to do at the time of the unexpected event.

Suggested implementation:

logBWCondition(h,event)

{

/* Open the system log - this is installation dependent */

OpenSystemLog("Bank Wizard Alert " + event)

/* Check that the handle is valid */

if (BWIValidHandle(h) != 0) {

/* If not, report the reason */

BWIGetString(h,0,reason)

WriteToSystemLog("Invalid handle: " + reason)

/* Report handle statistics */

BWIGetRuntime(BWI_R_MAX_HANDLES,max)

BWIGetRuntime(BWI_R_NUM_HANDLES,num)

WriteToSystemLog("Maximum handles = " + max + ", number in use = " + num)

/* Close the system log - this is installation dependent */

CloseSystemLog()

/* Finish */

return

}

/* Make sure there is no active iteration */

BWINext(h,BWI_N_NONE)

/* Loop through each severity */

for(type = BWI_N_FATAL; type = BWI_N_INFORMATION; type = type + 1) {

/* Continue while there is another condition of that severity */

while(BWINext(h, type)) {

/* Obtain the condition code */

BWIGetValue(h,BWI_V_NEXT,cond)

/* Obtain the condition string */

BWIGetString(h,BWI_V_NEXT,string)

/* Write details of the condition to the system log */

WriteToSystemLog(type + " " + cond + " " + string)

}

}

/* Write parameters and settings to the system log to aid problem diagnosis */

/* - Country code */

BWIGetValue(h,BWI_V_COUNTRY_CHECK,country)

WriteToSystemLog("Country " + country)

/* - Input parameter strings */

for(i = BWI_V_PAR1; i <= BWI_V_PAR5; i = i + 1) {

BWIGetString(h,i,bwParam)

WriteToSystemLog("Param " + i + "=" + bwParam)

}

/* - Input flags */

for(i = BWI_V_INFLAG + 1; i <= BWI_V_INFLAG_LAST; i = i + 1) {

BWIGetValue(h,i,flagset)

if(flagset) {

WriteToSystemLog("Input flag " + (i - BWI_V_INFLAG) + " set")

}

}

/* Close the system log - this is installation dependent */

CloseSystemLog()

}

The exact behaviour of the function should depend on the context, because some errors should be treated differently when they occur during initialisation. For example, during initialisation you can treat not finding a table for a country as a warning, however if you are trying to validate account details for that country, you must treat it as an error and stop the processing.

If you pass the handle to the logging function, the function can query any additional information to help resolve the issue.