Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

EDIT & TEDIT functionalities

783 views
Skip to first unread message

Shiva

unread,
May 7, 2014, 12:23:04 AM5/7/14
to
Hello everyone! Been some time since I visited here and so much has happened. From the last time here I've developed so many small tools that will help newbies like me. Learnt more about tacl programming as well. Learning more everyday. All thanks to you people.

To my question now. Again a mainframe similarity that I'm trying to find in tandem. When I search for some string in a file using the mainframe TSO command, I used to get the 'number' of times the string was found, as well. Though this detail might seem unnecessary, I still got it. TEDIT's search doesn't seem to tell me that. Neither does EDIT's command - though it displays the list of lines where it is found. Is writing a macro/routine the only way around this? Or is there a way in both EDIT & TEDIT - which seems highly unlikely at this point.


And one more functionality of mainframe which I used to adore is the TSO command - NX ALL F ALL 'search_string'

For the non-mainframers, this command would delete or rather exclude all those lines except those which have the string which is searched. For example, if you search for 'Robin' in a file. All the lines except those which have the word robin will be deleted. I tried this with so many combinations of commands in TDIT but was unsuccessful, without using copy/retrieve - mainly because I don't want to create or use another file - when I can do that using just one file in mainframe, I'd like to do the same in NS. But finding it hard. Again, only a macro is the only way?

Being a mainframer whose thoughts are always aligned along those lines, since the day I started learning NS - I've always learnt with comparison - and hence such vague questions. May be I'm looking at this problem in a mainframer's way, when it can be done a bit differently in NS, Let me know if anyone of you can find answers to these?

Keith Dick

unread,
May 7, 2014, 2:32:16 AM5/7/14
to
Shiva wrote:
> Hello everyone! Been some time since I visited here and so much has happened. From the last time here I've developed so many small tools that will help newbies like me. Learnt more about tacl programming as well. Learning more everyday. All thanks to you people.
>
> To my question now. Again a mainframe similarity that I'm trying to find in tandem. When I search for some string in a file using the mainframe TSO command, I used to get the 'number' of times the string was found, as well. Though this detail might seem unnecessary, I still got it. TEDIT's search doesn't seem to tell me that. Neither does EDIT's command - though it displays the list of lines where it is found. Is writing a macro/routine the only way around this? Or is there a way in both EDIT & TEDIT - which seems highly unlikely at this point.
>
I can only tell you the shortest way I know to get the result in EDIT. TEDIT might have a way to do it, but I do not know TEDIT very well.

In EDIT, I believe this sequence of commands will get the count:

EDIT file; PUT temp /some string/; GET temp; NUMBER ALL; LIST LAST; EXIT

this will put all lines that match "some string" into the file "temp", open temp, renumber the lines in the file to start with 1 and increment by 1, then display the last line in the file. The line number of that last file will be the number of times "some string" appears in the original file.

If you are willing to use unsupported programs, such as LOCATE, I believe it has an option to count matches, so you could get the count in a single LOCATE command, if LOCATE is installed on your system.

In OSS, you would do something like this:

grep "some string" file | wc -l

This would print lines from "file" that match "some string", and that output would not be displayed, but would be sent to the wc program. The -l flag makes wc count the lines in its input and display the count when it reaches the end of input. "file" could be /G/vol/subvol/file to make it work on Guardian files

Neither of those are single editor commands, so if you need to get the count while you are in the midst of editing a file, you would have to exit the editor in order to run
>
> And one more functionality of mainframe which I used to adore is the TSO command - NX ALL F ALL 'search_string'
>
> For the non-mainframers, this command would delete or rather exclude all those lines except those which have the string which is searched. For example, if you search for 'Robin' in a file. All the lines except those which have the word robin will be deleted. I tried this with so many combinations of commands in TDIT but was unsuccessful, without using copy/retrieve - mainly because I don't want to create or use another file - when I can do that using just one file in mainframe, I'd like to do the same in NS. But finding it hard. Again, only a macro is the only way?
>
If I understand what the command you describe does, EDIT certainly can do it:

EDIT file; DELETE QUIET NOT /Robin/; EXIT;

I imagine TEDIT has a way to delete lines that do not match a string, but I don't know TEDIT well enough to know it. Perhaps someone who knows TEDIT better than I do will answer that part of the question.

wbreidbach

unread,
May 7, 2014, 2:38:48 AM5/7/14
to
Hi Shiva,

no, this functionality is not supported by the NonStop editors.
Depending on your needs it might be useful to get the BROWSER tool, a new version is available within the Yahoo Tandem group. Have a look at the description and in case you are not allowed to bering it to the NonStop, ask your system manager to do that. As far as I know (unfortunately feedbach is very rare) this tool is used on a bunch of NonStop systems.

