Re: Procedures and Parameters
- Posted by Irv Mullins <irv at ELLIJAY.COM> Jul 26, 1999
- 326 views
On Mon, 26 Jul 1999, you wrote: > All, > > The problem here is this, if define the Look procedure in the > following manner to handle input such as look > > global procedure Look() > .......... > puts(You look....... > end procedure > > and the user enters look vase then the program aborts > with the following message: > > Syntax error - expected to see possibly ')', not a variable > > If I define the Look procedure in the following manner > to handle input such as look vase > > global procedure Look( sequence Obj) > ........... > puts(You look........ > end procedure > > and the user enters look then presses return the > program aborts with the following message: > > Look() needs 1 arguments, not 0 > Is there a better more efficient way to handle this? > I think you may as well go ahead and write a command parser, you will be calling it from all over your program. That way, one function can handle valid and invalid inputs appropriately. You'll need a small dictionary of nouns and verbs, and set up some simple syntax rules: i.e. "vase look" could return a "sorry, don't know how to vase", while "look vase" returns "You are looking at", & "a blue vase".... You may also want to set up tables of attributes - so "take house" returns a smart alek remark, rather than "you are carrying a vase and a house".... Irv