ACCEPT

<< Click to Display Table of Contents >>

Navigation:  Gekko User Manual > Gekko statements >

ACCEPT

Previous pageReturn to chapter overviewNext page

ACCEPT is used to show a dialog box in Gekko, where a scalar value can be input. See also PAUSE.

 


 

Syntax

 

ACCEPT  type  variable  message;

 

type

Choose between val, date or string. For string type, you do not need to enclose the input (in the dialog box) in quotes.

variable

The name of the variable

message

Text string to be displayed. You can use \n to insert a new line.

 

 


 

Examples

 

The statement may contain text inside single quotes:

 

accept string %'Variable name';
accept string %'Label';
accept date %'Date';
accept val %'Value';
create {%n}; //if it does not exist
doc {%n} label = %s;
{%n}[%d] = %v;
disp <%d-%d+1> {%n};

 

The four ACCEPT-input might be the following:

 

'Input variable name' --> vat

'Input label --> Value added tax

'Input date' --> 2016

'Input value' --> 0.25

 

This will create the series vat, with the label 'Value added tax', and the value 0.25 in 2016.

 

If you need to accept list items, you may accept them as a comma-separated string, and afterwards use the split() function to split the string into a list of strings.

 

To control program flow dynamically depending upon user input, you may use code like the following:

 

accept string %yesno 'Do you want to proceed? (y/n, default: n)';
if(%yesno == 'y');
  tell 'proceeding...';
  //program continues
else;
  tell 'aborting...';
end;

 

A dialog box is shown, and if the user just presses [Enter], %yesno will be an empty string, and the program does not proceed. The program only proceeds when the user inputs y or Y (Gekko string comparisons are case-insensitive).

 


 

Related statements

 

EXIT, IF, PAUSE, RETURN, STOP