Path: utzoo!attcan!uunet!samsung!emory!hubcap!sleepy!lsalomo From: lsalomo@sleepy.uucp (Lawrence W Salomon) Newsgroups: comp.os.msdos.programmer Subject: Re: Autoexec.bat prob: take two Message-ID: <10889@hubcap.clemson.edu> Date: 10 Oct 90 18:01:54 GMT References: <3936.27135c52@cc.curtin.edu.au> <744@demott.COM> Sender: news@hubcap.clemson.edu Reply-To: lsalomo@sleepy.UUCP (Lawrence W Salomon) Organization: Clemson University Engineering Department Lines: 48 Why make is so specific? A better solution, IMHO, is the following: /* ---------- Cut here ---------- */ #include #include main(argc,argv) int argc; char *argv[]; { char input; if (argc>2) { puts("Syntax: ONECHAR [verify]"); putchar('\n'); puts("verify - an optional string of valid input characters."); puts(" If omitted, any character is considered valid."); puts(" The characters are case-insensitive."); putchar('\n'); puts("ONECHAR returns the character pressed as the return code."); exit(2); } else if (argc==2) { strupr(argv[1]); } /* endif */ do { input=getchar(); if ((argc==2) && (strchr(argv[1],input)!=NULL)) { argc==1; } /* endif */ } while (argc!=1); return input; } /* ---------- End of cut -------- */ (Hmm...That looks correct, but of course I typed it in on the fly and so it hasn't been compiled/tested/etc.) As the help text indicates, ONECHAR accepts an optional string which is a list of valid characters. The character pressed is returned as the return code, which can be tested by ERRORLEVEL in a batch file. Have fun...(Please let me know if I made any mistakes)... Cheers, Q