共有スクリプトについて
共有スクリプト・ファイル、uf_sy420_rts.jsを使用して、すべての5250画面スクリプトからアクセスできる共通のJavaScriptプロパティおよびファンクションを保管できます。
通常、このファイルはRAMP-TSのskinsフォルダに保管されます。ただし、このファイルのプライベート・バージョンは、指定したプライベート定義フォルダにも配置できます(「RAMP-TSAD05 ステップ1. オプション - 共有スクリプト・ファイルのユーザー独自のコピーを作成する」を参照してください)。
共有スクリプト・ファイルについて確認するには、以下を実行します。
1. Windowsエクスプローラで、\axes\ts\skinsフォルダにアクセスできるようにマッピングされたドライブを設定します。
2. メモ帳またはテキスト・エディターを使用し、uf_sy420_rts.jsファイルを見つけて開きます。次のように表示されます。
/* ================================================================================== */
/* 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 */
このファイルの構造は以下に示すように簡素です。
· var SHARED =の行は、SHAREDという名前のJavaScriptオブジェクトの始まりを定義します(SHAREDという名前を使用する必要があります)。
· SHAREDオブジェクト内には、myProperty1とmyProperty2という2つのプロパティがあります。
· また、それぞれが3つおよび2つのパラメータを受け取るmyFunction1とmyFunction2という2つのファンクションがあります。
これらのプロパティとファンクションは、SHAREDオブジェクト内で定義される方法を示す以外に何も機能はありません。特に、コンマを使用してファンクションを区切ることを示しているコメントに注意してください。
このオブジェクト・フォーマットは純粋なJavaScriptです。これは、RAMP独特のものではありません。
この技術を使用して、他と競合しないコード用に保持されたnamespaceを作成します。