RE: DOS: A newbie question about get()
- Posted by Brian Broker <bkb at cnw.com> Dec 31, 2003
- 422 views
I think the documentation explains very well the advantages of using get(): "get() can read arbitrarily complicated Euphoria objects. You could have a long sequence of values in braces and separated by commas, e.g. {23, {49, 57}, 0.5, -1, 99, 'A', "john"}. A single call to get() will read in this entire sequence and return it's value as a result." "The combination of print() and get() can be used to save a Euphoria object to disk and later read it back." So I wouldn't use it to read from the keyboard but rather from a file that was written using print(). I like games so I find this to be the easiest way to write and store a high score table or saved game stats for instance. You don't have to worry about the details of reading in your data. You get() back exactly what you print(). -- Brian Alex Caracatsanis wrote: > > > Hi Brian, and others: > > -----Original Message----- > From: Brian Broker [mailto:bkb at cnw.com] > > What do you want to accomplish? > > Fair point, Brian! > > I realize now that I was trying to understand what get() does, how it > works, and where it stands in comparison with the other routines > available for reading input. So I set myself an artificial problem: if > my program had to read input that may be either a number or a string, > but that must not be a no_input or invalid_input, how would I implement > it using get(); and would get() be the best way of implementing it in > any case? (Maybe the problem would've been more convincing if I'd set > out to read data from a file.) > > I realized that prompt_string() and prompt_number() will read their > respective data types, and that gets() won't read numbers; and I > understood that getc() will read the next character (altho' come to > think of it, I don't really understand in what context this might be a > useful thing to do). It seemed that get() was the ideal tool to read > either data type, and do a bit of error-checking at the same time. I > tried to write some code to put it thro' its paces, so to speak. > > Maybe I should've asked: when's it best to use get()? > ...or: in what programming tasks would get() be ideal? > ...or even: if get() didn't exist, would it be missed? > > Thank you for your advice > > Alex Caracatsanis > >