Code works on 6.3 but does not work on 7.02

Discussions about CSEntry
Forum rules
New release: CSPro 8.0
Post Reply
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Code works on 6.3 but does not work on 7.02

Post by Yass »

Dear CSPro,
I have this line of codes that check IDs from an external file in a .dat format
Proc IntID
XCODE = $;
if !loadcase(INTERW,XCODE) then
errmsg(001,IntID);
reenter;
endif;

Any ID I enter in Proc IntID either it wrong or write , I still have the error message 001 in the 7.02 but this work fine in 6.3.
Pls help.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Code works on 6.3 but does not work on 7.02

Post by josh »

Make sure you are not calling close() on the external dictionary (INTERW) in your application. In 6.3 loadcase would automatically reopen the file after a call to close but in 7.0 it does not. Other than that the behavior should be the same.
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Code works on 6.3 but does not work on 7.02

Post by Yass »

Thanks Josh,

I have this external file that i have assigned teams to a cluster. Can I use this external file to set values for the Clusters based on InterID. Find attached QTest. I have search the forum i can see a similar example. For example if I enter Interviewer ID 203 then CLUSTER will set values
5222 Hankai
4353 H3 Avenu etc.
This values are coming from the external file. I have tried severally i cant figure it out. Please help!!

Thanks for prompt response
Attachments
QTest.zip
(12.58 KiB) Downloaded 279 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Code works on 6.3 but does not work on 7.02

Post by josh »

The test application you sent is working fine for me with version 7.0.2. It doesn't give an error message for ids that are not in the lookup file.

To fill in the fields from the lookup file you just need to assign them from the lookup file dictionary to the main dictionary after the loadcase. For example:

Code: Select all

CLUSTER_NUMEBR = CLUSTER;
QTEST_DICT.TAB_CODE = SHEET1_DICT.TAB_CODE;
Not that in the second line since the variable name is the same in both dictionaries you have to use the dictionary name followed by a . to differentiate. To avoid this I usually recommend using different names for the variables in each dictionary.
Yass
Posts: 103
Joined: November 11th, 2017, 1:26 am

Re: Code works on 6.3 but does not work on 7.02

Post by Yass »

Thanks Josh, the help i want i did not explain well.

I will like to use the ID keyed to set the values to be selected in CLUSTER
I was trying something like this but got lost with it:

preproc
numeric i xCluster,xTeam,k,xcode;
xTeam=INTERVIEWER_ID/10;
do i = 2 while i <= 5
xTeam=INTERVIEWER_ID/10;
k= loadcase(SHEET1_DICT,INTERV);

xcode(i-1) = xTeam;

enddo;

setvalueset(CLUSTER_NUMEBR, XTEAM);

endif;

There is variable in the external called "assigned " which has a relationship with Interv code in the external file.
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: Code works on 6.3 but does not work on 7.02

Post by josh »

I'm still not sure what are you trying to do exactly. I understand that you want to create a dynamic value set for CLUSTER based on the INTERVIEWER_ID and the lookup file. I don't understand the criteria you want to use to determine which clusters are to be put in the dynamic value set. Specifically how does ASSIGNED relate to INTERVIEWER_ID?

Generally to create a dynamic value set you need to declare two arrays in your proc global: one for the codes and one for the labels.

Code: Select all

PROC GLOBAL
array codes(99);
array string labels(99);
Then in the onfocus proc of CLUSTER_NUMEBR you need to fill in these two arrays and then pass them to setvalueset. Filling them in usually involves a loop of some kind. Calling setvalueset is just:

Code: Select all

setvalueset(CLUSTER_NUMEBR, codes, labels);
For details and examples see the following http://teleyah.com/cspro/SouthAfricaOct2016/05-CAPI.pdf

So the missing piece is how to fill in the arrays but in order to do that you need to explain how to pick the clusters to go into the value set based on the INTERVIEWER_ID.
Post Reply