Link to home
Start Free TrialLog in
Avatar of notesrookie
notesrookieFlag for United States of America

asked on

Running an agent within an agent

Greetings learned experts,

I am on Domino R6.5. I am trying to run an agent, AgentA, and within this agent I call 2 more agents, AgentB and AgentC. AgentB executes without a problem calling a script library. AgentC is the same as AgentB except for the change in one of the function names in the script library. I am using "If agent.Run <> 0 ...". I know that you cannot run an agent recursively but I thought I took care of that by "creating" a separate script library. I can run AgentC by clicking a button but am unable to run it from within another agent. Please let me know if you require more information. Thank you.
Avatar of SysExpert
SysExpert
Flag of Israel image

I thnk that the problem is understanding how things work.

I think that once you run AgentB from Agent A, you are expecting to be able to run AGENTC after AGENTB finishes.

I think that once you run another agent, you can not expect it to return to the first one again.

I would look for some good articles on this and double check the design help to be sure.

I hope this helps !
Avatar of notesrookie

ASKER

Hmmm - I thought that checking the return status of the agent would be sufficient for a "return" to the original agent.  Anyone else have more thoughts on this? I looked in the designer help and all I got was that you can call other agents but not the logic behind the return. I did try the "cascade"method, that is, AgentA calls AgentB and AgentB calls AgentC.
AgentC is still an issue. I know I created it from another script library and changed enough so that it is a "different" script. Let me start over and see what happens.

Thanks.
ASKER CERTIFIED SOLUTION
Avatar of Sjef Bosman
Sjef Bosman
Flag of France image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of marilyng
marilyng

Sorry, keep hitting the submit button too early.. but agree with sjef here, much easier to nest them all in a script library and use logic to tell whether to move to the next sub or not.
Thanks for the suggestions. I'll have to see which one would be the easiest to implement.
Well my 2 cents worth is that the Correct way to do it would be to create a script library as sjef_bosman has requested and try to have good coding style.  It is also possible that all you need to do is write a Subroutine.  If you want to move forward in your ability to code in Notes I highly recommend that you learn how to do a script library and that you very probably need to learn how to write Functions and subroutines as well.  

Congratulations you are writting in script and you seem to be somewhat proficient from the content of your questions (arrays etc).  But I bet that you are in an environment where you have not had the benefit of working with an experienced programmer so all your knowledge is hard won and self taught.  The first big step is moving from Formula Language to Script, the second step is often learning Subroutines and Functions and the third step is often using script libraries.  Hopefully you also learn how to write Error Handlers as well.  There are other steps like working with the API and implementing the Lotus Extensions etc.. But those are the bread and butter steps to proficient coding in lotus.

I have made an assumption that the main reason that you are trying to call agents from agents is so that you have the benefit of Re-use, so you can call any of the other agents just on their own.  You should probably give your reasoning so that you can be given alternatives that follow good coding style.  The reason that Subroutiens and Script libraries are prefferable is that there is a much higher level of control, and it is also more in line with coding best practices.  

Good luck.



You're right. They found out out I knew something about Notes, albeit from the administrative side of things, and they assumed that I knew how to code. They have come to expect "miracles" which I have only been able to pull of because of this website. Anything I've learned, as you say, was self taught, what I learned from here and spaghetti coded together. If you have links to places where I can go and read about bettering my skills, other than getting formal training (there is of course no money or time for that), that would be greatly appreciated.

Let's just say it's rare when I have a non-coding day. Thanks.
As it seems, you're doing a great job. You're flying a 737 and the only thing you were hired for was maintenance. I suppose you're not really awarded for the additional things you do? Hm... And no money for training? Frankly put, you deserve a better employer! Someone who appreciates your going beyond, and your willingness to do so.

IMHO, getting a solid background takes a lot of time. How it functions I cannot tell (hm, maybe I should write a book about that), but you need "structures" in your mind. There's methodology, then methods, then application. What you need is not a pile of very good books, but someone who guides you along the way: a skilled project manager. He or she can show you how to create the application the users have been waiting for. Many questions like: "but why are you doing it like this?" cannot be answered in books, they must be "revealed" to you. And you need some hands-on training and book for the most important subjects: programming languages, coding principles, and data structures.

In this case, you need to think: I'm not the first with this problem, and they must have some vehicle to do what I want. Still, don't think codig, but structure or design, that's one level above. In my first agent, I want to do A, B and C. In my second agent, I need D, B and C. How can I accomplish that with a minimum of recoding? In the old days, they developed object libraries to do that. Script libraries are not that much different: its purpose is to share/reuse code easily in your application.
nicely stated, sjef.  And I agree.. notesrookie needs a better employer.. !!  
And to think y'all, sjef, marilyng, madeeshwar, sysexpert, etc. are helping me fly the plane. You have most definitely helped me out in my many hours of banging-head-against-the-wall need. I really appreciate your letting me know that I'm doing better than I really expected. It's funny that you're letting me know about the project manager as I just got one who is showing me the big picture on one of the more complicated databases that I am working on. Talk about eye opening. It's no fun flying by the seat of my pants and blind at times trying to guess at what the user wants. Normally the coding I've been doing have been driven by some users that I believe are not sure what they want or the application has been transferred from a spreadsheet and yet the want the same functionality as the spreadsheet and not want to take advantage of what Notes can offer. And you're right I need to start thinking in terms of script libraries. See your brief statement about them explained more to me than what designer help does. I do seem to find myself writing almost the same thing over and over again.

And with that being said, I have implemented sjef suggestions and that seems to working pretty well.

