User input script

The text of the full script of chapter 3d is:

 

function Get_user_input_via_dialog() {

 

var dialog = new Dialog;

dialog.title = "Data of experiment";

dialog.okButtonText = "Done";

dialog.cancelButtonText = "Cancel";

dialog.width = 350;

 

var nameEdit = new LineEdit;

nameEdit.label = "Subject name: ";

dialog.add(nameEdit);

 

var expEdit = new LineEdit;

expEdit.label = "Experiment name: ";

dialog.add(expEdit);

 

var expTypeBox = new ComboBox;

expTypeBox.itemList = ["fMRI", "PET", "EEG"];

expTypeBox.label = "Select the type of experiment";

dialog.add(expTypeBox);

 

var nameInput;

var expInput;

var detailsInput;

var expTypeInput;

 

// launch the dialog

if( dialog.exec() ) {

nameInput = nameEdit.text;

expInput = expEdit.text;

detailsInput = detailsEdit.text;

expTypeInput = expTypeBox.currentItem;

}

 

// do something with the user input

var displayInfo = "EXPERIMENT DATA<P> Subject name: '" + nameInput + "'<BR> Experiment name: " + expInput;

displayInfo += "; <BR> Type of experiment: '" + expTypeInput + "'";

displayInfo += "; <P> Experiment details: '" + detailsInput + "'";

 

MessageBox.information(displayInfo);

}