@getsymbol() as dynamic dictionary symbol

Discussions about CSEntry
Post Reply
htuser
Posts: 415
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

@getsymbol() as dynamic dictionary symbol

Post by htuser » September 18th, 2019, 4:40 pm

Dear CSPro Developer Team,
I already write you several's time about the request of dynamic dictionary symbol for multiples CSPro functions(getlabel, invalueset etc). Right now, i see setvalueset accept @getsymbol().
but, preceded by the @ symbol, it can also be a string expression that evaluates to the name of an item; for example:
setvalueset(@getsymbol(),MY_VALUESET_VS1);
Please can i use this for other CSPro functions?

Thanks in advance,

aaronw
Posts: 208
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: @getsymbol() as dynamic dictionary symbol

Post by aaronw » September 20th, 2019, 9:46 am

Thanks for the feedback. It would be beneficial to include a simple explanation/example of why this is needed. For example, because of x, y, and z I regularly run into an issue where I need to call getlabel, but don't know the dictionary symbol at compile time.

The more common the use case is, the more compelling the argument is. If it's an obscure use that only adds a bit of convenience, for example, then we'll probably not add the functionality in the future. Our goal is to keep CSPro logic simple to use, but also powerful.

htuser
Posts: 415
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: @getsymbol() as dynamic dictionary symbol

Post by htuser » September 20th, 2019, 11:11 am

Dear Aaron,
We would like to have ability to use alias when we don't know the dictionary symbol at compile time. For example in user defined functions.
I already mentioned it in multiples mails sent to you, right now, several's CSPro functions doesn't accept dictionary symbol in user defined functions.
This avoid us designed more powerful and dynamic user defined functions. So, it's important to solve this by allow us to use dynamic dictionary symbol as it's right now with @getsymbol() in setvalueset.

Another example is autocomplete, that i requested. When we must process other in multiple response question, usually we must deal with responses that are synonyms but written differently by enumerators differently. To process theses words, but synonym we're obliged to clean, aggregate etc. Often it's very time consuming.
For HA6_10_AUTR_SOURCE_LUMIERE (OTHER) we have response


LAMP A GAZ
LAMP A KEROSENE
LAMP AGAZ
LAMP CHEMINE
LAMP CHEMINYE
LAMP CHEMINYE, FLACH
LAMP CHINYE
LAMP E KEROSENE
LAMP GAZ KEROZENE
LAMP KEROSENE
LAMP KEROZEN
LAMP KEROZENE
LAMP TET GRIDAP
LAMP TETE GRIDAPE
LAMP TETE GRITAPE

that are equal to LAMPE KEROZENE.

Having good autocomplete functions will allow to minimize errors.

Best Regards,

aaronw
Posts: 208
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: @getsymbol() as dynamic dictionary symbol

Post by aaronw » September 20th, 2019, 5:07 pm

Let's stick to one feature request at a time. I understand you'd like to write user defined functions where the dictionary symbol isn't known till run time. Sticking with the getlabel example, what is your custom function going to do?
function CustomGetLabel( {paremeter-list...} )
    // ...
   
string label = getlabel(@getsymbol());
    //...
end;

htuser
Posts: 415
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: @getsymbol() as dynamic dictionary symbol

Post by htuser » September 20th, 2019, 5:23 pm

Hi Aaron, an example already sent to you is:
function string labelCheckbox (string itemName, array string responseArray)
// it's used to display label for multiple response checkbox. Thanks to Josh, years ago.
string allvalue = "";  
do ctr = 2 while ctr <= length (responseArray)
     
if (pos(responseArray(ctr),itemName)) <> 0 then
            if length
(allvalue) > 0 then
           
allvalue = allvalue + "/";
       
endif;
              allvalue = allvalue +
getlabel(itemName, responseArray(ctr));
   
endif;
enddo;
labelCheckbox=allvalue;
end;
where i'm trying to transform this for checkbox label in a function. This would be used to display checkbox results in HTML printing format questionnaire (see attachements examples in your email).

This function isn't fully complete. I must transform checkbox response to list or array, who's easy right now with latest list or array object. So, responseArray may be also responseList.

The @getsymbol() would replace itemName.

What do you think about?

aaronw
Posts: 208
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: @getsymbol() as dynamic dictionary symbol

Post by aaronw » September 20th, 2019, 10:24 pm

Alright, so your custom function converts checkbox selections to their value set label and appends it to a string. Allowing you to conveniently display the check box selections in another question's CAPI text (or similiar).

Now if I put it all together, your feature request looks like this:
I would like to request that the CSPro functions (getlabel and invalueset) take a string argument that evaluates to the name of an item like setvalueset. Using getlabel as an example, it would allow me to create a custom function that converts checkbox selections to their value set labels and append it to a string. I regularly need to display the value set labels for a check box's selections in CAPI text questions, so this new feature would increase the re-usability of my logic while reducing the lines of logic in my application. Here's an example of it in use:
function string labelCheckbox (string itemName, array string responseArray)
    // it's used to display label for multiple response checkbox. Thanks to Josh, years ago.
   
string allvalue = "";
   
do ctr = 2 while ctr <= length (responseArray)
       
if (pos(responseArray(ctr),itemName)) <> 0 then
            if length
(allvalue) > 0 then
               
allvalue = allvalue + "/";
           
endif;
            allvalue = allvalue +
getlabel(itemName, responseArray(ctr));
       
endif;
   
enddo;
    labelCheckbox=allvalue;
end;
This feature request makes it clear what you want and why. Which makes it easy for us to discuss and prioritize.

htuser
Posts: 415
Joined: December 19th, 2011, 6:26 pm
Location: HAITI

Re: @getsymbol() as dynamic dictionary symbol

Post by htuser » September 21st, 2019, 12:16 pm

Thank you Aaron for let me know that i must give you clear explanation for accepting and prioritize a request. Hope, among others, dynamic dictionary symbol and convenient autocomplete will be on your
to do list
soon.

Best Regards,

Post Reply