Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

If the action required some input from the user via the Screen Script, the values are placed in the argv variable. This is a string array containing ordered sequences of label and value(s) for the fields shown on the screen.

For single value fields, the array contains the field label immediately followed by the value entered. For multi value fields, if no value was selected, the label is immediately followed by an empty value. If one or more values were selected, the label is immediately followed by the number of values selected, and the selected values.

In order to help you retrieve the selected value(s) faster, we have created more plugin-specific SIL routines.

CategoryUsed withRoutineReturn value
Single value fieldsTEXT, TEXT_AREA, SELECT_LIST, RADIO_GROUP, SINGLE_CHECKBOX(optional)BA_getSingleValue(argv, label)String representing the value entered or the selected option for the given label. For

...

checkbox it will return "checked" if the checkbox was selected or an empty string otherwise.
Multi value fieldsMULTI_SELECT_LIST, CHECKBOX_GROUPBA_getMultiValues(argv, label)String array representing the selected options.
CheckboxSINGLE_CHECKBOXBA_isChecked(argv, label)Convenience method for checking whether a checkbox is selected or not. Returns a boolean: true if the box was checked, false otherwise.
Note

These methods are only available in versions 1.0.1+ and 2.0.1+

 

For example, take the following Screen Script:

Code Block
return {"My Favorite FruitBA_createCheckboxGroup("checkbox group", {"TEXTo1", "Kiwio2", "Do you like chocolate?"o3"}, {"TEXT_DISABLEDo1", "Of course!o2"}, false);

Assuming the user did not change the default values, the argv variable in the action script will have 4 values: "My Favorite Fruit"checkbox group", "2", "Kiwio1", "Do you like chocolate?", "Of course!".You can retrieve these values using o2". The result of BA_getMultiValues(argv, "checkbox group") would return an array with two values: o1 and o2.

If the user unchecked all the values, the argv variable would have only 2 values: "checkbox group" and an empty string.

You might also use these in conjunction with array-specific routines like arrayGetElement and arrayElementExists. See Array Routines for a list of available routines that manipulate arrays.

...

To do this, you will have to return an array containing pairs of label and error. (similar to what you get in the argv variable). 

Code Block
string fruitLabel = getElement(argv, 0);
string fruit = getElement(argv, 1);

string chocolateLabel = getElement(argv, 2);
string chocolate = getElement(argv, 3);

string [] errors;

if( isNull(fruit) ){
 	errors = addElement(errors, fruitLabel);
	errors = addElement(errors, "What? You don't like fruits?");
}

if( chocolate != "yes" and chocolate != "of course"){
	errors = addElement(errors, chocolateLabel);
	errors = addElement(errors, "No way!");
}

return errors;

...