In the source code for T1520IC1, the main() function:
Figure 56. ILE C Source to Call Functions in Other Modules
/* This program demonstrates how to use multiple modules, service */
/* programs and a binding directory. This program accepts a user ID, */
/* item name, quantity, and price, calculates the total cost, and */
/* writes an audit trail of the transaction. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h.>
#include <decimal.h>
int calc_and_format (decimal(10,2),
short int,
char[]);
void write_audit_trail (char[],
char[],
decimal(10,2),
short int,
char[]);
int main(int argc, char *argv[]) (1)
{
/* Incoming arguments from a CL program have been verified by */
/* the *CMD and null ended within the CL program. */(2)
char *user_id;
char *item_name;
short int *quantity;
decimal (10,2) *price;
char formatted_cost[22];
/* Incoming arguments are all pointers. */(3)
item_name = argv[1];
price = (decimal (10, 2) *) argv[2];
quantity = (short *) argv[3];
user_id = argv[4];
/* Call an ILE C function that returns a formatted cost. */(4)
/* Function calc_and_format returns true if successful. */
if (calc_and_format (*price, *quantity, formatted_cost))
{
write_audit_trail (user_id, (5)
item_name,
*price,
*quantity,
formatted_cost);
printf("\n%d %s plus tax = %-s\n", *quantity,
item_name,
formatted_cost);
}
else
{
printf("Calculation failed\n");
}
return 0;
}
|
Notes:
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.