setvalueset function

Discussions about editing and cleaning data
Forum rules
New release: CSPro 8.0
Post Reply
becklesd
Posts: 14
Joined: June 11th, 2012, 5:25 pm

setvalueset function

Post by becklesd »

Does the setvalueset function in its Format 2 form:
setvalueset(item-name | @alpha_expr, numeric-array | alpha-array, alpha-array);
work in batch edit applications?
In the following, F2 is a field that has one value set containing the single value 0. The following code fails:
PROC GLOBAL
array codes(4);
array alpha(10) labels(4);
PROC F2
preproc
codes(0) = 1;
codes(1) = 2;
codes(2) = 3;
codes(3) = notappl; { mark end of array }
labels(0) = "Value 1";
labels(1) = "Value 2";
labels(2) = "Value 3";
setvalueset(F2, codes, labels);
$ = 2;
errmsg("invalueset(%d)=%d", $, invalueset($));

The output is invalueset(2)=0, which is surely incorrect.
Has anyone else had this problem? Can setvalueset be used in this way in a batch application? If not, is there a workaround?

Thanks,
Beckles
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: setvalueset function

Post by Gregory Martin »

This actually isn't just a problem in batch applications. It also occurs in data entry applications. If you read the help document on invalueset, it says this:
The valueset-name is the name of a value set with the specified item. If the value set name is omitted, the first value set for the item is used.
So it actually never uses the "current" value set, which is defined by the setvalueset function. By design it always will check against the first value set in your dictionary.

I think that we may want to change this behavior for the upcoming 5.0 release, so that the default behavior is not to check against the first value set but instead to use the current value set, which will always be the first value set unless setvalueset was called.
Gregory Martin
Posts: 1777
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: setvalueset function

Post by Gregory Martin »

We've changed this behavior so now invalueset will use whatever the "current" value set is, which will be the first value set until you change it by calling setvalueset. This fix will come out in the beta release this week, or you can wait until the final release of CSPro 5 in July.
becklesd
Posts: 14
Joined: June 11th, 2012, 5:25 pm

Re: setvalueset function

Post by becklesd »

I have tried it in the 5 Beta version and it works as you have described.
Thank you.
BecklesD
Post Reply