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

TACL MACRO for automation of basic manual work - EDIT select text.

2,338 views
Skip to first unread message

Shiva

unread,
Mar 20, 2014, 3:08:10 PM3/20/14
to
Hi everyone,

Sorry for such a vague title - couldn't think of a descriptive, yet short, title at 12 in the night! Excuse. Hope you all have been fine! Learning lots of tandem, every single day. Though I'm having to cope up with the work that I've to complete, I try to learn as much as I can. And even this group has become kind of a journal entry for my life since Tandem introduction in my life. Hope I get to meet at least some of you, someday!

Now to the query. I have an obey file, - okie, a so many obey files. And inside these obey files are lines of code which have DD statements (Variable names pointing to files) and also run commands for some cobol programs. Now, I want to purge data all these output and input files which are present in obey files. For that I have to open all the obey files and check them to find the "files used". And then go and purge data those files. Now you may be thinking that why not just add purge data line on obey jobs for those files. Let's just say, for this context that it is not possible.

So I'm thinking of creating a tacl macro to search and pick up the filenames from these obey jobs, the list of which is present in a file (one obey filename per line). So basically the tacl macro should read this master file and open the corresponding obey job and search for file names, and purge data those files and close the obey job and open the next one.

Looks hard from the outside, but I've cracked most part of it (thanks to all you people's help in my previous experiments with TACL MACROS), except for the main logic - where using EDIT I try to locate the filename. I know that there will be $VOLUME, in the file name. So I'm thinking - why not search for $ and then take that string till the next space(or a comma), which will probably be at the end of the file. Get my drift?

Ex: INPUT-FILE \SYSTEM.$VOLUME.SUBVOL.FILE,shared

Just as I write the above example, I remember, may be I can use \ which SYSTEM uses. The VOLUME will change, but it will definitely use $ and that should probably be the only thing (mentioning file names) using the character $ in that obey file. So if I search for that $ and take the whole string including that right until a space after that, or a comma - I think I'd get the file name.

I'm not sure how to do this using EDIT commands, because I'm not familiar with EDIT. Someone could help?

Also I have a subquery. I'm going to use EDIT as an inline process (Boy, I've learnt a lot! Using technical words which I didn't even get the meaning of, a few weeks back!) but I think after I open the obey file and copied that string (file name) into a variable or so, I should go use a FUP command to purge data the file. How do I do that inside an inline process? Impossible, I guess? What would you suggest?

Can I start an inline process for FUP inside the inline process of EDIT? And if so, *as per requirement, I'd have to purge data the file, and then come back to the master file containing all the obey file names, and then open the next file in EDIT, and do the same in loop again!* how in God's name can I accomplish this using successive inlines, because I'd have to resume to go back to FUP's inline and then back to EDIT's inline, back and forth! Not sure whether I could do that.

Also, a simple idea struck my mind as I was trying to analyze any other ways of accomplishing the above using a different method. (just the part where we purge data and back to file to read the next filename)

What if I just take all the file names, into another output file? All the file names that are used inside all the listed obey jobs? And then just give that as an input to another FUP inline process which will purge data all the files listed in that file created by EDIT inline process? Seems simple enough. Should work, right? How do I paste all the file names taken into a new file successively using EDIT? By just using EDIT the normal way you open and paste the variable at EOF and close it? But remember? In my obey file, I may have multiple filenames - so when I collect one file name how will I drop it to the output file and then again search for the next possible filename present in the obey file?

I'd really like to try the INLINE inside INLINE, resume and stop and resume and stop process - if there's any. Also I'd like to see this separate EDIT and FUP inline process work as well. This macro is not for work, but just for fun - just to try out all the possibilities, if the need arises. To stretch the limits of the TACL knowledge I know. :)

The whole question has been a journal kind of an entry. Thanks for patiently reading though. And apologies for anyone whose precious time, this post wasted.

Let me know if you get answers for any of these. Have a nice day! :)

wbreidbach

unread,
Mar 20, 2014, 4:37:24 PM3/20/14
to
I am not really familiar with EDIT, I am a TEDIT guy. What you could do with TEDIT:
Search a file for something, copy the line containing that something and find the next occurence of that something. Afterwards open a second window and retrieve the copied lines. I never tried but this should be possible within a mcaro running on a 6530 screen.
I am not in the office so I have to do that from memory:
tedit <myfile>;search "something",f/l,1:239,line copy,findnext;open <newfile>;retrieve;exit