Shiva

unread,
May 7, 2014, 4:48:40 AM5/7/14
to
@Keith: The Delete quiet not command is cool. I didn't know that 'not' can be combined with delete. May be it can be combined with other commands as well.

And using a temp file to find the number of times a string is present is disappointing, and more so when the end result is not exactly the one I was expecting. There's no other way I guess. So I'd like to know whether this output from EDIT which is displayed (the last line, with line number) can be captured in a file and the line number alone can be taken from that and displayed - using some macro that I'm hoping to write? I'm not sure whether there's anyway to take EDIT's command line response as an input?

And @wolfgang - the system admin doesn't take inputs from the developer as easily. As much as I'd like to, I don't think there's a chance that I'd get to use your tool unless or until you share the code, in which way I can compile it and use the object code. And I also remember that you were not in a position to share the code - so it is fine. May be when I get to a more lenient workplace, I'd make sure to try your tool. Thanks though :)

Keith Dick

unread,
May 7, 2014, 7:21:02 AM5/7/14
to
Shiva wrote:
> @Keith: The Delete quiet not command is cool. I didn't know that 'not' can be combined with delete. May be it can be combined with other commands as well.

The NOT is not part of the command, but part of the expression of what lines are to be addressed, so it works with any command that accepts a line range.
>
> And using a temp file to find the number of times a string is present is disappointing, and more so when the end result is not exactly the one I was expecting. There's no other way I guess. So I'd like to know whether this output from EDIT which is displayed (the last line, with line number) can be captured in a file and the line number alone can be taken from that and displayed - using some macro that I'm hoping to write? I'm not sure whether there's anyway to take EDIT's command line response as an input?

You can capture the output of EDIT into a TACL variable using OUTV, so you should easily be able to write a TACL routine or macro that picks just the line number from the last line of EDIT's output. You couldn't invoke it from within EDIT, though.

wbreidbach

unread,
May 7, 2014, 7:33:51 AM5/7/14
to
Shiva,
of course your system manager is careful in taking requests from the development, I am a system manager myself. But I can assure you that this tool would prove useful for the system manager himself (or herself). So you probably should give the hint that there might be something useful instead of requesting the installation. Within our installation this tool is used by nearly everyone with access to the NonStop.

Doug Miller

unread,
May 7, 2014, 7:37:15 AM5/7/14
to
Keith Dick <kd...@acm.org> wrote in
news:mYednQ_qA5XrTvTO...@giganews.com:

> Shiva wrote:
[...]
>> To my question now. Again a mainframe similarity that I'm
>> trying to find in tandem. When I search for some string in a
>> file using the mainframe TSO command, I used to get the
>> 'number' of times the string was found, as well. Though this
>> detail might seem unnecessary, I still got it. TEDIT's search
>> doesn't seem to tell me that. Neither does EDIT's command -
>> though it displays the list of lines where it is found. Is
>> writing a macro/routine the only way around this? Or is there a
>> way in both EDIT & TEDIT - which seems highly unlikely at this
>> point.
>>
> I can only tell you the shortest way I know to get the result in
> EDIT. TEDIT might have a way to do it, but I do not know TEDIT
> very well.
>
> In EDIT, I believe this sequence of commands will get the count:
>
> EDIT file; PUT temp /some string/; GET temp; NUMBER ALL;
> LIST LAST; EXIT
>
> this will put all lines that match "some string" into the file
> "temp", open temp, renumber the lines in the file to start with
> 1 and increment by 1, then display the last line in the file.
> The line number of that last file will be the number of times
> "some string" appears in the original file.

No, it won't. It will be the number of lines which contain "some string". If the string appears
multiple times on the same line, it will be counted only once.

The BREAK command can be used to break each line of the file 'temp' into separate lines
containing the separate occurrences of "some string", but doing so requires either knowing,
or making some assumptions about, the maximum number of times that "some string" could
occur in one line, e.g.

B A AT "string" "string" "string" "string"

If "string" occurs *five* times in a line, however, this will split that line into only four, with the
fourth line having two occurrences of "string".

Doug Miller

unread,
May 7, 2014, 7:41:24 AM5/7/14
to
Shiva <subrama...@gmail.com> wrote in
news:2c585b72-f0be-4417...@googlegroups.com:

