@getsymbol() as dynamic dictionary symbol

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
htuser
Posts: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

@getsymbol() as dynamic dictionary symbol

Post by htuser »

Dear CSPro Developer Team,
I already wrote you several times 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,
Last edited by htuser on March 11th, 2023, 12:15 pm, edited 1 time in total.
G.VOLNY, a CSProuser from Haiti, since 2004
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: @getsymbol() as dynamic dictionary symbol

Post by aaronw »

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: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: @getsymbol() as dynamic dictionary symbol

Post by htuser »

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,
G.VOLNY, a CSProuser from Haiti, since 2004
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: @getsymbol() as dynamic dictionary symbol

Post by aaronw »

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: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: @getsymbol() as dynamic dictionary symbol

Post by htuser »

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?
G.VOLNY, a CSProuser from Haiti, since 2004
aaronw
Posts: 561
Joined: June 9th, 2016, 9:38 am
Location: Washington, DC

Re: @getsymbol() as dynamic dictionary symbol

Post by aaronw »

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: 631
Joined: December 19th, 2011, 6:26 pm
Location: Silver Spring Area, MD, USA

Re: @getsymbol() as dynamic dictionary symbol

Post by htuser »

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,
G.VOLNY, a CSProuser from Haiti, since 2004
Post Reply