I've got a problem with SetValueSet command, I can't use it in an alpha field. The list of values doesn't show..
That's my code lines...
PROC ALPHAFIELD_ACT1
postproc
if iCantListado>0 then
setvalueset(ALPHAFIELD_ACT1, aCodListado, aListado);
setcapturetype(ALPHAFIELD_ACT1,3);
endif;
set attributes(ALPHAFIELD_ACT1) assisted on;
Note:
- iCantListado has got the items number.
- aCodListado is an alpha array
- aListado is an alpha array
- ALPHAFIELD_ACT1, is alpha field (dictionary)
Thanks in advance,
Hannes
How can I use setvalueset with alphanumeric field? Resolved
How can I use setvalueset with alphanumeric field? Resolved
Last edited by hannesrr on February 5th, 2013, 7:40 pm, edited 1 time in total.
Hannes Rodriguez
Lima, Perú
Lima, Perú
-
- Posts: 1796
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: ¿How can I use setvalueset with a alphanumeric field?
I suspect that there are two problems here:
1) You are executing the code in the postproc of ALPHAFIELD_ACT1. Don't you want to run it before you get to the field?
2) CSPro isn't entirely consistent between when arrays are 0-indexed and when they are 1-indexed. The setvalueset function requires the values to start at position 0. If you don't do this, your array will appear as if it has no values and the setvalueset function will fail.
This should work:
1) You are executing the code in the postproc of ALPHAFIELD_ACT1. Don't you want to run it before you get to the field?
2) CSPro isn't entirely consistent between when arrays are 0-indexed and when they are 1-indexed. The setvalueset function requires the values to start at position 0. If you don't do this, your array will appear as if it has no values and the setvalueset function will fail.
This should work:
aListado(0)="First";
aCodListado(0)="0";
aListado(1)="Second";
aCodListado(1)="1";
aCodListado(2)=""; // end the array
setvalueset(ALPHAFIELD_ACT1, aCodListado, aListado);
aCodListado(0)="0";
aListado(1)="Second";
aCodListado(1)="1";
aCodListado(2)=""; // end the array
setvalueset(ALPHAFIELD_ACT1, aCodListado, aListado);
Re: ¿How can I use setvalueset with a alphanumeric field?
Gregory, thank for your response.
About the first problem, I need to add a new value (by the setvalueset function) after the postproc of ALPHAFIELD_ACT1. Is it posible?
About the second problem, I'll improve my code.
Thank you in advance.
About the first problem, I need to add a new value (by the setvalueset function) after the postproc of ALPHAFIELD_ACT1. Is it posible?
About the second problem, I'll improve my code.
Thank you in advance.
Hannes Rodriguez
Lima, Perú
Lima, Perú
Re: How can I use setvalueset with alphanumeric field? Resol
Gregory, thanks for your inputs, I resolved this problem.
With this code my CSPRO application, add a new value into an alphanumeric array and it allows the user to select a value from the list (by the setvalueset function and the alphanumeric array)
Maybe, this isn't the better way, but it works...
PROC GLOBAL
array alpha(30) aListado(250);
array alpha(3) aCodListado(250);
numeric iCantaListado=0;
function fnAdd_aListado(alpha(30) strNuevoValor) { This function adds a new value into the alphanumeric array (aListado), and calls two functions: fnEsDuplicado() and fnOrdernarArray() }
function fnEsDuplicado(alpha(30) strNuevoItem) {This function determines whether a new value has been entered before.}
function fnOrdernarArray() {This function sorts all the values of alphanumeric array.}
PROC ALPHAFIELD_ACT1
onfocus
if iCantaListado>0 and length($)>0 then
setvalueset($, aCodListado, aListado);
setcapturetype($,4);
endif;
set attributes($) assisted on;
postproc
if length($)=0 then
reenter;
else
if tonumber($) in 0:250 then
$=aListado(tonumber($));
endif;
fnAdd_aListado($);
endif;
Note:
- iCantListado has got the items number.
- aCodListado is an alpha array
- aListado is an alpha array
- ALPHAFIELD_ACT1, is an alpha field (dictionary)
With this code my CSPRO application, add a new value into an alphanumeric array and it allows the user to select a value from the list (by the setvalueset function and the alphanumeric array)
Maybe, this isn't the better way, but it works...
PROC GLOBAL
array alpha(30) aListado(250);
array alpha(3) aCodListado(250);
numeric iCantaListado=0;
function fnAdd_aListado(alpha(30) strNuevoValor) { This function adds a new value into the alphanumeric array (aListado), and calls two functions: fnEsDuplicado() and fnOrdernarArray() }
function fnEsDuplicado(alpha(30) strNuevoItem) {This function determines whether a new value has been entered before.}
function fnOrdernarArray() {This function sorts all the values of alphanumeric array.}
PROC ALPHAFIELD_ACT1
onfocus
if iCantaListado>0 and length($)>0 then
setvalueset($, aCodListado, aListado);
setcapturetype($,4);
endif;
set attributes($) assisted on;
postproc
if length($)=0 then
reenter;
else
if tonumber($) in 0:250 then
$=aListado(tonumber($));
endif;
fnAdd_aListado($);
endif;
Note:
- iCantListado has got the items number.
- aCodListado is an alpha array
- aListado is an alpha array
- ALPHAFIELD_ACT1, is an alpha field (dictionary)
- Attachments
-
- selectvalue.jpg (33.24 KiB) Viewed 5381 times
Hannes Rodriguez
Lima, Perú
Lima, Perú