> To my question now. Again a mainframe similarity that I'm trying
> to find in tandem. When I search for some string in a file using
> the mainframe TSO command, I used to get the 'number' of times
> the string was found, as well. Though this detail might seem
> unnecessary, I still got it. TEDIT's search doesn't seem to tell
> me that. Neither does EDIT's command - though it displays the
> list of lines where it is found. Is writing a macro/routine the
> only way around this? Or is there a way in both EDIT & TEDIT -
> which seems highly unlikely at this point.

This should get you fairly close:

EDIT filename; PUT temp /string/; G temp; BREAK A AT "string" "string" "string"; NA; LSL

This assumes that "string" doesn't occur more than three times on any given line; if it can,
increase the number of times "string" appears in the BREAK command.

> And one more functionality of mainframe which I used to adore is
> the TSO command - NX ALL F ALL 'search_string'
>
> For the non-mainframers, this command would delete or rather
> exclude all those lines except those which have the string which
> is searched. For example, if you search for 'Robin' in a file.
> All the lines except those which have the word robin will be
> deleted.

EDIT filename; DN/Robin/

Shiva

unread,
May 7, 2014, 9:35:29 AM5/7/14
to
@Keith: Could you please state how to get EDIT's response in OUTV? I tried EDIT /IN CMDFILE, OUTV VAR/ but that did not work. Doesn't recognise the commands in the command file if I add OUTV. Also string manipulation inside a TACL variable can be done only using #DELTA? Like just taking the line number out - on this occasion. (Previously once I tried delta, but was unsuccessful and using #SHIFTSTRING helped as, all I wanted on that occasion was to convert the string present in a variable to UPPER CASE.

@Doug: Using break 'n' number of times where I'm not sure of the value of 'n' doesn't make up for a good solution. Is there no other way to get around a solution for this? Have you people never wanted to know how many times a string was present in a file? May be you used different unsupported tools, but writing a macro for that shouldn't be too hard. I'm trying. I'll let you all know if I find a solution.

@wolfgang: Point taken, I'll try to reason with them, and get back to you with their reply. Thanks. :)

Doug Miller

unread,
May 7, 2014, 10:51:46 AM5/7/14
to
Shiva <subrama...@gmail.com> wrote in
news:cba26e94-eb77-4958...@googlegroups.com:

> @Keith: Could you please state how to get EDIT's response in
> OUTV? I tried EDIT /IN CMDFILE, OUTV VAR/ but that did not work.
> Doesn't recognise the commands in the command file if I add
> OUTV.

That seems to me like it should work. In any event, this is logically equivalent:

#PUSH cmdvar
#SET /IN cmdfile/ cmdvar
EDIT /INV cmdvar, OUTV var/
#POP cmdvar

> Also string manipulation inside a TACL variable can be
> done only using #DELTA?

TACL has many built-ins for string manipulation:
VCHANGE
VFIND
VDELETE
VINSERT
VMOVE
VCOPY
#CHARFIND
#CHARDEL
#CHARINS
#CHARBREAK
#CHARCOUNT

>Like just taking the line number out -
> on this occasion.

Because the line number is separated from the line contents by a string of spaces, you can
remove it this way:
#SET line [line] == strip leading and trailing spaces
== use #CHARFIND to find the first space (which must be *after* the line number)
== use #CHARDEL to remove everything up to and including the first space
== use #SET again to remove leading spaces

>
> @Doug: Using break 'n' number of times where I'm not sure of the
> value of 'n' doesn't make up for a good solution.

Agreed. But you asked if there's any way to do that without writing a macro.

>Is there no other way to get around a solution for this?

Write a macro. :-)

>Have you people
> never wanted to know how many times a string was present in a
> file? May be you used different unsupported tools, but writing a
> macro for that shouldn't be too hard. I'm trying. I'll let you
> all know if I find a solution.

It's not hard. If the file isn't terribly large, you can import the whole thing in a TACL variable
and loop through it with #CHARFIND, counting the number of times you find it.

If the file is too large for that, read it one line at a time using #REQUESTER READ, and
loop through each line with #CHARFIND.

Shiva

unread,
May 8, 2014, 3:29:00 AM5/8/14
to
The command file concept works if I'm typing
EDIT / IN CMDFILE/
in tacl prompt - but when I use OUTV in a macro like this:

EDIT /IN CMDFILE, OUTV LC/ it doesn't. Throws the basic error. Error, expecting file name or something.

Unsure why this happens.

Shiva

unread,
May 8, 2014, 3:33:18 AM5/8/14
to
I'll try #CHARFIND; but how 'terribly large' the file should not be. It might contain 7000 lines of code. Would that be a problem? I'd like to know what's the limit on that built in function and thanks for #REQUESTOR READ, I'll try check that out as well. :)

Doug Miller

