cvs.gedasymbols.org/archives/browse.cgi | search |
From: | "Tom" <thomasbd AT erols DOT com> |
Newsgroups: | comp.os.msdos.djgpp,comp.os.msdos.programmer |
Subject: | Iteration vs. Recursion... |
Date: | Thu, 22 Jul 1999 14:24:32 -0400 |
Message-ID: | <7n7s1h$ms6$1@autumn.news.rcn.net> |
X-Trace: | +gCbv3cgbnog2oWR+HACfu90m0WPh/EL82+jnFX3xWA= |
X-Complaints-To: | abuse AT rcn DOT com |
NNTP-Posting-Date: | 22 Jul 1999 19:39:29 GMT |
X-MimeOLE: | Produced By Microsoft MimeOLE V5.00.2314.1300 |
X-Newsreader: | Microsoft Outlook Express 5.00.2314.1300 |
X-MSMail-Priority: | Normal |
X-Priority: | 3 |
Lines: | 49 |
To: | djgpp AT delorie DOT com |
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
Reply-To: | djgpp AT delorie DOT com |
I have a keyboard input program that runs one thing if one key is entered and another if another key is entered. There are about ten different options. That means I have ten different if statements. I am using recursion because after I get one input I do the program over again. The only problem with this program is that I have to hold down the key for about a second before anything is recognized. Is there any way to speed this up? Possibly by using iteration instead of recursion. Here is the code. Any suggestions are greatly appreciated. I left out the program names and variables not needed. I use getch to catch the keystrokes. I tried using the bioskey but that didn't speed anything up. I am using DJGPP to compile this: /*********start code******** { if (getch() == x) {run_program(); run_program(); exit(0);} if (getch() == y) run_program(); if (getch() == z) run_program(); if (getch() == a) run_program(); if (getch() == b) run_program(); if (getch() == c) run_program(); if (getch() == d) run_program(); if (getch() == e) {run_program(); if ((getch() == f || (getch() == g)) run_program(); if (getch() == h) run_program(); if (getch() == i) run_program(); } ****end code**********/ Thanks. Tom
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |