Spawning a Child Window

From Sysgem Support
Revision as of 09:29, 29 March 2011 by Mike.schofield (talk | contribs)
Jump to navigationJump to search

'Tips for developers working within the Sysgem Enterprise Manager (SEM) environment'.


Spawning a child window in SEM:

One window can be started from a another window by:

  • adding code to the (M) Pre-processing script of menu option in the parent window
  • adding script comment in the Main Display Pre-processing script of the child window


To Initiate the Spawn Command from the Parent Window...

Add the following code in the '(M) Pre-processing script' of the menu option of the parent window:


   #
   #   start another display window, passing along information
   #   extracted from the selected entries.
   #
   #   @{{START_DISPLAY_SCRIPT
   
   #
   #   Don't display the menu dialog.
   #
   #   @{{MENU_OPTION_SILENT 
   #
   
   print "\@{{START_DISPLAY_TITLE Child Example\n";
   
   print "\@{{START_DISPLAY_NEW\n";
   
   print "\@{{START_DISPLAY_TILED\n";


To Identify the Child Window...

The following comment is added to the main 'Pre-processing' script to identify the display window as the one required. In the example below, the phrase "Child Example" is variable text to identify this particular window. The same text is used in the "\@{{START_DISPLAY_TITLE" output initiated by the (M) Pre-processing script in the menu option of the parent window.


   #
   #   @{{AUTOSTART_DISPLAY_TITLE Child Example
   #
   


To Pass Parameters from the Parent to the Child Window...

The following code added to the Parent menu option, in the (M) Pre-processing script, passes parameters to the child window using data from the selected entry in the parent window.

In this example, fields AA and AB of the selected entry in the parent window are sent to the child window:


   print "\@{{START_DISPLAY_PARAM AA $SelectedEntry{0}{AA}\n";
   print "\@{{START_DISPLAY_PARAM AB $SelectedEntry{0}{AB}\n";
   

This will cause the variables $INPUT_AA and $INPUT_AB to be defined in the Main Windows Agent script of the child window.

In UNIX agent scripts - access the Korn shell variables as ${INPUT_AA} and ${INPUT_AB}.

In VMS agent scripts - access the DCL logical names as INPUT_AA and INPUT_AB.


To Determine which Agents Should be Started in the Child Window...

The parent window can define which agents should be used when starting the child window. For example, if the same agents should be used by the child as are selected in the parent window, then the following code needs to be added to the menu option of the parent and in the startip initialize script of the child:

In the (M) Pre-processing script of the parent menu option:


   use Sysgem;
   
   #
   #  Pass the server list to the child window via a temporary file
   #
   my $path = "";
   
   Sysgem::GetApplicationPath("Sysgem AG", "TempFiles", $path);
   
   my $FilePath = $path . "\\Temp_SV_File.txt";
   
   my @servers = map $SelectedEntry{$_}{"SV"}, sort keys %SelectedEntry;
   
   open(SVRS, "> $FilePath") || die "Can't open $FilePath - $!\n";
   
   print SVRS join("\,", @servers) . "\n";
   
   close(SVRS);
   
   


In the startup Initialize script of the child:


   use Sysgem;
   
   #
   #  Open the selected server list from the parent window via a temporary file
   #
   my $path = "";
   
   Sysgem::GetApplicationPath("Sysgem AG", "TempFiles", $path);
   
   my $FilePath = $path . "\\Temp_SV_File.txt";
   
   open(SVRS, "< $FilePath") || die "Can't open $FilePath - $!\n";
   
   my @servers = <SVRS>;
   
   close(SRVS);
   
   print "\@{{LOAD_SERVERS $servers[0]\n";    # to preselect the same servers as those selected in the parent window
   
   print "\@{{LOCK_SERVERS\n";                # to force these and only these to be used