acm@grendal.Sun.COM (Andrew MacRae) (05/02/90)
In article <1990Apr27.203354.993@watdragon.waterloo.edu> gcreesor@lotus.uwaterloo.ca (Glen Reesor) writes: >I would like to have a program compiled using TP5.5 read parameters on >the command line entered after the program name. For example, in >running the program demo you may specify options: > > a:>demo /b > >i.e. I want my program to beable to read the '/b'. The technique is rather clearly documented (with examples) in the manual that comes with the software. Have you lost your copy or are just unable to find it in the index? After all there is no way you could have gotten a copy of the compiler without getting a copy of the manual is there? Andrew C. MacRae Standard Disclaimer: My submissions to net news are in no way associated with my employer.
880716a@aucs.uucp (Dave Astels) (05/02/90)
In article <1990Apr27.203354.993@watdragon.waterloo.edu> gcreesor@lotus.uwaterloo.ca (Glen Reesor) writes: >I would like to have a program compiled using TP5.5 read parameters on >the command line entered after the program name. Check out functions/procs ParamCount and ParamStr. (something close to that, I am going from memory) These correspond roughly to argc & argv in C. -- - Dave Internet: 880716a@AcadiaU.CA Bitnet: 880716a@Acadia
wsinpp@lso.win.tue.nl (Peter Peters) (05/03/90)
In article <1990Apr27.203354.993@watdragon.waterloo.edu> gcreesor@lotus.uwaterloo.ca (Glen Reesor) writes: >I would like to have a program compiled using TP5.5 read parameters on >the command line entered after the program name. > I've written a unit in TP which does a kind of GETOPT thing like there is available in C. If enough people are interested (and someone tell me the correct procedure) I'll upload it somewhere where it's ftp-able, or I'll mail it to someone who can upload it for me (volunteers ?). If you're only interested in getting a single parameter, it's a lot of overhead, otherwise I think it's nice... A code extract which uses this module follows.... ---------------------------------- Procedure ProcessParameters; Var Par : Char; Code : Integer; Begin (* There's a possibility to use a environment variable to preset parameters, I usually use the program name as environment variable *) SetEnvOpt ( ProgramName ); (* Here's how command line switches are processed... *) Repeat Par := GetOpt( 'lLhHs:S:' ); (* like in C-getopt *) Case Par Of 'l','L' : Begin (* some actions *) End; 's','S' : Begin (* The ":" in the getopt line above means a parameter is required *) (* some actions *) (* usage of current option argument *) If OptArg <> '' Then Begin Val(OptArg,BlankDelay,Code); If Code <> 0 Then ErrorExit ('Invalid blanking value : "'+OptArg+'"',1); End; End; 'h','H' : Begin Usage; Start := False; End; '?' : (* ? means an invalid switch is on the commandline *) ErrorExit ('Invalid switch : "'+Par+'"',1); End; Until Par = EofChar; If Argv[OptInd] = '?' Then Begin Usage; Start := False; End Else InName := Argv[OptInd]; End; ------------------------------------------------- See if it's of any use and let me know if I should upload it somewhere (or mail it to someone who will upload it). -- | Peter Peters | UUCP : wsinpp@lso.win.tue.nl | | Eindhoven University of Technology (TUE) | SURF : heithe5::wsdcpp | | Dept. of Mathematics and Computer Science | VHF : PA0PPE | | Disclaimer : I said WHAT ??? | TUE : HG 8.86 tst. 4283 | -- | Peter Peters | UUCP : wsinpp@lso.win.tue.nl | | Eindhoven University of Technology (TUE) | SURF : heithe5::wsdcpp | | Dept. of Mathematics and Computer Science | VHF : PA0PPE | | Disclaimer : I said WHAT ??? | TUE : HG 8.86 tst. 4283 |
reeves@dvinci.usask.ca (Malcolm Reeves) (05/03/90)
From article <1990Apr27.203354.993@watdragon.waterloo.edu>, by gcreesor@lotus.uwaterloo.ca (Glen Reesor): > I would like to have a program compiled using TP5.5 read parameters on > the command line entered after the program name. The functions you require are described in Chapter 16 p.345 of the TP5.0 "Reference Guide". It has a red and yellow spine to make it easy to see on your bookshelf and bears the inscription Turbo Pascal (c).
silvert@cs.dal.ca (Bill Silvert) (05/04/90)
In article <1162@tuewsd.win.tue.nl> wsinpp@lso.win.tue.nl (Peter Peters) writes: >I've written a unit in TP which does a kind of GETOPT thing like there >is available in C. If enough people are interested (and someone tell me >the correct procedure) I'll upload it somewhere where it's ftp-able, or >I'll mail it to someone who can upload it for me (volunteers ?). This is the sort of thing that should definitely be posted. If it ends up in an FTP strongbox somewhere, will someone please extract and post for the rest of us? -- William Silvert, Habitat Ecology Division, Bedford Inst. of Oceanography P. O. Box 1006, Dartmouth, Nova Scotia, CANADA B2Y 4A2. Tel. (902)426-1577 UUCP=..!{uunet|watmath}!dalcs!biomel!bill BITNET=bill%biomel%dalcs@dalac InterNet=bill%biomel@cs.dal.ca