Hello everyone,
I would like to consult them if it is possible through the onkey function to show the user the contents of an array. As an example, the questionnaire has 10 sections and the array to be shown was defined after the end of section 5.
Thus, if the user uses the onkey function it should not be activated until section 5, ie it should only be activated in sections 6 to 10.
Thank you!
Using the onkey Function to view arrays
Forum rules
New release: CSPro 8.0
New release: CSPro 8.0
-
- Posts: 29
- Joined: October 5th, 2019, 1:43 pm
Re: Using the onkey Function to view arrays
You could create a global variable that you initialize to zero. When you arrive at the end of section 5 you set the variable 1. In your OnKey function you only show the array if the variable is set 1.
numeric finishedSection5 = 0;
function OnKey(numeric x)
if x = 2069 and finishedSection5 = 1 then
showarray(...);
else
OnKey = x; { returnrest of keys }
endif;
end;
An alternative to using OnKey is to add a button to the userbar (https://www.csprousers.org/help/CSPro/u ... ction.html). This tends to be less hidden than using a key and will also work well on Android.function OnKey(numeric x)
if x = 2069 and finishedSection5 = 1 then
showarray(...);
else
OnKey = x; { returnrest of keys }
endif;
end;
-
- Posts: 29
- Joined: October 5th, 2019, 1:43 pm
Re: Using the onkey Function to view arrays
Thanks again Josh!
-
- Posts: 1777
- Joined: December 5th, 2011, 11:27 pm
- Location: Washington, DC
Re: Using the onkey Function to view arrays
Another function that is little known in CSPro but is useful is the highlighted function. You can pass it a field name to check if that field has been entered, so you could write something like:
if highlighted(LAST_FIELD_IN_SECTION_FIVE) then
// show array
// show array