Displays a parameter input error box for an Xcos block
block_parameter_error(inform, expected)
inform: | a string, type of error |
---|
:
The goal of this function is to give a precise information to an user on his error when he inputs a block parameter. The user information is displayed on two lines provided respectively by the parameters:
`msprintf`_(`gettext`_("Must be in the interval %s."), "[3, 8]")
The example below is a simple use case for the function. The user inputs a value in the parameter dialog box. If the value is not valid, the example displays this error box:
`loadXcosLibs`_ // Useless in Xcos block programming context
ok = %f;
while ~ok do
// Input the parameter
[Datatype] = `x_mdialog`_( ..
"Parameter input", ..
"Data Type (3:int32, 4:int16, 5:int8, ...) ?", ..
"3" ..
);
if `isempty`_(Datatype) then // Cancel or Ok ?
break;
else
Datatype = `evstr`_(Datatype);
end
// Test 'Data Type' parameter and displays error box if necessary
if Datatype < 3 | Datatype > 8 then
block_parameter_error( ..
`msprintf`_("Wrong values for ''Data Type'' parameter: %d.", Datatype), ..
`msprintf`_("Must be in the interval %s.", "[3, 8]") ..
);
ok = %f;
else // Parameter is valid, continue the job
ok = %t;
`print`_(%io(2), "Data Type parameter is valid");
end
end