Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!apple!mitch From: mitch@Apple.COM (Mitchell Adler) Newsgroups: comp.sys.mac.programmer Subject: Re: MPW cmd language Keywords: MPW Message-ID: <32774@apple.Apple.COM> Date: 29 Jun 89 00:14:00 GMT References: <495@unicads.UUCP> <919@iraun1.ira.uka.de> Organization: Apple Computer Inc, Cupertino, CA Lines: 52 In article <919@iraun1.ira.uka.de> norbert@ira.uka.de (Norbert Lindenberg) writes: >In article <495@unicads.UUCP> tom@unicads.UUCP (Tom Gerardy) writes: >>I am trying to put up ctags and a vi/tags like facility in MPW (actually >>it is already working.) The output of the tag tool is a string of MPW >>commands to open the file and find the search string. >>... >>Currently I am having to write the output to a file and execute it as >>a script. This seems to slow things down considerably since both "open" >>and "find" are builtins. >I developed a similar package for MPW Pascal some time ago >(LookupDeclaration, available from the info-mac archives), >and also could not find a better way. Probably there is none... There is a different way, but depending on the complexity of the script producing the script to execute, it is a little messy... The trick is to use back-quotes (`) to put your standard output on the command line. If it happens that your output is executable, it will be executed, i.e. `getListItem 'files -l' files; files -t TEXT` will let you choose the command to execute on all the text files in the current directory. Since back-quotes just put text on the command lines, that text can be anything you want it to be, even a command (or series of commands) to execute. One thing to rember is that the syntax for back-quotes allows *any* script to be executed (even looping structures, begin/ends and the like), BUT the whole script must be on one "line", that is there must be no carriage returns between the start and end back-quotes that aren't masked with option-d's. Not having cirrage returns means adding semi-colons between all your commands, more dirt, it can get really messy, but sometimes it is truly elegant. And the final problem is that you are already inside a set of back-quotes so if any of your commands need to use back-quotes in their command lines, you need to escape them (with option-d). In my experience it is valuable to use this trick whenever it will help you avoid creating a temporary file without adding more than 20 option-d's :-). For those real purists out there, this trick won't avoid creating a file, MPW uses temporary files to do back-quoting, but it does put the problem of naming and deleting the temprary file back in MPW's hands (where it should be). Mitch Adler "Hamper? ... I have a Hamper?" Apple Computer - Dr. Peter Venkman mitch@apple.com "Prepare for jump to...ludicrous speed!" AppleLink: M.ADLER - Dark Helmet