(not sure about the open)

Keith Dick

unread,
Mar 20, 2014, 4:45:39 PM3/20/14
to
I'll take it as given that you cannot rearrange how those OBEY files and programs are set up. If I had to solve that problem, I'd probably try to rearrange how the file names were communicated to the programs, so the filenames could be listed in one place, which could also be consulted by this program that is to do the purgedata.

By the way, do you really want to purgedata the input files? I suppose if they are output files of earlier steps, that makes sense, but unless those input files are output files of earlier steps, doing a purgedata on them doesn't seem like it would be the right thing to do.

Now to your problem.

No, you cannot have nested INLINE. Just one INLINE at a time. However, you can have as many programs using INV (with each program using a different INV variable) at the same time as you like. Or one INLINE and one or more INV at the same time. So it is possible to feed commands from your TACL code to any of a number of programs that are running at the same time.

Your idea of saving all the filenames until you have looked at all the OBEY files, then move on to doing the purgedata commands is a good way to do it, which would let you use EDIT with INLINE to find the filenames, then later stop the EDIT and start FUP with INLINE to feed purgedata commands to FUP.

As far as getting EDIT to extract the filename from the line it is on, there isn't an easy way to do that. However, if you get EDIT to list the line that contains the filename and capture that list output in a TACL variable, then you can use TACL code to pick the filename out of the line. Something like:

EDIT/INLINE,OUTV lst,NOWAIT/
...
+ L /$/
[#set line [#extract lst]]
Here write TACL statements to find the filename in the variable line and put it in a variable by itself.
Then you can use that variable to construct a purgedata command to send to FUP by #appending to an INV variable
or build a list of filenames by #appending the value of the filename to the variable that is the list of filenames.

The EDIT command L /$/ will list all the lines that contain a $. If you are sure that the only lines that contain $ are the lines that have the filenames you want to do the purgedata on, then that command will list them for you. If there are several such lines in the current file, that command will list them all, so you would need an #extract loop to process them one at a time.

I think that covers all you need to do. If there is some part of the task that you still are unclear about, just ask about it.

Doug Miller

unread,
Mar 20, 2014, 5:38:33 PM3/20/14
to
Keith Dick <kd...@acm.org> wrote in
news:HcadnY0tvdXgzrbO...@giganews.com:


> No, you cannot have nested INLINE. Just one INLINE at a time.

Sorry, Keith, this is incorrect.

You can have as many nested INLINE processes as you please -- but only the innermost
one can be active, and you must terminate it before you can send additional commands to
the immediately previous INLINE process.

Example:
#PUSH #INLINEPROCESS, #INLINEPREFIX
INLPREFIX --
PATHCOM /INLINE/
-- OPEN $pm
-- STATUS SERVER *
#PUSH #INLINEPROCESS, #INLINEPREFIX
== at this point we cannot send commands to the Pathcom process
INLPREFIX **
EDIT /INLINE/
== now we can send commands to Edit
** GET myfile
** LA
INLEOF
== right now, we can't send commands to either one
#POP #INLINEPROCESS, #INLINEPREFIX
== and now we can send commands to Pathcom again
-- STATUS TCP *
INLEOF

Keith Dick

unread,
Mar 20, 2014, 5:57:27 PM3/20/14
to
Okay, you caught me. I didn't say it precisely correctly. However, Shiva was asking about using INLINE with two processes without terminating either. At least that is what I think he was asking about. And I am correct that that cannot be done.

Doug Miller

unread,
Mar 20, 2014, 10:27:18 PM3/20/14
to
Keith Dick <kd...@acm.org> wrote in
news:lOmdnZcbYLbM-bbO...@giganews.com:
You're still not being precise enough to be completely correct. The example I showed
above is a paraphrase of actual working code. You *can* use INLINE with two processes,
without terminating either. What you can *not* do is switch back and forth between them, or
use them simultaneously -- but nothing at all prevents you from using them serially.

Specifically, you can use the second inline process without terminating the first.
You can launch and use a third inline process without terminating either the first or the
second. And so on.

You can't re-use an inline process without terminating all inline processes that were started
later: to use the second one again, you must terminate the third; to use the first one again,
you must terminate the second and the third; etc.

Keith Dick

unread,
Mar 20, 2014, 11:07:27 PM3/20/14
to
I think your description is precisely correct. However, if you look at what Shiva asked in his original post, he *was* asking about switching back and forth between two INLINE processes, and that is the question I answered with a shorthand "you can't do that". Assuming Shiva understands your description, it will teach him why he can't do what he was asking about, which would be good. It just isn't what I was focusing on.

Tone

unread,
Mar 21, 2014, 2:47:12 AM3/21/14
to
Others have discussed the techniques of using INLINE, so the following
is just another possible way of tackling (or TACL'ing) the problem.

If you have the Viewpoint product installed it comes with some TACL code
that allows you to have multiple background processes running
simultaneously.

To check to see if it is installed type VARIABLES :UTILS:DP and you
should see a list of variables.

I use it a bit for scripting test cases. For example, the following
creates 2 SQLCI sessions, the first locking a table and the second
trying to read from it.

?tacl routine
#frame

dp sqlci/pname sql1/
dp sqlci/pname sql2/

sql1 begin work;
sql1 lock table testtab in exclusive mode;

sql2 control table testtab timeout 5 seconds;
sql2 select * from testtab;

sql1 unlock table testtab;
sql1 rollback work;

:utils:dp:undp sql1
:utils:dp:undp sql2

#unframe

Documentation on DP can be found in chapter 4 of the Viewpoint Manual.

Shiva

unread,
Mar 25, 2014, 9:36:32 AM3/25/14
to
@Wolfgang: Hi, thanks for that command. It gave me a headsup in trying to work out the one major blockhead that I was trying to solve. But the command is:

tedit <filename>; search "something", f/l,1:230, find next (or line copy); (if line copy specified in search) write scratchpad, <newfile>; exit

The point is - in search command, "When found" parameter can just be one command, when I tried to specify two commands "Find next; line copy" - it said too many commands. So I tried a different way.

tedit <filename>; search "something", f/l,1:230,line copy; write scratchpad, <newfile>;exit
tedit <filename>; search "something", f/l,1:230,delete line;exit

And I used the following commands in loop, as I knew far ahead that "something" which I searched for - occurs only once in a line, and I also knew the number of times it occurs. But also this deletes lines from my source file. That does not help. Though I can take copies, this is tedious. One more thing, I can't know how many times the "something" occurs in every file I try this macro on. So that's got to be solved as well.

But thanks for the heads up.

@Keith: Can't rearrange obey job. Also "If I had to solve that problem, I'd probably try to rearrange how the file names were communicated to the programs, so the filenames could be listed in one place, which could also be consulted by this program that is to do the purge data." - Yes, that's how I've decided to go on, as well.

By the way, do you really want to purgedata the input files? - Yes. Because I just don't intend to stop with purge data. I want to FUP (DUP or COPY) right after I purge data the file. So there's that.

Also thanks for clearing the air about "switching back and forth between two INLINE processes" - That can't happen. Okie.

@Doug: Thanks for your explanation on using INLINE. I did understand that. And that makes a lot of sense. :)

@Tone: I don't totally understand how that would tackle (TACL) my problem, as you put it. But thanks, I'll check that utility as well. :)


