This code, developed to run under Windows/98, was designed to demonstrate simple arithmetic and the use of STEM variables in Windows/REXX.

/* REXX for Windows Read names, and amounts, and calculate discount.  */
name. = '';                          /* Stem variable for gotten names. */
nom = ''; i = 1; n = 1; balance = 0;
/*
   Set up file for processing.
*/
infile = .STREAM~NEW("c:\REXXdata\demo3i"); 
signal on notready
Do Forever                           /* Phase1 - Get names & amounts. */
    inline = (infile~LINEIN())
    Parse Var inline nom  amount .
    name.i = nom;
    balance = balance + amount
    i = i + 1;
End;
/*
   End of input, report results.
*/
notready:
i = i - 1;
Say i '- names read, total value is -' '£'||balance; Say ' ';
discount = balance/100*12;           /* Calculate the discount. */
due = balance - discount;
Say 'Total = ' '£'||balance 'Less discount of 12% - ' '£'||discount,
    ' Final Amount -' '£'||due;
Say " "; Say 'REXX for Windows Demo - Successfully completed.'
Exit 0                               /* leave program */

To compare with the TSO/E REXX version click here or the Java version click here.

Copyright © KMS-IT Limited 2002