私はこのようなテーブルを持っています。私がしたいのは、「カップの色」列で一意の値を検索し、ユーザーが一意のカップの色ごとに対応するフレーバーを入力するためのポップアップ ウィンドウを表示することです.. .
| カップの色 | カロリー | 味 | ランキング | テスター |
| 青 | 140 | 4 | 2 | 1 |
| 緑 | 80 | 7 | 1 | 4 |
| 黄色 | 200 | 2 | 3 | 6 |
| 紫 | 130 | 3 | 6 | 4 |
| 青 | 140 | 3 | 5 | 2 |
| 青 | 140 | 4 | 4 | 3 |
| 黄色 | 200 | 5 | 7 | 1 |
カップの色ごとにフレーバーが決まったら、ユーザーからの入力に基づいて入力される新しい列を追加したいと思います。
| カップの色 | カロリー | 味 | ランキング | テスター | フレーバー |
| 青 | 140 | 4 | 2 | 1 | チェリー |
| 緑 | 80 | 7 | 1 | 4 | ラズベリー |
| 黄色 | 200 | 2 | 3 | 6 | チョコレート |
| 紫 | 130 | 3 | 6 | 4 | 本当にミント |
| 青 | 140 | 3 | 5 | 2 | チェリー |
| 青 | 140 | 4 | 4 | 3 | チェリー |
| 黄色 | 200 | 5 | 7 | 1 | チョコレート |
私はまだJSLにかなり慣れていないので、ここ数時間フォーラムを調べてガイダンスを探していましたが、これをつなぎ合わせることができないようです。少し助けていただければ幸いです。
モーダル ウィンドウの使用は、非常にユニークな種類のウィンドウです。従わなければならないルールがいくつかあります。そのうちの 1 つは、「OK」というテキストを含むボタン ボックスを含みます。モーダルウィンドウに特別な機能があります。したがって、それらを使用することはできますが、それらについて学習し、それらを使用して練習する必要があります。
私の好みは、モーダル ウィンドウを使用するのではなく、Functions() または Expr() 要素を使用してコードをカプセル化し、スクリプトが実行する必要があることを示すまで実行されないようにすることです。以下は、その方法の簡単な例です。
Names Default To Here( 1 );
// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );
// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i <= N Items( colorList ), i++,
Insert Into( flavorList, "" )
);
// Create the display window
nw = New Window( "Select Flavors",
//<< Modal,
Text Box( "Enter in Flavors for each Color" ),
tb = Table Box(
String Col Box( "Colors", colorList ),
scb = String Col Edit Box( "Flavors", flavorList )
),
Button Box( "OK",
nw << close window;
// Create the flavor table and update it to
// the original table
dt2 = New Table( "combined",
New Column( "Cup Color", character, set values( colorList ) ),
New Column( "Flavors", character, set values( flavorList ) )
);
dt << Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
close( dt2, nosave );
runAdditionalCodePlease;
)
);
// Set the String Col Edit Box action
scb << Set Function( Function( {this, which}, flavorList[which] = scb << get( which ) ) );
runAdditionalCodePlease = Expr(
Dialog("This represents the kind of things that",
"you may want to run after the data entry.",
"By placing the code inside an Expr() or in",
"a Function(). The code will be run only",
"when executed within the code."
)
);実際には、スクリプトが進行する前にユーザー入力を待機する必要があります。
スクリプト ガイドで、モーダル メッセージを使用してこれを実行できることがわかり、正しく追加されたと思いましたが、スクリプトを実行しても、テーブルが更新されません。ログには、「Name Unresolved: Button in accessまたは 'Button' の評価、Button( 1 ) /*####*/"
// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );
// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i <= N Items( colorList ), i++,
Insert Into( flavorList, "" )
);
// Create the display window
nw = New Window( "Select Flavors",
<< Modal,
Text Box( "Enter in Flavors for each Color" ),
tb = Table Box(
String Col Box( "Colors", colorList ),
scb = String Col Edit Box( "Flavors", flavorList )
),
Button Box( "OK",
nw << close window;
// Create the flavor table and update it to
// the original table
dt2 = New Table( "combined",
New Column( "Cup Color", character, set values( colorList ) ),
New Column( "Flavors", character, set values( flavorList ) )
);
dt << Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
close( dt2, nosave );
)
);
// Set the String Col Edit Box action
scb << Set Function( Function( {this, which}, flavorList[which] = scb << get( which ) ) );コミュニティへようこそ。
まず、JSL の学習をスピードアップする方法について提案があります。
スクリプトガイドを読んでください!!!!
で入手できます
ヘルプ==>書籍==>スクリプト ガイド
以下は、あなたが要求したことを達成するためのベアボーン スクリプトです。
Names Default To Here( 1 );
dt = New Table( "Untitled 2",
Add Rows( 7 ),
New Column( "Cup Color",
Character,
"Nominal",
Set Selected,
Set Values( {"blue", "green", "yellow", "purple", "blue", "blue", "yellow"} )
),
New Column( "Calories",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [140, 80, 200, 130, 140, 140, 200] )
),
New Column( "Taste",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [4, 7, 2, 3, 3, 4, 5] )
),
New Column( "Ranking",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [2, 1, 3, 6, 5, 4, 7] )
),
New Column( "Tester",
Numeric,
"Continuous",
Format( "Best", 12 ),
Set Values( [1, 4, 6, 4, 2, 3, 1] )
)
);
// Get the list of unique colors
Summarize( dt, colorList = by( :Cup Color ) );
// Initialize the flavor list and make it the same
// length as the colorList
flavorList = {};
For( i = 1, i <= N Items( colorList ), i++,
Insert Into( flavorList, "" )
);
// Create the display window
nw = New Window( "Select Flavors",
Text Box( "Enter in Flavors for each Color" ),
tb = Table Box(
String Col Box( "Colors", colorList ),
scb = String Col Edit Box( "Flavors", flavorList )
),
Button Box( "OK",
nw << close window;
// Create the flavor table and update it to
// the original table
dt2 = New Table( "combined",
New Column( "Cup Color", character, set values( colorList ) ),
New Column( "Flavors", character, set values( flavorList ) )
);
dt << Update( With( dt2 ), Match Columns( :Cup Color = :Cup Color ) );
close( dt2, nosave );
)
);
// Set the String Col Edit Box action
scb << Set Function( Function( {this, which}, flavorList[which] = scb << get( which ) ) );