unread,
May 8, 2014, 8:02:02 AM5/8/14
to
Shiva <subrama...@gmail.com> wrote in
news:15888c67-754e-41f1...@googlegroups.com:
Possibly the variable LC doesn't exist yet. When using OUTV, you must refer to an existing
variable. See if this works:

#PUSH LC

Doug Miller

unread,
May 8, 2014, 8:14:58 AM5/8/14
to
Shiva <subrama...@gmail.com> wrote in
news:ad8a8fdd-bf54-4381...@googlegroups.com:

> I'll try #CHARFIND; but how 'terribly large' the file should not
> be. It might contain 7000 lines of code. Would that be a
> problem?

Shouldn't be. IIRC, TACL won't allow more than 32767 lines in a variable.

Shiva

unread,
May 8, 2014, 2:08:32 PM5/8/14
to
@Doug: Of course I pushed the variable. I have some basic knowledge about TACL, :D

Shiva

unread,
May 8, 2014, 2:09:12 PM5/8/14
to
That should do, 30K is more than enough!

Doug Miller

unread,
May 8, 2014, 6:32:06 PM5/8/14
to
Shiva <subrama...@gmail.com> wrote in news:83bcf048-031b-4d05-9c25-
d8260e...@googlegroups.com:

> @Doug: Of course I pushed the variable. I have some basic knowledge about TACL, :D
>
Anybody can forget -- and that was the only reason I could think of why

EDIT /IN file, OUTV var/

wouldn't work.

Keith Dick

unread,
May 10, 2014, 5:54:02 AM5/10/14
to
Maybe EDIT's code was written with the assumption that IN and OUT would be the same, or something like that. You could try putting the commands on the command line:

EDIT/OUTV var/ file;cmd;cmd;cmd;exit

or give the commands via INLINE:

EDIT/INLINE,OUTV var/
+ GET file
+ cmd
+ cmd
+ cmd
+ EXIT

to see whether either of those approaches works. I cannot remember whether I ever used EDIT from TACL code like this. Maybe it doesn't work at all.

In another post, you asked about getting the line number from the line. I would do it this way:

#setmany linenumber, [line]

#setmany breaks the text following the comma into tokens at space characters, then assigns one token to each of the variables named before the comma. The above command will assign the first token to linenumber and discard the rest.

Doug Miller

unread,
May 10, 2014, 9:41:50 AM5/10/14
to
Keith Dick <kd...@acm.org> wrote in
news:mZKdnY9DQsugavDO...@giganews.com:

> Maybe EDIT's code was written with the assumption that IN and
> OUT would be the same, or something like that.

Definitely not. There's no problem at all with any of these:

EDIT /IN file1/ == OUT defaults to HOMETERM
EDIT /IN file1, OUT file2/
EDIT /IN file1, OUT $S.#loc/

> You could try
> putting the commands on the command line:
>
> EDIT/OUTV var/ file;cmd;cmd;cmd;exit

That definitely works.
>
> or give the commands via INLINE:
>
> EDIT/INLINE,OUTV var/
> + GET file
> + cmd
> + cmd
> + cmd
> + EXIT

So does that.
>
> to see whether either of those approaches works. I cannot
> remember whether I ever used EDIT from TACL code like this.
> Maybe it doesn't work at all.

Oh, absolutely, it does. I don't think I have any examples of using EDIT /IN file, OUTV var/,
though -- and given that everything else works, I don't see a reason why that shouldn't
either.
>
> In another post, you asked about getting the line number from
> the line. I would do it this way:
>
> #setmany linenumber, [line]
>
> #setmany breaks the text following the comma into tokens at
> space characters, then assigns one token to each of the
> variables named before the comma. The above command will assign
> the first token to linenumber and discard the rest.

I think he wanted to discard the line number and keep the rest.

There are a few other options as well:

1. The EDIT command LU (List Unsequenced) lists lines without the sequence numbers
2. The command LS (List Sequence) lists *only* the sequence numbers
3. It's not hard to write a TACL routine to separate them.

Shiva

unread,
May 13, 2014, 2:55:50 AM5/13/14
to
Hi Keith, I tried all your methods - they don't work in my macro. I'm not sure why.

I'll explain what I do in my macro. First I get a file - put a copy somewhere else, delete all lines that are not what I want in this copy, then number all and then exit inline. And then I start a new inline where I open the copy file, list the last line and exit. This second part of inline is what I try to capture in my OUTV. But when I run my macro - it says current file is first file twice, then current file is copy file twice, where the second time it states that *Error - name of file, builtins or *something else* needed*. But when I take out OUTV, it works fine. Just that the last line is printed on my terminal.

What am I doing wrong?

Shiva

