Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!sm.unisys.com!csun!csuna!abcscnuk From: abcscnuk@csuna.UUCP (Naoto Kimura) Newsgroups: comp.lang.pascal Subject: Re: Parsing the command line ... Message-ID: <1656@csuna.UUCP> Date: 7 Feb 89 16:54:41 GMT References: <547@loligo.cc.fsu.edu> Reply-To: abcscnuk@csuna.UUCP (Naoto Kimura) Distribution: na Organization: California State University, Northridge Lines: 46 In article <547@loligo.cc.fsu.edu> perrone@loligo.UUCP (Perrone Ford) writes: > > Hello netters, > > I have a question, but first I would like to thank all the > knowledgeable fokls out there who have helped me in the past. > > Does any one out there know a "simple" way to parse the >comand line in ANSI pascal/TurboP4.0 ? If so, lay the info >down on me. I would prefer knowing if there is a way to do so in >ANSI because I want to port this to as mainframe. > >Also, by simple, I mean without going into assemble code and reading >memory segments. Well, I don't know what ANSI says about such beasties, but I know that some implementations allow you access to the arguments passed through the command line. Most of them will pass you the already parsed arguments to you. - Under Berkeley pascal on UNIX systems, there is usually a argv(n) function (interesting name eh?) that will return the n'th argument string of the command line. - With Turbo the function is ParamStr(n). If you want to get at the unparsed string, you'll have to start reading somewhere in the environment segment or the prefix segment (don't recall where, but it's somewhere in there) - There is an include file and a library on the Cyber here at CSUN that will allow you to access the parsed portions of the command line. Unfortunately, you could only access the option flags if I recall correctly, as the other strings were used to associate the internal variables with the external filenames - I don't recall how it was done under PASCAL/VS on IBM mainframes, but there was a way to do it. On the VM/CMS system that I used, there were two forms of the command line, one that was parsed according to older rules, which resulted in space-separated 8-character arguments, and another which returned the entire command line string. You had to do a bit of twiddling with machine registers to get at the latter. Hope this helps. //-n-\\ Naoto Kimura _____---=======---_____ (csun!csuna!abcscnuk) ====____\ /.. ..\ /____==== // ---\__O__/--- \\ Enterprise... Surrender or we'll \_\ /_/ send back your *&^$% tribbles !!