by Yi Kun Lin - GUI Computing
Visual Basic's ability to use ODBC to connect to databases other than Access, has allowed Database vendors to enter into the rapidly expanding GUI Market. One such vendor is Information Resources Inc. who have developed a backend called pcEXPRESS.
pcEXPRESS is a multi-dimensional database which can have up to seven dimensions organised in tables much like a standard spreadsheet. pcEXPRESS allows you to create complicated queries, or 'Rotations', simply by changing the order of the table dimensions.
IRI have now released an API suite which allows current users to retain their database and move to the GUI interface. The API's work exactly like any other Windows API and developers that are currently using pcEXPRESS will be happy to learn that the syntax they are using currently has changed little in the new standard.
A component called the PIPE handles the communications link between the Windows client side and pcEXPRESS server side at a low level. The retrieved large block of pcEXPRESS data is then stored in binary form. The API has two basic properties: Message and Data. Before starting the conversation with the pcEXPRESS server, the front-end must open a pipe connection by setting CCXAPIíS message-handling property XAPIMode to True. If pcEXPRESS is not running, the pipe connection fails and a trappable error is returned. In this case, the Visual Basic shell function can be used to start pcEXPRESS, after which a connection can be established.
Sub StartUp (ByVal PATH As String) dim Temp gXAPIErrorCode = PR_SUCCESS ' to initialise to CCXAPI error code gPipeOpened = False ' and pipe connection flag If .XAPI1.XAPIReady = False Then ' if the pipe connection is not open .XAPI1.XAPIMode = True ' try to open pipe connection End If ' wait til pipe connection open or error occurs Do While gXAPIErrorCode = PR_SUCCESS And gPipeOpened = False temp = DoEvents() Loop If XAPIErrorCode = PR_PCX_UNCON Then ' pcEXPRESS is not running Temp = Shell ( PATH, WIN_MINIMIZED) ' launching pcEXPRESS with shell function XAPI1.XAPIMode = False ' stop opening pipe connection gXAPIErrorCode = PR_SUCCESS ' initialise the error code again If gPCXStarted = True Then ' pcEXPRESS started successfully XAPI1.XAPIMode = True ' reconnect pipe End If Else ' pcEXPRESS is already running XAPI1.XAPIMode = True ' reconnect pipe End If End Sub
In above code, the global error variable gXAPIErrorCode is assigned a value according to the error type in XAPIError events; global Boolean variable gPipeOpened is set to True in XAPIOpen event triggered when the pipe connection is successfully opened; global Boolean variable gPCXStarted is set to True in XAPIPoke event trigged when a response message is received from pcEXPRESS.
Once a Pipe connection has been established, the application can send its requests, typically a pcEXPRESS command, via the API. For example;
XAPI1.XAPICommand = ExpressCommand$ XAPI1.XAPISend=True
It is important to synchronise the clientís requests and serverís responses as the API control does not support multiple transactions. If this is not catered for, some previous serverís response may be lost. This problem can be prevented by using modal forms or disabling buttons to avoid users from sending further requests.
To retrieve a block of data from pcEXPRESS, you can assign a pcEXPRESS FETCH command to XAPICommand and set XAPISend to True. For example:
XAPI1.XAPICommand ="FETCH SALES LABELED" XAPI1.XAPISend=True
Again a trappable error will be returned if the operation fails. Otherwise the data block is successfully returned into an array.
From my viewpoint, although you still have to write a few lines of code to
process the retrieved data in the array, you can probably benefit from
saving the code of handling queries with pcEXPRESS's powerful multi-dimension
feature. On the other hand, Visual Basicís GUI capability can certainly make
pcEXPRESS more user-friendly.