Idea ID: 2874838

Enhancement to lr_paramarr_random function

Marius Brecher Marius Brecher
Status : Waiting for Votes

Many times we find it necessary to capture multiple variables from within the same request, each using its own array.

We then use the lr_paramarr_random function to randomize a selection, but have to use a loop in order to assign the same index value to the rest of the variables required.
Would it be possible for you to create an additional variable returned for lr_paramarr_random request that will return the index selected and not just the value within the array??? something similar to the xx_xx_count option, that will return the selected index..... i.e. xx_xx_IDX.



    There can be made many tiny convenient functions. But those might also be easily created yourself. What you are requesting can be expressed like e.g.

    #define my_paramarr_random_idx(P) (lr_paramarr_len(P)>=0 ? rand()%(lr_paramarr_len(P))+1 : lr_paramarr_len(P))

    It returns a random index number for parameter P or a value <= 0 when lr_paramarr_len() returns that value.

    The same kind of issues we have when we like to have a random value between X and Y. We have only a random parameter or rand() function. With the parameter we need to apply atoi(lr_eval_string()). There is no 'int lr_eval_int()' function.

    I think that development effort can be better put into more complex things than saving an a few key strokes.

    How to ask questions

    Reward contributions via likes or 'verified answers'