Last episode saw the definition of a string data structure for COBOL. This episode will show how to write Pascal Code to manipulate the string data structure (cst-string).
Using these examples, it would be easy enough to implement any needed string processing procedure.
I have created 3 Pascal procedures: cstset, cstdeb, and cstrightj.
cstset is used to initialize cst-string by moving text from a buffer into cst-string and setting the cst-len appropriately. It replaces the COBOL-only code I did in the prior post.
cstdeb (deblank) will remove leading and trailing spaces from cst-string.
cstrightj (right justify) will right justify the text in cst-string using the specified field width.
To make using these procedures easier, there is a copy book (.cpy file) for each call: cfCstSet, cfCstDeb, and cfCstRightJ.
Rather than describe all of the parts, the following file contains a listing of the Pascal program, commands to compile and execute the Pascal and COBOL code with the resulting run’s output, and finally the compiler’s listing of the COBOL code.