I display many tables, and most of the code within the display loops are repeated in each. I want to pull out the repeated code into a “to decide” or “to assign traits” function. What is the syntax for calling that routine? Example:
To display armor table:
let PriceValue be a real number;
say "[line break][bold type][line break] A R M O R[line break]";
say "Armor Nbr Cost Weight[line break][roman type]";
repeat through the Table of BodyProtection: [reading table before displaying]
now PriceValue is Cost entry * ChrAdj;
let price be coinage of PriceValue; [text]
say "[fixed letter spacing][item entry] [nbr entry] [price] [weight entry] [AC entry][variable letter spacing][line break]";
now item entry is in Ganon's Emporium;
** now cost of item entry is cost entry; [base cost before Chr adj to get price]**
** now weight of item entry is weight entry;**
** now qty of item entry is nbr entry;**
now AC of item entry is AC entry;
say "[paragraph break]";
I pulled out the statements in bold like this:
To assign traits to (item - a thing):
now qty of item is nbr entry of item;
now cost of item is cost entry; [base cost before Chr adj to get price]
now weight of item is weight entry;
I get a generic parser error on the first line of the “To assign traits” function. What am I doing wrong? I think it doesn’t identify the row of the table in which “entry” applies.
Lab is a room.
Table of BodyProtection
Item Nbr Cost Weight AC
padded robe 2 5 1 11
To assign traits to (LocalItem - a thing) consulting (LocalTable - a table name):
choose row with an item of Localitem in Localtable ;
now qty of LocalItem is nbr entry;
now cost of LocalItem is cost entry;
now weight of LocalItem is weight entry;
A padded robe is a thing.
A padded robe has a number called qty.
A padded robe has a number called cost.
A padded robe has a number called weight.
When play begins:
assign traits to a padded robe consulting Table of BodyProtection;
say "qty: [qty of a padded robe] -- cost: [cost of a padded robe] -- weight: [weight of a padded robe] [paragraph break]";
- Sorry, I didn’t want to appear condescending; I find that it helps a lot (and I need it) to be interested in other people’s code problems. It’s just that I’m in a hurry (don’t complain, it saves you 3 off-topic paragraphs).