tjarrad Absent Member.
Absent Member.
2627 views

Reusing login logout transactions in multiple scripts?

Hi all,

Wondering if someone has successfully implemented, and can provide an example of how to reuse code in multiple (web) scripts. I've checked the documentation and find it lacking.

I have a lot of scripts to create and they all use the same login/logout sequence, so naturally I don't want to have to create parameters/correlate/declare/rename forms this every time. Ideally, I want TInit to login, and TEnd to logout, while TMain does whatever the script's purpose is.

What's the best approach?

If the best approach is to put it in a .bdh, how do I create one of these for a low-level web script? What sections do I need? How do I get the variables/correlations I need to continue in the TMain, back into the calling script to be used? (there are multiple session variables that need to come back). I've seen the .bdh solution referred to in community docs etc, but haven't see any examples of working solutions and my attempts at creating it thus far have failed, and I'm running out of time to investigate it.

If the best approach is something else... well I guess the questions are probably similar. 

Any ideas?

Thanks

0 Likes
3 Replies
Highlighted
ckim9 Absent Member.
Absent Member.

RE: Reusing login logout transactions in multiple scripts?

I have been using the same technique for years without any issues. If you need to preserve any variables from the login function or TInit, use global variables. Since the global variables are assigned per virtual user, you shouldn't have any conflicts with other virtual users executing the same transactions. Also, as the session variables are usually passed via cookies, you shouldn't have to preserve them yourselves for Silk Performer does that for you automatically.

0 Likes
tjarrad Absent Member.
Absent Member.

RE: Reusing login logout transactions in multiple scripts?

I'm not sure this quite answers the question. Where do I put the login function? How do I define it so multiple scripts can access it?

Good to know there's a per user scope for global variables. How does one go about defining them in a web script? The help info I'm finding all seems to refer to .NET or Java explorers, and I don't have the 'objects' tab they refer to?

As an aside, the sessions data I need to correlate is not stored in cookies, so is not handled automatically.  But if I can get global variables working, I can probably solve this problem without too much trouble.

Thanks

0 Likes
PhilipL Absent Member.
Absent Member.

RE: Reusing login logout transactions in multiple scripts?

Hi,

You have to put the code which you want to reuse in functions in a .bdh file.

For example:

LoginLogout.bdh
---------------

dclfunc
  function FMyLogin
  begin

    // your code for login

  end FMyLogin;

  function FMyLogout
  begin

    // your code for logout

  end FMyLogout;

 

MainScript.bdf
--------------

// .... on top

use "LoginLogout.bdh"

// ...

transaction TMain
begin

  FMyLogin();

  // custom code

  FMyLogout();

end TMain;

 

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.