Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!lanl!dspo!quark!crunch!josh From: josh@crunch.uucp (Josh Siegel) Newsgroups: net.lang.c Subject: a basic like gosub in C Message-ID: <202@crunch.uucp> Date: Sun, 23-Feb-86 15:06:37 EST Article-I.D.: crunch.202 Posted: Sun Feb 23 15:06:37 1986 Date-Received: Wed, 26-Feb-86 07:23:09 EST Organization: University Of New Mexico Lines: 55 In basic there is a GOSUB routine that will push the current position onto the stack and jump to another line. Then, upon hitting a return will return to that place. I wish to write something like that in C that will be movable between compilers. A sample of something like it is below: 5 rem Basic 10 print "hi" 20 gosub 50 30 print "bye" 35 gosub 50 40 end 50 print "hello" 55 print "who are you?" 60 return /* C code that does work */ main () { (void)gosub (0); } gosub (line) int line; { switch (line) { default: puts ("hi"); (void)gosub (50); puts ("bye"); (void)gosub (55); exit (0); case 50: puts ("hello"); case 55: puts ("who are you"); return (0); } } Can anybody think of a better way to do this? I want it for a Basic->C translator (Please, I am writting it for fun... No abuse...Please?). thanks much, Send me mail . . . I L O V E mail Josh Siegel {convex,ucbvax,gatech,csu-cs,anl-mcs,lanl-a}!unmvax \ !crunch!josh / {cmcl2,csu-cs,dirac,dspo,gel,ias,ihnp4,mtu,nmsu}!lanl!quark