What are Shared Scripts

RAMP-TS

What are Shared Scripts?

The shared scripts file uf_sy420_rts.js can be used to store common JavaScript properties and functions that can be accessed from all your 5250 screen scripts.

This file is normally stored in the RAMP-TS skins folder. However, a private version of the file can also reside in the nominated Private Definitions Folder (see RAMP-TSAD05 Step 1. Optional - Creating Your Own Copy of the Shared Scripts File ).

To see what the shared scripts file is like:

1.   In Windows Explorer set up a mapped drive so that you can access folder \axes\ts\skins.

2.   Using Notepad or a text editor locate file uf_sy420_rts.js and open it. It looks like this:

/* ================================================================================== */
/* Note that this file is used when using RAMP-TS as the RAMP 5250 server             */
/* ================================================================================== */

/* This file is for common JavaScript properties and functions you want to access     */
/* from all your 5250 screen scripts. To provide an unlimited name space your         */ 
/* properties and functions MUST be encapsulated inside an object named SHARED        */
/* Typically is reside in the \axes\ts\skins folder                                   */

/* ---------------------------------------------------------------------------------- */
/* The SHARED object contains all customer defined shared scripts and properties      */
/* ---------------------------------------------------------------------------------- */

var SHARED = 
{

   /* ----------------------------------------------- */ 
   /* Properties defined as part of the shared object */  
   /* ----------------------------------------------- */ 

   myProperty1 : "a",
   myProperty2 : 42, 

   /* ----------------------------------------------- */ 
   /* Functions defined as part of the shared object  */  
   /* ----------------------------------------------- */ 

   /* myFunction1 is a test function */

   myFunction1 : function(a,b,c)
   {
      alert("myFunction1 executed with parameters " + a.toString() + " " + b.toString() + " " …. etc
      return;
   }, /* <======= Note the comma =========== */ 

   /* myFunction2 is another test function */
   
   myFunction2 : function(a,b)
   {
      var sResult = "myFunction2 was executed with parameters " + a.toString() + " " + b.toString();  
      return(sResult);
   }, /* <======= Note the comma =========== */ 

   /* Dummy last property that does not have a comma, leave here. All preceeding definitions use a comma */
   
   myEndProperty : true          

}; /* End of SHARED object definition */

 

The structure of this file is simple:

  • The line  var SHARED =  defines the start of a JavaScript object named SHARED (you must use the name SHARED).
  • Within the SHARED object are 2 properties named myProperty1 and myProperty2.
  • There are also 2 functions called myFunction1 and myFunction2 that receive 3 and 2 parameters respectively.

These properties and function serve no purpose other than to demonstrate how they are defined inside the SHARED object. Note especially the comments indicating the use of commas to separate the functions.

This object format is pure JavaScript. It is not unique to RAMP.

By using this technique you will create a preserved namespace for your code that will never conflict with anything else.