Thanks again and if you're ever in the Los Angeles area let me know and I'll buy you (my mentors) a drink (or if you don't do the hard stuff I can certainly do coffee or bubble tea aka boba tea).

As for a better employer ... I have a mortgage to pay off so until I get brave enough to say I can do and want better, I remain, your humble - NotesRookie.
This is a closed post but.. for the benefit of those seeking online materials for coding help and to round out the post

in response to:
 If you have links to places where I can go and read about bettering my skills, other than getting formal training (there is of course no money or time for that), that would be greatly appreciated.

http://www-12.lotus.com/ldd/doc/uafiles.nsf/docs/ls70/$File/lscript.pdf

Here you can type in LotusScript Javascript java etc.. and get the documentation Free yaaaaay free
http://www-10.lotus.com/ldd/notesua.nsf/$$Search?OpenForm

They are online but the Lotus Yellow Books are a best buy
H'm, yes, very good suggestions, but... they usually discuss the "how", and not the "why". IMHO a good developer (who's more than a programmer) needs a solid background in programming fundamentals (binary, octal, decimal, hex, sorting, recursive functions, bit manipulations, ports, classes, data structures etc.) in order to recognize the structure in a certain situation or application. The tricks of the trade cannot be found in those books. Sadly, I do not know a better way than to join a good team or project, and to absorb anything you can lay your eyes on.
Question about yellow books.. they seem to be a print out of HELP.  Best investment, if you want to learn, is the VIEW.  Excellent samples, solutions, and discussions of best practices:   http://www.eview.com/

Boot camps are also very good.   If you can't get into a good team or project, then, this type of collaboration is excellent.
sjef, you make a very good point in trying to encourage the recognition of structures, datatyping, paterns etc.. And joining a good team would be great.  The View is a great resource too.  

My main reason for recomending the yellowbooks is that I suspect that he is the A team the B team and the C team.  The experienced developers were too rich for his employers blood.  He won't get training, or training time or help from consultants.  When I arrived at my current environment there were some really amazing mile long subroutines and three overworked undertrained developers.  Intelligent as heck, but not real object oriented, and completely self trained.  The databases there were not pretty but they were holding the place together. Getting those developers to just create a few functions and subroutines other that Click and Initialize helped a lot.  Error handlers were also absent and made a nice improvement.

I don't think notesrookie has ventured very far outside the long single subroutine, and that if he creates a script library it will very likely be his first.  The lotusscript pdf I tried to link him to gets into data types, passing arguments by reference and by value, recursive functions, Error Processing, Scope and file handling.  The error handling alone might make it a worthwhile read for him.  It is not everything he needs there is a whole lot more that would be good for him to learn.  But if he reads the yellowbooks he will have a base.
1) Hope you read ed-commands:
    g/ he /s// she /
Notesrookie: please update your EE-profile...

2) >> But if she reads the yellowbooks she will have a base
I think that's where we disagree: to me, yellowbooks are not a base but the 10th floor... Knowledge of the floors underneath is required, and especially the understructure is not to be disregarded. Hm, I don't particularly like this metaphore, but I hope you understand.

For some perspective, here's a curriculum: http://www.informatics.manchester.ac.uk/undergraduate/courses/structure/firstyear/index.html
OK bad choice of words.  It will give her a bigger toolbelt without building the base.  But some of the elements in that toolbelt will move her in the direction of better coding.  Most specifically subs, functions, script libraries and error handlers.

Starting at the 10th floor is not ideal, and it makes it harder to get into good habits.  She is already flying the 747.  It is unlikely that the code being written is very modular.  There is a lot more to good coding practices than whether or not the code has error handlers and whether or not the code is modular, but modular code with error handlers is a small step in the right direction.  Lots of people who begin by programming in formula language have a macro based linear mindset that is hard to overcome.  Asking how to push a button in another form using some type of code is perfectly logical from a goal oriented, macro based, linear point of view.  It is a perfectly logical approach to a problem.  Moving from that mindset to one where you pass parameters into modules to achieve the same goal is a step forward.  But I can understand how you could argue that I am advocating the creation of bad modular code with error handlers.

Her applications work, she is still employed, and modularized code (with error handlers) will help her to achieve her objectives more effectively.  Once she makes that change then there is a lot more to learn.  I should make it clear that the path that sjef has suggested is a much better path.  What is the best plan B if the mentor/teacher is not available/affordable?  A pile of books in the absence of guidance is not the best approach, but I think that the absence of a pile of books and the absence of guidance is worse.  For that reason I advocate books (And good magazines like the view and good forums like OpenNTF.Org and asking smart people on EE like Sjef and Marilyn) but that is not the best option just the best plan B.  I hope I am not a corporate monkey telling her not to touch the Bananas, the options you describe are better options if she has access to them.  

Learning the concepts first and then getting to the specifics is a much better approach.  I think that we would both agree that coding to meet a specific objective and looking at help once you are bogged down is not as good as reading/learning/being shown an overall picture first and then coding.  The yellowbooks may be bad choices because they are task specific and do not give the reasons why you do things they just show you how to do things.  But since I advocated script libraries, functions, subs and error handlers I thought they would be a good place to learn how to implement those suggestions.
Heh, eye-opener: who knows, you may be the lamb here and I the sheep ;-))
sjef - Updated. Thanks for the political correctness but those in the know on my team address me as "Notes Goddess". But I liked your metaphor - you need a good table foundation, poured and cured, before you can build the floors above it. I'll do my best for future projects to meet with the folks to get the requirements and what needs to be done as a more formal part of the entire project. Oh heck the entire process is anything but formal as I'm sure you've figured out by now.

And I did start in formula language hence the mindset. I can get things done but not necessarily the best or most efficient way. So both your words have been helpful to me. Thank you.