User's Guide

Using the AbtRecord class with COBOL

For COBOL, use the following code:

"Parses the header file and saves the resulting object table"
| anObjectTable |
anObjectTable := AbtCOBOLLangParser parseFile: 'atm.cpy'.
anObjectTable saveToFile: 'c:\cobolatm.rec'
 
"Restores the object table from the file and
 calls the function using a generic record"
| anObjectTable aSampleCOBOLATMGenericRecord platformFunction |
anObjectTable := AbtObjectTable loadFromFile: 'c:\catm.rec'.
aSampleCOBOLATMGenericRecord := (anObjectTable cobol01s
    at: 'ATM-CUSTOMER' asSmalltalkGlobalIdentifier) newRecord.
aSampleCOBOLATMGenericRecord at: 'pinNumber' put: '12345'.
platformFunction := PlatformFunction
                          callingConvention: 'abtc16'
                          function: 'atm'
                          library: 'atm'
                          parameterTypes: #(pointer pointer)
                          returnType: #none.
platformFunction coroutineCallWithArray:
    (Array with: 'Q' abtAsExternalPassedPointer
           with: (aSampleCOBOLATMGenericRecord
                            abtAsExternalPassedPointer))
    threadKey: nil.
Transcript
    show: (aSampleCOBOLATMGenericRecord at: 'firstName'); cr;
    show: (aSampleCOBOLATMGenericRecord at: 'lastName'); cr;
    show: (aSampleCOBOLATMGenericRecord at: 'checkingBalance'); cr.

For more detailed information on accessing external functions from IBM Smalltalk see the IBM Smalltalk Programmer's Reference.


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]