1. Re: Why doesn't this work?
On Wed, 27 May 1998, Bonn Ortloff ("LEVIATHAN") wrote:
> Alan Tu wrote:
> >
> > clear_screen()
> > sequence prompt
> > atom prompt_loop
> > prompt = {97,98,99,100,101,102,103,104,105,106,107,108}
> > for prompt_loop = 1 to 12
> > print(1,prompt[prompt_loop])
> > end for
> > abort
> > [pph: something is wrong here]
> > --Alan
> [pph: Try this instead]
> clear_screen()
> sequence prompt
>
> prompt = {97,98,99,100,101,102,103,104,105,106,107,108}
> for a_loop = 1 to 12 do
> print(1, prompt[a_loop])
> end for
I think this might be what you're after:
include get.e
constant
Basevar = 'a',
Maxvar = 'l',
Vardist = Maxvar - Basevar + 1,
Access = Basevar - 1
sequence vartable, temp
atom number
vartable = repeat(0, Vardist)
clear_screen()
for a_loop = 'a' to 'l' do -- 'a' = 97, 'l' = 108
puts(1, "Enter value for " & a_loop & ": ")
temp = get(0)
if temp[1] = GET_SUCCESS and atom(temp[2]) then
number = temp[2]
else
number = 0
end if
vartable[a_loop - Access] = number
-- To access a, b, c etc. use:
-- vartable['a'-Access] rather than just "a".
end for
I actually think Leviathan was trying to put values into variables a to l
in a loop, incrementing the variable's *name* each time.
This can't be done (in any language. Although I seem to remember being
able to hack something in Commodore Basic ;) ). You can increment the
value *in* a variable, but you can't increment the *name*.
I've tried to get as close as this as possible though, by implementing a
clumsy variable table for a to l.
If you abbreviate vartable to vt, and use 1, 2, 3, etc.:
vartable['a'-Access] ===> vt[1]
vartable['d'-Access] ===> vt[4]
etc, you can save a lot of typing.
Mail me if I've confused you, and I'll try and help out...
Carl
--
Carl R White
E-mail...: cyrek- at -bigfoot.com / Remove the hyphens before
Finger...: crwhite- at -dcsun1.comp.brad.ac.uk \ mailing or fingering...
Url......: http://www.bigfoot.com/~cyrek/