Re: wildcard usage

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sat, 10 Apr 1999, Scott Murray wrote:

] >got a bit of a thing that has been driving me slowly insane since I first
] >started using EU.  I have tried every permutation of code to create a
] '>wildcard' method to substitute for many lines of branching to strings of
] >data; question: is it possible to turn this...?
]
] >       --string 1
] >      a1={"cat","dog","mouse"}
] >       --string 2
] >       a2={"chicken","duck","cow"}
]
] >       input=x  string_to_fetch="a" & x
] >       --where string_to_fetch is executable in the same way
] >       --that either string_to_fetch=a1 or string_to_fetch=a2 is
]
] If I guess correctly, you're wanting the user to be able to specify a
] variable by name.  The only ways I know of to do that is to store the
] name as part of the variable, or to use a parallel sequence:
]
]        strings  = { { "a1", "cat",    "dog", "mouse"}, --string 1
]                     { "a2", "chicken","duck","cow"  }  --string 2
]                   }

Or the simplest solution of all:

sequence a
integer x
a = repeat({},2)

a[1] = {"cat",     "dog",  "mouse"}
a[2] = {"chicken", "duck", "cow"  }

x = 0

while x < 1 or x > 2 do
    x = input(x, "Which set of animals? 1 = House, 2 = Farm: ")
    -- one of my many input() ideas ;)
end while

animals = a[x]

--
Carl R White -- cyrek- at -bigfoot.com -- http://www.bigfoot.com/~cyrek
 aka Cyrek   --    No hyphens :)    --       Bigfoot URL Alias

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu