RPR GetUserInputs
From CockosWiki
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetUserInputs
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetUserInputs
Contents |
GetUserInputs()
bool GetUserInputs(const char* title, int num_inputs, const char* captions_csv, char* retvals_csv, int max_retval_len)
Displays a dialogue box with the specified number of input boxes and their captions. The uesr can enter values in the input boxes and press either OK or Cancel.
Calling this function is easy, interpreting the returned values is a little more difficult.
It doesn't really return just a boolean (true or false) value based on whether the user pressed OK or Cancel. It actually returns an array, the *first element* of which is boolean, the rest of it is the contents of the parameter list - but the captions_csv element of that returned array is what the user types in the boxes - if OK was pressed.
Parameters
Type | Name | Description |
---|---|---|
const char* | title | The title of the dialogue box displayed to the user. |
int | num_inputs | The number of input boxes in the dialogue box. |
const char* | captions_csv | Captions for the input boxes. |
char* | retvals_csv | The default values for the input boxes |
int | max_retval_len | The overall length of the CSV value returned. |
Returns
An array or list, the elements of which are:
Name | Description |
---|---|
boolean value | 1 if user pressed ok, 0 if user pressed cancel |
copy of title | from the parameter list |
copy of num_inputs | from the parameter list |
copy of captions_csv | from the parameters list |
retvals_csv | This is the return value |
copy of max_retval_len | from the parameters list |
Examples
C++
Perl
# # GetUserInput.pl # use strict; use warnings; use constant TITLE => "GetUserInputs"; use constant NUM_INPUTS => 2; use constant CAPTIONS_CSV => "Caption 1,Caption 2"; use constant MAX_RETVAL_LEN => 10; my $retvals_csv = "one,two"; my @response = RPR_GetUserInputs(TITLE, NUM_INPUTS, CAPTIONS_CSV, $retvals_csv, MAX_RETVAL_LEN); RPR_ShowConsoleMsg("retvals_csv $retvals_csv\n"); RPR_ShowConsoleMsg("\n"); RPR_ShowConsoleMsg("response @response\n"); RPR_ShowConsoleMsg("\n"); RPR_ShowConsoleMsg("response[4] $response[4]\n"); RPR_ShowConsoleMsg("\n");
Python
#------------------------------------------------------------------- # get_user_input_example.py #------------------------------------------------------------------- # define msg alias (custom) def msg(m): RPR_ShowConsoleMsg(m+'\n') names = 'in0,in1,in2'; dvalues = '20,21,22'; maxreturnlen = 10; # 10 as per the example above, but really one more than what you expect to get back nitems = len(dvalues.split(',')); # call dialog and get result res = RPR_GetUserInputs('dialogname',nitems,names,dvalues,maxreturnlen); # we get a tuple msg('type is: '+type(res).__name__); # check if res[0] is true ('ok' pressed) if res[0]: # the fourth item holds the input values resvalues = res[4].split(','); # get length of the new array and output all items rvlen = len(resvalues); i=0; while i<rvlen: msg('resvalues['+str(i)+'] = '+resvalues[i]); i+=1; #-------------------------------------------------------------------
See Also
Stuff
Main Page > REAPER Documentation > ReaScript > ReaScript API, Functions > RPR GetUserInputs
Main Page > REAPER Documentation > REAPER API > REAPER API Functions > RPR GetUserInputs