Path: utzoo!mnetor!uunet!husc6!necntc!ima!cfisun!lakart!dg From: dg@lakart.UUCP (David Goodenough) Newsgroups: comp.lang.c Subject: Re: gotos Message-ID: <64@lakart.UUCP> Date: 25 Apr 88 16:52:56 GMT Organization: Lake - The systems people Lines: 78 In article <2200@louie.udel.EDU> new@udel.EDU (Darren New) writes: >How about: (pseudocode) > for (i = 0; i < max_in_table && key != name[i]; ++i) > if (keypressed()) goto handle_key; > seek(helpfile, offset[i]); > if (keypressed()) goto handle_key; > linecount = 0; > do { > read_line_from_file(); > ++linecount; > if (keypressed()) goto handle_key; > if (read_line[0] == special_flag_char) goto handle_key; > insert_spaces_and_color_codes(); > if (keypressed()) goto handle_key; > display_text_line(); > if (keypressed()) goto handle_key; > } while (linecount < 24); > handle_key: > c = wait_for_key_then_read_it(); > switch (c) { > case 'A': ... > ... > } This is about the same: for (i = j = 0; i < max_in_table && key != name[i] && !j; ++i) if (j = keypressed()) break; if (!j) { seek(helpfile, offset[i]); linecount = 0; while (!keypressed() && linecount < 24) { read_line_from_file(); ++linecount; if (keypressed() || read_line[0] == special_flag_char) break; insert_spaces_and_color_codes(); if (keypressed()) break; display_text_line(); } } c = wait_for_key_then_read_it(); switch (c) { case 'A': ... ... } I grant that j could be renamed to (say) key_press_seen, but choice of long / short variable names belongs in a whole different discussion. However, I ask, where did all those goto's go to?? :-) The ONLY time I use a goto is because C doesn't have a 'break 2' construct: for (;;) { while (...) { code ..... if (condition) break 2; more code ..... } } /* break 2 exits to here */ Maybe someone should suggest it to the ANSI crowd - it can't be that hard to do. -- dg@lakart.UUCP - David Goodenough +---+ | +-+-+ ....... !harvard!adelie!cfisun!lakart!dg +-+-+ | +---+