13.07.2015 Views

apple-pascal-1.3-manual

apple-pascal-1.3-manual

apple-pascal-1.3-manual

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

TYPE DATEPAYMENT =RECORDDAY, YEAR : INTEGER;MONTH : STRINGEND;RECORDCHECK_HUM : INTEGER;DATE_WR!TTEH, DATE_PAIDAMOUNT : IHTEGERC7l;PAYEE : STRING;ACCT : I i'ITEGEREND;DATE;VAR CHECK : PAYMENT;CHECKBOOK : ARRAY £1 .. 100] OF PAYMENT;The type PAYMENT defines a record with six fields, two of which arerecords of the type DATE. The variable CHECK is a single record of the typePAYMENT; the variable CHECKBOOK is an array of 100 such records. Aprogram using these declarations would access individual fields to store andretrieve data:o CHECKBOOK[N] would refer to the Nth record in the array, a variable ofthe type PAYMENT.o CHECKBOOK[N].DATE_p AID would refer to the date on which the Nthcheck was paid, a record variable of the type DATE.o CHECKBOOK[N].DATE_p AID.MONTH would refer to the month of thedate on which the Nth check was paid, a string variable.IA Shortcut: A shorter way of writing these field references is describedbelow in the section "WITH ... DO''.To number the check records in CHECKBOOK, the program could use theFOR ... TO ... DO statement:FOR N := 1 TO 100 DO CHECKBOOKCHl.CHECK-NUM :• H;To compare the contents of CHECK with the Nth element of CHECKBOOK,it could use the IF ... THEN statement:IF CHECKBOOK[Nl = CHECK THEN --The remainder of this statement would be executed if and only if thecontents of every field of CHECK were the same as the contents of everycorresponding field of the Nth element of CHECKBOOK.III-52Chapter 4: Structured Data Types

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!