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