Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!mcsun!ukc!tcdcs!maths.tcd.ie!ecarroll From: ecarroll@maths.tcd.ie (Eddy Carroll) Newsgroups: comp.sys.amiga.programmer Subject: Re: Amiga Application Startup Code question Message-ID: <1991Jun27.163049.2406@maths.tcd.ie> Date: 27 Jun 91 16:30:49 GMT References: <00677915228@elgamy.raidernet.com> Organization: Dept. of Maths, Trinity College, Dublin, Ireland. Lines: 45 In article <00677915228@elgamy.raidernet.com> elg@elgamy.raidernet.com (Eric Lee Green) writes: >From article , by eb15+@andrew.cmu.edu >(Edward D. Berger): >> How do I 'runback' my program if the user starts from CLI with any arguments >> other than "?", but echo the command template to the CLI if that is what >> they obviously want. [ Goes on to say cback.o and c.o don't cut it ] > >Look in the file "umain.c" in your SAS/C sources directory. It's opening >the file "*" for stderr, i.e., opening the current console for output. >So print your stuff to stderr, then, if you want to close the console, >close stderr. I think Edward is trying to get his program to automatically detach from the CLI, yet still handle the case where the user tries to display a command template. The problem with cback.o is that by the time your code gets going, it's already running as a background task and control has been returned to the CLI. So, when you print out the usage message, it can be displayed _after_ the CLI prompt, which looks very tacky. It also prevents you from prompting the user for input. There are two solutions that I know of: - Tell the user to use RunBack if he wants the program to run in the background (or RUN NIL: for Workbench 1.3 upwards). This has the advantage of being clean and easy; you don't need any special code. - Write your own code to spawn the program off as a background task. This allows you to control exactly when the background task starts running, and you can print out templates/messages beforehand. This has the disadvantage that it involves playing with system structures and so may break on future revisions of the OS. It's friendlier to the user though (imho). I tend to use the second way myself (with no problems under 2.0). Grab the source code to SnoopDos or CpuBlit from your nearest comp.sources.amiga archive for an example of how I do it. There are similar examples on the fish disks as well (most noticeably Leo Schwab's on one of the earlier disks). Eddy -- Eddy Carroll ----* Genuine MUD Wizard | "You haven't lived until ADSPnet: cbmuk!cbmuka!quartz!ecarroll | you've died in MUD!" Internet: ecarroll@maths.tcd.ie | -- Richard Bartle