Syntax If on Occurrences Variable

Discussions about CSEntry
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Syntax If on Occurrences Variable

Post by Gregory Martin »

The forum was down for a short while as we moved it from one server to another. Try this for your logic:
PROC FQ1

preproc

    set behavior(FQ1) canenter(notappl) on (noconfirm); // allow blanks on this field

postproc

    if FQ1 = notappl then

        if curocc() = 1 then
            errmsg("Please entry at least one.");
            reenter;

        else
            skip to FQ2;

        endif;

    endif;
langitluna
Posts: 32
Joined: December 4th, 2016, 10:57 pm

Re: Syntax If on Occurrences Variable

Post by langitluna »

Thanks Gregory Martin.
Its worked.

For all CsPro team and this forum members:
Merry Xmas and Happy New Year.
langitluna
Posts: 32
Joined: December 4th, 2016, 10:57 pm

Re: Syntax If on Occurrences Variable

Post by langitluna »

Hi Gregory Martin

Still on your logic above: can you add the logic to prevent double entry on FQ1 ?
Thank you
Gregory Martin
Posts: 1796
Joined: December 5th, 2011, 11:27 pm
Location: Washington, DC

Re: Syntax If on Occurrences Variable

Post by Gregory Martin »

You can change whether or not the item is filled in and then set the field to protected if it is. Something like this:
PROC FQ1

onfocus

    if visualvalue(FQ1(curocc())) <> notappl then
        set attributes(FQ1) protect;

    else
        set attributes(FQ1) native;

    endif;
langitluna
Posts: 32
Joined: December 4th, 2016, 10:57 pm

Re: Syntax If on Occurrences Variable

Post by langitluna »

Thanks Gregory

I mean field on FQ1 rooster on will not permit to entry same value that has been entry.
So:

Code: Select all

If FQ1 = ??? then errmsg("This value has been entry");reenter;endif;
Thanks in advance.
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Syntax If on Occurrences Variable

Post by khurshid.arshad »

Dear langitluna

Code: Select all

	Numeric Q1Ans, CountQ1;

	Q1Ans=Q1;
	CountQ1 =count(Q1 where Q1=	Q1Ans);

	if CountQ1>1 then

		errmsg ("This value has been entered");
		reenter;
	else
	endif;
a.
langitluna
Posts: 32
Joined: December 4th, 2016, 10:57 pm

Re: Syntax If on Occurrences Variable

Post by langitluna »

Hi khurshid.arshad

Very well. The syntax is working.

This is my whole syntax I combined from Josh, Gregory, Khursid.
They are working well on two Occurrences variable :
Thank you very much.

Code: Select all

PROC FQ1
Numeric EXAns, CountEX;
EXAns=$;
CountEX =count($ where $=   EXAns);
if CountEX>1 then
errmsg ("This value has been entered");
reenter;
else
endif;

numeric i, linenumber;linenumber=$;
If $ = 0 then skip to TEMP1 ;endif;
 do  i = 1 while i <= 146
if $(i) = linenumber then Q1(linenumber) = 1; else endif;enddo;
do  i = 1 while i <= maxocc(Q1000)Q1(i) = 0;enddo;
do  i = 1 while i <= totocc(FQ1000)if $(i) in 1:maxocc(Q1000)then Q1($(i)) = 1;endif;enddo;
If $ =146then skip to E4O;endif; 
langitluna
Posts: 32
Joined: December 4th, 2016, 10:57 pm

Re: Syntax If on Occurrences Variable

Post by langitluna »

Hi Expert

Still on FQ1 Occurrences/rooster:
How to prevent particular value ex 5, get mixed entried with others values?

FQ1: What pet do you like? Multiple Answer.
1. Cat
2. Ant
3. Mosquito
4. Others
5. None. I dont like any pet.

so:
if FQ1 = 5 then skip to FQ2
but if FQ1=5 and with any others value mixed then errmsg('Can not entry 5 together with..");reenter:endif;

Thank you in advance.
khurshid.arshad
Posts: 572
Joined: July 9th, 2012, 11:32 am
Location: Islamabad, Pakistan

Re: Syntax If on Occurrences Variable

Post by khurshid.arshad »

Dear langitluna

I hope it works for you.

Code: Select all

if curocc()>=2 and $=5 then
		errmsg ("You have already select pet and you can not enter 5.");
		reenter;
	else
	endif
a.
langitluna
Posts: 32
Joined: December 4th, 2016, 10:57 pm

Re: Syntax If on Occurrences Variable

Post by langitluna »

Dear khurshid.arshad

Its work fine. Thanks.

Still on on Occurrences Variable, I have a question please :
How the syntax to jump back to after the last occurrence filled.
Like this:
If FQ1 = 4 then skip to FQ1O (String field Alpha). After FQ1O fill entry then back to FQ1(), with position after value 4 that has been filled.
So if the answers of FQ1are : 1 and 2 and 4 and 6 and 7: After 4 specified on FQ1O then back to FQ1() to continue entry of 6 and 7.

FQ1: What pet do you like? Multiple Answer.
1. Cat
2. Ant
3. Mosquito
4. Others, please specity
5. None. I don't like any pet
6. Bird
7.
8.

FQ1O


Fyi masters: this is my last complete syntax on global mode, that I combine from Gregory, Josh and khursid in this thread. Tested and worked. Seems good on my taste :D :D as a beginner. Thank you team.

Code: Select all

PROC GLOBAL
PROC FQX

Preproc
////
set behavior($) canenter(notappl) on (noconfirm); // allow blanks on this field
PostProc
if $ = notappl then
if curocc() = 1 then errmsg("Please entry at least one."); reenter;endif;endif;

Numeric EXAns, CountFQX; 
EXAns=$; 
CountFQX =count($ where $=   EXAns); 
if CountFQX>1 then 
errmsg ("This value has been entered"); 
reenter; 
else 
endif; 
 
if curocc()>=2 and $ =  5   //CHANGE THIS
then errmsg("You can not enter this value"); 
reenter;else;endif; 

If $ = 0 then skip to FQX(1) ;endif;

numeric i, linenumber;linenumber=$; 
 
do  i = 1 while i <= 5              //
if $(i) = linenumber then FQY(linenumber) = 1; else endif;enddo; 
 
// Set everything in to zero 
do  i = 1 while i <= maxocc(FQY000)FQY(i) = 0;enddo; 
 
// Set ones in FQY where there are corresponding entries in FQX
do  i = 1 while i <= totocc(FQX000)if $(i) in 1:maxocc(FQY000)then  
FQY($(i)) = 1;endif;enddo; 
 
If $ =   4   then skip to FQO;endif; //
PROC FQY000 

Preproc 
set attributes ($) protect; 

PROC FQY


onfocus
if visualvalue($(curocc()))
<> notappl then
set attributes($)
protect;
else
set attributes($)
native;
endif;

PROC FQO 
if $ = "" then errmsg("Others. Please specify."); reenter;endif; 
 
Post Reply