Also, everyone, I've been thinking a lot lately, and this is what I'm stuck on - about this macro.

I don't think using $ is the way to find the file names. Searching for "ASSIGN" is better. Because in these obey jobs, searching for ASSIGN gives a much shorter list and way of finding my file names.

So to take out the filenames exactly from these assign statements, I'm providing you with details regarding how my assign statements might look.

ASSIGN SOMETHING-HERE, $VOL.SUBVOL.FILE ,SHARED
ASSIGN SOMETHING-ELSE ,$VOL.SUBVOL.FILE2 ,SHARED
ASSIGN SOMETHING-OTHER ,$VOL.SUBVOL.FILE3, SHARED
ASSIGN SOMETHIN-ELSE, $VOL.SUBVOL.FILE4, SHARED
ASSIGN ERRORLOG-PROCESS ,$PRES2 ,SHARED
ASSIGN OUT ,$SP

So that's how the assign statements look basically. And if I'm able to take these assign statements from the file - to a new file first (@wolfgang assisted me through a edit command above, though I'm still stuck regarding that), then I'd have to segregate the file name alone. Basically the file name resides between two commas in a line. But that's not true in the case of the fifth line, where it is the process, not the file name - so I can omit that. And in the sixth line, it is the spooler. So that's to be omitted as well.

So the main things to consider are,

* file names specified between commas,
* if there's no "."(period) in a filename, it can be omitted (process or spooler)
* if all the string between two commas are taken, the spaces have to be trimmed (not necessarily though)


I came up with some ideas that might help regarding this. The most useful one was, to first specify word stops in "recon o" (reconfigure options) - comma, and space.

Then use the following command on all lines (one by one - I don't know of a way to execute a command for all lines in Tedit)

2 delete word; copy word; write scratchpad, <newfile>;

This takes the file name to the new file, but also with a comma in the end. (which I can't do anything about - I thought may be I'll just replace it later from that file somehow with a blank)

The other useless ideas:

Trying "break at" TEDIT command to break the filenames, then copying the lines which start with "$" to another file later.

Using some other copy command, which I can't seem to remember now. That which defines a region using ( and ) or { and }. I just don't remember the name of it, right now.
Anyways, let me know if you have any ideas, or suggestions regarding this. Thanks very much already for all your help and patience!

wbreidbach

unread,
Mar 25, 2014, 10:59:05 AM3/25/14
to
I see the TEDIT problem, I just did it from memory, so I just tried it:

tedit myfile1 r;search ?if,f/l,1:239,i,"line copy;findnext";openwindow 2,myfile2!;retrieve;exit

I forgot the options parameter and the apostrophes arround the when-found commands.
In that case ?if is the search-argument (sourcecode with conditional compilation).

Shiva

unread,
Mar 25, 2014, 11:53:38 AM3/25/14
to
Thanks @Wolfgang. Wow! that actually worked. But, there is this small niggle that always used to arise every time i tried to use find next & when found together in search. If there are 10 occurrences of that string, this find next & when found combination works only on alternate occurrences. I give like:

searchfor:string
in lines:f/l
in columns:1:239
options:i
when found:DELLINE

whenever i used to provide this, (consider this string has 10 occurrences in this file), I always have alternate 5 occurrences deleted. and i had to run this script again, to delete the remaining (in this case 2 or 3 gets deleted) and again run it to delete the remaining. it actually works only for half of the exact occurrences. I can try to explain why, but you would have already guessed it. it searches before using when found, it searches again. so, that doesn't work very well sadly! Atleast it doesn't provide the desired output. Any suggestions?

Randall

unread,
Mar 25, 2014, 1:49:47 PM3/25/14
to
I hate to be a stick in the mud here, but this seems like a pretty simple problem if you were in the OSS space using OSS tools, like grep and sed. Just saying. Or better still, regex pattern replacement in ECLIPSE.

Shiva

unread,
Mar 25, 2014, 2:17:42 PM3/25/14
to
Ha. Well, Randall - I don't have access to the OSS or ECLIPSE environments. So, have to make do with what I have. Appreciate your comment, though! :)

wbreidbach

unread,
Mar 25, 2014, 7:01:11 PM3/25/14
to
Am Dienstag, 25. März 2014 19:17:42 UTC+1 schrieb Shiva:
> Ha. Well, Randall - I don't have access to the OSS or ECLIPSE environments. So, have to make do with what I have. Appreciate your comment, though! :)

I never experienced that alternating thing during copying lines, only when deleting lines. Just remind: If the "when found" contains more than one command they have to be separated by semicolons and the whole when-found has to be enclosed into apostrophes similar to my sample above.
There is another tool available in the Yahoo Tandem group, the BROWSER. If you are able to download, have a look at it. This tool only works interactively but you can do a "search all" and in the full version that is planned to be available within the next 2 weeks it is able to copy every line containing the searched string into another file.

Shiva

unread,
Mar 26, 2014, 1:31:14 AM3/26/14
to
Could you please try copying the lines and let me know whether it arises? It does, for me. And let me know if there's a way to counter it? I guess Keith might be able to provide some reason. Also regarding that Browser tool of yours, I can't download anything onto my system. A very secure workplace where even mobile phones are not allowed. And very limited access to internet. So that's why I was not interested in that tool. Sorry.

Shiva

unread,
Mar 26, 2014, 3:28:27 AM3/26/14
to
Update: I did find why it was doing so.The 'In Columns: 1:239' was what created problems. Changed it to 1:130 which helped! Thanks, regarding that. Now I'll try what I can. Thanks much, @Wolfgang. If not for you, I won't have learnt many awesome new TEDIT commands.

shubhanka...@gmail.com

unread,
Oct 25, 2018, 10:46:57 AM10/25/18
to
Are you shiva Yadav ???
0 new messages