Mail Archives: djgpp/1997/12/20/06:15:49
Bill McNeely wrote:
>Just getting started in programming... and seeing goto in many of the
>samples of code that I have looked at from other programmers...I have yet
to
>find a better way to control display of information.
>
>For example I have used a goto statement and displayed some information
then
>used the getch() to hold the screen until key hit (I am aware of the
kbhit()
>command) for display screens, such as ego screens. Any recommendations on
a
>better way to accomplish the same thing.
We can't see your code; there are many ways to write an input loop, and the
nature of the functions that collect input affect this.
Always use the best technology for the problem. Many techniques are better
than 'goto'.
You use it because you are thinking "control flow is here, but I want it to
be over there." Learn not to think this. Think "the statements between here
and there are all special, I need to control them as a group."
Use 'goto' (or 'return') to break out of a nested loop, and to avoid the
problem that 'break' exits both 3 different kinds of loops and 'switch'
blocks.
And a netiquette tip - when you quote another post, trim out irrelevant
material. Some folks pay by the minute to read this group!!
-- Phlip
======= http://users.deltanet.com/~tegan/home.html =======
-- "Java, the elegant simplicity of C++ and the
blazing speed of Smalltalk" - Jan Steinman --
- Raw text -