help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Kind of a lookfor function


From: avraham
Subject: Kind of a lookfor function
Date: Mon, 30 May 2005 16:01:33 +0300
User-agent: Mutt/1.5.5.1+cvs20040105i

Hi,
I wrote yesterday to  Mike Miller (in a very unclear manner, I am
affraid) why his solution would not work for octave-forge
functions.
I think I now that have a roundabout way to get the functionality 
of the lookfor function in octave.

I shell describe first its implementation on my system (linux,
using bash as shell), because I was able to check it. I shall
mention afterwards how it might be used on other systems.

First I wrote the following script (olookfor):
#! /usr/bin/octave -qf
page_output_immediately = 1;       
page_screen_output =0;
help
Made it executable and stored in my path.
I was then able to write at the octave prompt:
775~> system("olookfor | grep -v / | grep -i forge")
OCTAVE_FORGE_VERSION.m  inputname.m             read_options.m          
temp_name.m
ans = 0

Sonds crazy: you get out of octave to the shell to call octave
non-interactively...
The pleasant surprize was that on my 5 year old celeron, the
answer came promply. Probably, because the interpreter was already
in active memory.
That emboldened me to create a new script (Olookfor):

#!/bin/sh -f
olookfor | grep -v / | grep -i $1 | tr -s ' ' '\n' | grep -i $1
Made it executable and stored in my path.
Then I wrote at the octave prompt:
778~> system("Olookfor forge")
OCTAVE_FORGE_VERSION.m
ans = 0

The ultimate in confort would be to make it an octave command,
using the mark_as_command option, but I don't know how to do it.
In fact, I don't know if this is possible at all. I would be glad
if someone would explain how it could be done, or why it can't.

Linux and Unix users who prefer some other shell as default,
should check if these requires any change. I guess that is all
that is required of Mac users as well, since this is based on BSD
Unix.

I know next to nothing about MSwindows, but from the old days of
DOS, I remember some things:
1-The DOS counterpart of the shell scripts are batch files. They
have to end in .bat, to be recognized by the system and executed.
2-The grep command was available for DOS (I found it in the
floppies of Borland Turbo Pascal - I had no web access, then)
3-I don't know about tr.
4-The command line arguments are invoked in the batch file by %
(or maybe %%) instead of the $ sign in the Unix scripts.
5-When using a batch file inside another batchfile one should use
the call keyword, eg. the second file should be "call olookfor |
grep ...."
6-DOS is not case sensitive: different names should be chosen for
the two batch files
7-The /, in the second file should probably be replaced by a \ .

That is all. Hope it is helpful.
Cheers, Avraham



-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.

Octave's home on the web:  http://www.octave.org
How to fund new projects:  http://www.octave.org/funding.html
Subscription information:  http://www.octave.org/archive.html
-------------------------------------------------------------



reply via email to

[Prev in Thread] Current Thread [Next in Thread]