unread,
May 13, 2014, 2:56:26 AM5/13/14
to
Sorry doug, Keith did understand me correctly this time. :)

Keith Dick

unread,
May 13, 2014, 3:35:09 AM5/13/14
to
I don't have a strong feeling for what is going wrong. Maybe the first EDIT is not being terminated before you start the second. Maybe you have some mistake in your TACL code that is making it do something other than what you expected. Maybe something else.

Try a simple case of a macro that just runs EDIT with OUTV and the name of an existing Edit file on the EDIT command line, sends it a simple LIST LAST command, or something similar, exits EDIT, and displays the contents of the variable you used with OUTV. Once you get that to work, maybe it will shed some light on why your more complex macro does not work.

Tone

unread,
May 13, 2014, 4:40:16 AM5/13/14
to
Hi Shiva,

Here is an example that I think matches what you are attempting.

given this source file :

tacl> fup copy f1

good line first
bad line
good line second
bad line
good line third


the following macro makes a copy, deletes all the non good lines,
renumbers it and lists out the last line :

tacl>fup copy doit

?tacl routine
#frame
inlprefix ++

fup dup f1,f2,purge

#push eout

edit/inline,outv eout/
++ g f2;dqn/good/;p!;na;ll;e

#output [#lineget eout [#linecount eout] for 1]

#unframe

And the output will be :

FILES DUPLICATED: 1
3 good line third

Shiva

unread,
May 14, 2014, 5:38:42 AM5/14/14
to
@Tone, @Doug, @Keith: Thanks everyone. I found the issue. It was just that #SETMANY command was not bracketed, which produced the error. Corrected the error. Thanks for all your help. I have an adjoining query. Since my macro uses EDIT, it produces the following on my terminal, before it produces the desired output from #OUTPUTV.

Text Editor - version - date.
Current file is XXX.
Current file is YYY.
Current file is ZZZ.
$Vol.Subvol.file is purged.

These are edit's replies to the commands I've used in the macro, I know. And purge reply is from tacl. But how do I make edit/tacl to not echo these to the terminal. Or is there a clrscr(); like in C language. To clear the screen and then print my desired output? Thanks in advance.

Tone

unread,
May 14, 2014, 9:01:54 AM5/14/14
to
If you send the output of EDIT to a variable (OUTV) then the first four
lines will be in the variable rather than on the screen (see my example).

As for the purge output you could use something like :

SINK [#PURGE filename]

This will suppress the output but will also not let you know if there
was a problem when the purge was attempted. Or you could have :

#set fse [#purge filename]
[#if [fse] |then|
#output Error [fse] purging filename!
]

wbreidbach

unread,
May 14, 2014, 9:07:24 AM5/14/14
to
I am not really familiar with EDIT but as far as I know EDIT commands have a "QUIET" option. I used this in a replace command.

Shiva

unread,
May 14, 2014, 9:36:56 AM5/14/14
to
@Tone: Wow, that was exactly what I wanted. That outv was staring right at my face, I could've thought about that. Never struck my mind! And OUTV works, but OUT doesn't. Why? With inline, I mean.

And about that sink #purge - cool. Never thought that it could be suppressed. And the other foolproof method was also cool! Thanks for your help. :)

@wolfgang: Quiet command suppresses the commands where we manipulate or read the file using edit. But 'current file is xxx' etc are basic replies from edit which can't be suppressed by quiet command, if I'm not wrong! :) I knew that command well enough to not use it wrongly, or at least I'd like to think so. Thanks though.

Doug Miller

unread,
May 14, 2014, 9:50:48 AM5/14/14
to
wbreidbach <wolfgang....@gmail.com> wrote in
news:c331ebce-238c-4e70...@googlegroups.com:

> I am not really familiar with EDIT but as far as I know EDIT
> commands have a "QUIET" option. I used this in a replace
> command.

This won't suppress the "Current file is $vol.subvol.fname" messages, though. EDIT throws
those as soon as it opens a file.

To suppress all of that stuff:

#FRAME
#PUSH #INLINEECHO, #INLINEOUT, #INLINETO, #INLINEPREFIX
INLECHO OFF == equivalent to #SET #INLINEECHO OFF
INLOUT OFF == similarly for #INLINEOUT
INLPREFIX **
EDIT /INLINE/ == INLOUT OFF suppresses "Text Editor..." banner
** G [filename] == likewise, "Current file is..." also suppressed
== INLECHO OFF suppresses echo of commands to display
INLTO my_var == subsequent output from the INLINE process goes to my_var
** L {whatever}
INLTO == with blank argument, turns off copying output to my_var
...
INLEOF
#UNFRAME

0 new messages