Single select and multi-language from lookup file (external excel file)

Discussions about CSEntry
Post Reply
Bonobono
Posts: 1
Joined: July 2nd, 2019, 5:26 am

Single select and multi-language from lookup file (external excel file)

Post by Bonobono » July 2nd, 2019, 5:29 am

Hello.

I have two questions related with lookup file.

1. Dynamic value set from a lookup file is working well when it is ran on computer, but it is not working well on tablet application (province and district values are not popped up). How can I solve it?

2. I want to make two versions of dynamic value set, English and Laotian. I want to use different external files depend on languages. For example, I want to show English names province and district to interviewee at English version. On the other hand, I want to show Laotian names province and district to interviewee at Laotian version. I noticed that logic is same even language are changed. So, how I can do?

Thanks.
Attachments
Questions.zip
(111.37 KiB) Downloaded 19 times

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

Re: Single select and multi-language from lookup file (external excel file)

Post by aaronw » July 3rd, 2019, 4:51 pm

My first though is you're not deploying the lookup files. Make sure they exist on Android and I think the dynamic value sets will work.

The logic that your have written to create the dynamic value set references PROVINCE_CODES_DICT and DISTRICT_CODES_DICT which are associated with the English data files PROVINCE.csdb and DISTRICT.csdb. Switching languages is not going to affect this. However, you can call the function getlanguage() which in your case will return "EN" or "LAO." Use this return value to write an if else statement, that either runs your dynamic value set logic that references the English or Laotian dictionaries.
onfocus

numeric
nextEntry = 1;

if getlanguage() = "EN" then

    forcase
PROVINCE_CODES_DICT do
       
codes(nextEntry) = PROVINCE_NO2;
       labels(nextEntry) = PROVINCE3;
       nextEntry = nextEntry +
1;
   
enddo;

else

    forcase
LAO_PROVINCE_CODES_DICT do
       
codes(nextEntry) = LAO_PROVINCE_NO;
       labels(nextEntry) = PROVINCE_LAOTIAN;
       nextEntry = nextEntry +
1;
   
enddo;

endif;

codes(nextEntry) =
notappl;
setvalueset(PROVINCE, codes, labels);
This solution requires a bit of code duplication and duplicate dictionaries (English and Laotian version). I would instead have one dictionary for the provinces and another for the districts, but then have an English and Laotian data file for each. In my if else statement I would call the setfile function to associate the dictionary with the appropriate data file.
onfocus

if getlanguage
() = "EN" then
    setfile
(PROVINCE_CODES_DICT, "./PROVINCE.csdb", update);
else
    setfile
(PROVINCE_CODES_DICT, "./LAO_PROVINCE.csdb", update);
endif;

numeric nextEntry = 1;
forcase PROVINCE_CODES_DICT do
   
codes(nextEntry) = PROVINCE_NO2;
   labels(nextEntry) = PROVINCE3;
   nextEntry = nextEntry +
1;
enddo;

codes(nextEntry) =
notappl;
setvalueset(PROVINCE, codes, labels);

Post Reply