ユーザー入力を検証し、ユーザーが必須フィールドに入力していない場合にユーザーが入力UIを渡さないようにします。これまでのところ、ボタンボックスは実際にはスクリプトを順番に実行しません。あるいは、スクリプト全体が終了するまで変数を格納しているようには見えません。どうすればこれを回避できますか。
clearLog();
clearGlobals();
clearSymbols();
dt = currentDataTable();
inputGUI = newWindow( "Input Selection UI", << modal,
//Step Name input box
hListBox(
textBox("1. Enter some text input"),
stepTextEdit = textEditBox(),
),
//Column Section input box
hListBox(
vListBox(
choosesrc=filterColSelector( nLines( 6 ) ),
chooseSRC << numeric( 0 ),
),
vListBox(
lineUpBox( nCol( 1 ), spacing( 2 ),
buttonBox( "Add Column >>",
listcols2 << Append( chooseSRC << getSelected );
),
buttonBox( "<< Remove Column",
listcols2 << removeSelected;
),
),
),
vListBox(
listcols2 = colListBox( nLines( 3 ), minItems(1), maxItems(1) ), //col list box with no columns inside
);
),
//Footer Section and OK/Cancel Buttons
hListBox(
buttonBox("OK",
//Collect all variables from input boxes
uinp_stepName = stepTextEdit << getText;
uinp_colssrc=listcols2 << getItems;
// Input Validation Logic
if ( IsMissing(uinp_stepName) == 1,
(nw_error_uinp_stepName = New Window("Error ", << Modal,
VList Box(
Text Box("Text input is missing"),
HList Box(
Button Box ( "OK" ),
),
);
);
break(); // Only send 1 error at a time
)
);
if ( nItems(uinp_colsSRC) == 0,
(nw_error_uinp_colssrc=New Window("Error ", << Modal,
VList Box(
Spacer Box( Size (5, 5) ),
Text Box("Column input is missing"),
Spacer Box( Size (15, 15) ),
HList Box(
Button Box ( "OK" ),
),
);
);
break(); // Only send 1 error at a time
)
);
),
buttonBox("Cancel", Print("User cancelled operation!"); Stop() ),
),
);また、この目的のインラインメッセージ<< On Validate(expression)to New Window()も参照してください。
順不同で何かを評価しているとは思わない。問題は、そのfilterColSelectorオブジェクトをコンマで区切って1行に変更しようとしていることです。 コンマは、その垂直リストボックス内にネストされているさまざまな表示オブジェクトを区切るためのものです。 そのコードスニペットをこれと交換してください。
vListBox(
choosesrc=filterColSelector( nLines( 6 ), << numeric( 0 ))
)
*また、そのvListBoxに他に何か追加する予定があるかどうかはわかりませんが、表示ボックスが1つしかないため、削除することができます。