Operating System - OpenVMS
1827834 Members
2418 Online
109969 Solutions
New Discussion

how to define a symbol from a search result ?

 
SOLVED
Go to solution
Davor_7
Regular Advisor

how to define a symbol from a search result ?

i.e.
i have a command: $sear 1.txt "111"
and there is a output like "111 test"
i wanna assign this output into a symbol. which command i can use?
i tried:
$pipe sear 1.txt "111" | a = sys$output
but didnot work...
13 REPLIES 13
Hein van den Heuvel
Honored Contributor
Solution

Re: how to define a symbol from a search result ?


This question has been asked and answered a number of times, for example:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=779260

Google for: +vms +search +pipe +site:itrc.hp.com

I prefer using perl:
For example:


$ create tmp.tmp
aap
noot
111 test
mies
$
$ perl -ne "$ENV{a} = $_ if /111/" tmp.tmp
$
$ show log a
"A" = "111 test." (LNM$PROCESS_TABLE)


hth.
Hein.
Hein van den Heuvel
Honored Contributor

Re: how to define a symbol from a search result ?


This question has been asked and answered a number of times, for example:
http://forums1.itrc.hp.com/service/forums/questionanswer.do?threadId=779260

Google for: +vms +search +pipe +site:itrc.hp.com

I prefer using perl:
For example:


$ create tmp.tmp
aap
noot
111 test
mies
$
$ perl -ne "$ENV{a} = $_ if /111/" tmp.tmp
$
$ show log a
"A" = "111 test." (LNM$PROCESS_TABLE)


There are also other tools you may want to check like (VAXman's ) SYMBOL and maybe 'extract'

hth.
Hein.
Davor_7
Regular Advisor

Re: how to define a symbol from a search result ?

sorry, i'm not asking for a logical
i'm asking for a symbol...
Hein van den Heuvel
Honored Contributor

Re: how to define a symbol from a search result ?


Hmm, once it is in a logical, how hard is it to get it into a symbol?
$a = f$trnlnm...

Also, I mentioned "SYMBOL" and google.

Just google +symbol +vms +vaxman "I feel lucky"

Or google for: +vms +symbol +perl

Hein.


"http://kobesearch.cpan.org/htdocs/perl/VMS/DCLsym.html

http://kobesearch.cpan.org/htdocs/perl/VMS/DCLsym.html
Davor_7
Regular Advisor

Re: how to define a symbol from a search result ?

that's right.
but your method still cannot make it in ONE sentence :)
John Gillings
Honored Contributor

Re: how to define a symbol from a search result ?

>that's right. but your method still cannot make it in ONE sentence :)

Technically true, but anywhere you would use the symbol, you could use:

'F$TRNLNM("name")'

so there's very little difference, apart from a few extra characters.

The issue is that pipe segments are independent processes, so they don't share a symbol table with the parent process. The JOB logical name table is shared, so it can be used to return values from subprocesses to parent processes.
A crucible of informative mistakes
Davor_7
Regular Advisor

Re: how to define a symbol from a search result ?

thanks all
i think the f$trnlnm is a good way to use :)
Hein van den Heuvel
Honored Contributor

Re: how to define a symbol from a search result ?


As John writes, any PIPE solution to this problem involves an extra process which may become a problem with high repeat counts.

The PERL solution I suggested is only a single image activation, much like SEARCH itself. Furthermore, once you get the hang of perl a little it will be trivial to parse the target line for exactly the desired data, or perhaps do what the next dcl steps would have done with the selected data.

This request is common enough that it would be nice if SEARCH had a switch to toss its output into a symbol (and why stop at search? Well maybe because most other tools output is many records).

Hein.

Hein van den Heuvel
Honored Contributor

Re: how to define a symbol from a search result ?


I happened to sit in a meeting with Guy yesterday and he indicated he would consider an option for search output to go into a symbol.

In OpenVMS 8.3 SEARCH/STAT will already define local symbols like: SEARCH$RECORDS_MATCHED

fyi,

Hein.


Davor_7
Regular Advisor

Re: how to define a symbol from a search result ?

Thanks Hein,

that will be a great help for me :)
Ian Miller.
Honored Contributor

Re: how to define a symbol from a search result ?

You could submit a issue at
http://www.hpuseradvocacy.org

and if it receives enough votes then it will be put forward to hp for consideration.

User requests help towards getting engineering time to add features to VMS.
____________________
Purely Personal Opinion
Davor_7
Regular Advisor

Re: how to define a symbol from a search result ?

thanks Miler,

btw, i try to submit a issue and reply other issue, but cannot see my reply message quickly.
does that mean my reply is waiting for approval before it is pasted onto the website?
Ian Miller.
Honored Contributor

Re: how to define a symbol from a search result ?

i think there is an approval process.
Check again tomorrow.
____________________
Purely Personal Opinion