Article View: comp.os.msdos.programmer
Article #2612Re: Autoexec.bat prob: take two
From: Lawrence W Salomon
Date: Wed, 10 Oct 1990 18:01
Date: Wed, 10 Oct 1990 18:01
48 lines
1791 bytes
1791 bytes
Why make is so specific? A better solution, IMHO, is the following:
/* ---------- Cut here ---------- */
#include <stdio.h>
#include <string.h>
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
Technical Details
Message-ID:
<10889@hubcap.clemson.edu>Path:
arc1-ca.pugleaf.net!utzoo!attcan!uunet!samsung!emory!hubcap!sleepy!lsalomoReferences:
<3936.27135c52@cc.curtin.edu.au> <744@demott.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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