Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site hadron.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!lll-crg!seismo!rlgvax!hadron!jsdy From: jsdy@hadron.UUCP (Joseph S. D. Yao) Newsgroups: net.unix Subject: Re: Shells, features and interaction Message-ID: <102@hadron.UUCP> Date: Thu, 28-Nov-85 01:15:18 EST Article-I.D.: hadron.102 Posted: Thu Nov 28 01:15:18 1985 Date-Received: Fri, 29-Nov-85 10:42:59 EST References: <4575@alice.UUCP> <3387@brl-tgr.ARPA> Reply-To: jsdy@hadron.UUCP (Joseph S. D. Yao) Organization: Hadron, Inc., Fairfax, VA Lines: 98 Summary: here's loop.c. In article <3387@brl-tgr.ARPA> gwyn@brl-tgr.ARPA (Doug Gwyn ) writes: >I hope to post a public domain implementation of "seq" (which >Rob called "loop" in his example) soon. Stay tuned. You mean this? /* #include */ /*********************************************************************\ ** ** loop -- do a quick FORTRAN-style (ech) numeric loop ** ** Syntax: ** loop [ start [ end [ incr ] ] ] ** ** Copyright and Disclaimers: ** Who cares? It's past midnight. Have a ball. ** ** Description: ** This is a program that really counts. ** #ifdef SCCS ** Last modified %G% %U%. Last retrieved %H% %T%. ** # else ** $Log:$ #endif SCCS ** Author: ** Joseph S. D. Yao ** Engineering and Information Systems Division ** Hadron, Inc. ** 9990 Lee Highway ** Fairfax VA 22030 ** (703) 359-6163 ** ** Routines: ** main(argc, argv, envp) ** \*********************************************************************/ #ifndef lint # ifdef SCCS static char SCCS_id[] = "%W%"; # else static char RCS_id[] = "@(#)$Header:$"; # endif SCCS #endif lint main(argc, argv, envp) int argc; char **argv; char **envp; { register int var, end, incr; #ifdef lint argv = envp; #endif lint var = end = incr = 1; /* Arg 1: start value for var. */ if (--argc > 0) var = atoi(*++argv); /* Arg 2: end value for var. */ if (--argc > 0) end = atoi(*++argv); /* Arg 3: increment for var. */ if (--argc > 0) incr = atoi(*++argv); /* A zero increment could take a while. */ if (incr == 0) incr = 1; /* ** Different tests are used if incr < 0 or > 0. ** This coding is for speed, not program size. */ if (incr < 0) { while (var >= end) { printf("%d\n", var); var += incr; } } else { while (var <= end) { printf("%d\n", var); var += incr; } } return(0); } -- Joe Yao hadron!jsdy@seismo.{CSS.GOV,ARPA,UUCP}