For a project I need tons of phrases like these ones:
if there is a foo corresponding to a foobar of the foobar-variable in the Table of Foo-Fighters:
say the foo corresponding to the foobar of foobar-variable in the Table of Foo-Fighters;
otherwise:
say the foo corresponding to the foobar of deafult-foobar in the Table of Foo-Fighters.
if there is a bar corresponding to a foobar of the foobar-variable in the Table of Baristas:
say the bar corresponding to the foobar of the foobar-variable in the Table of Baristas;
otherwise:
say the bar corresponding to the foobar of deafult-foobar in the Table of Baristas.
where only the first table column and the table name varies
I had hoped to define a simpler equivalent phrase for this:
To look up (TC - table column) in (T- table):
if there is a TC corresponding to a foobar of the foobar-variable in T:
say the TC corresponding to the foobar of foobar-variable in T;
otherwise:
say the TC corresponding to the foobar of deafult-foobar in T.
But I can’t make it work. Is that because it can’t be done or because I do it wrong?
The following, for instance, won’t compile.
To look up (TC - table column) in (T - table name):
if there is a TC corresponding to a foobar of the foobar-variable in T:
say the TC corresponding to the foobar of foobar-variable in T;
otherwise:
say the TC corresponding to the foobar of deafult-foobar in T.
A foobar is a kind of value. The foobars are defined by the Table of Foobars.
Table of Foobars
foobar
default-foobar
xyzzy
frotz
filfre
Foobar-variable is a foobar that varies. Foobar-variable is xyzzy.
Table of Answers
foobar Alpha Beta Gamma
default-foobar "ett" "två" "tre"
frotz -- "fem" "sex"
xyzzy "sju" -- "nio"
filfre "tio" "elva" --