If Char logic

Discussions about CSEntry
Post Reply
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

If Char logic

Post by yanina »

Hello friend

I have questions. Your help would
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: If Char logic

Post by yanina »

sorry for last unfinished post. I am using mobile that a bit hard and tricky when typing.

Your help would be very appreciate.

I have
Q1 : type Alfa, lenght 11, set declared 1234567890A, for Multiple amswer
Q2 : Num, lenght 1, Single.

How to set the logic for Q2, that only what entried on Q1 allowed.
I tried but failed, ex : If pos("1", Q1) = 0 or pos ("2", Q1) .... so on and so on then errmsg ("Only value entried on Q1 allowed ...

Is that correct using pos or poschar? or any other simple logic that can handle this ?

Great thanks for your help.

Yanina
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: If Char logic

Post by josh »

pos() is the correct function to use in this case.

See the following for details: http://teleyah.com/cspro/DCJune2015/04-CAPI/04-CAPI.pdf
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: If Char logic

Post by yanina »

Hi Josh

Thank you. I got the file. But I am a beginner. its for advance level to understand it cry:, but I will try to learn from it.
1. Could please to check my logic below. Its not work at all.
2. Can Q2 as NUM type ?

The questions should be like this:
Q1: What kind of food do you know ? Multiple Answer, Maximum 11
Alpha 11. Code 1234567890A Accordingly
Code: 1. food1 2. food2. .....0. food10 A. food11

Q2. From that foods (answered in Q1), what is your most favorite ? Single Answer
Alpha, Single
Num ?

Thank you very much for your help.

=========================================
PROC GLOBAL
PROC MT_FF
PROC Q1

PROC Q2
string alphabet = "1234567890A";

// Single Answer
if pos("1234567890A", Q1) = 1 then
errmsg("You can entry only value entered on Q1");
reenter;
endif;

=========================================
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: If Char logic

Post by josh »

Unfortunately to do what you are trying to do is not a task for beginners. Do your best to follow along with the lesson I sent if you want to do this. You will want Q1 to be an alphanumeric type so that you can use checkboxes. Since Q2 is single response you would normally make it a numeric item and use radio buttons as the capture type. Then you will use the logic function setvalueset() to create the value set for Q2 based on what was selected in Q1. In the CSPro examples directory (C:\Program Files(x86)\CSPro 6.3\examples) there is an example called SIMPLE CAPI. In that example you will find an example you can follow. The LANGUAGES_SPOKEN variable is a multiple response item and the question that follows, MAIN_LANGUAGE, is a single response item that displays only the languages that were chosen in the previous question.
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: If Char logic

Post by yanina »

Hi josh

Yes. Oki doki. There is a logic on simple capi example folder that I can follow. I will learn from it.
Million thanks, Josh. You are a man.
I ll be back ( Arnold Swarzenegger mode). :mrgreen:
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: If Char logic

Post by yanina »

Dear Josh
Dear Expert

I am back :).
First let me give big appreciation for this forum. You all are the best. So many that I can learn from here.
I only known CSPRO for 2 weeks but has been falling in love with it.

Now about the topic I asked:
I have followed the logic on SIMPLE CAPI file, and take some that I think necessary on my program. Please see attached ExampleFood.zip.
The program I tested and running well.
The problem is, If I put many values label on, for example I just take 28 values on Q1 and Q2, exactly like on Simple Capi example, do running entry, but the process seems running so slow when reading logic on Q2. It will take sometimes till the Q2 values popup on the screen.

As comparison I have followed the logic as you suggested too on http://teleyah.com/cspro/DCJune2015/06- ... urvey6.zip, session Crops. On my attached ExampleFood.zip are P1 and P2. Its similar for CROPS_PRODUCED and CROPS_SOLD, that both using alpha field.
I put 28 values on P1 and P2 as like on SIMPLE CAPI. On this: the program running smooth, fast and good.

My question are:
1. Q2 Num that running so slow : is this normal or there is some unnecessarily logic I have put on in it ? Or any other o
2. P2 Alpha: How I make it single instead of Multiple ?

I am using CS Pro v.6.2.0 tested it on Windows XP, and Windows 7.

Please advice, and could you please see ExampleFood.zip and give correction and comment.

Thank you very much for your help.
Attachments
ExampleFood.zip
(4.28 KiB) Downloaded 335 times
josh
Posts: 2399
Joined: May 5th, 2014, 12:49 pm
Location: Washington DC

Re: If Char logic

Post by josh »

For question 1 remove the lines:

set attributes(Q2) protect;
set attributes(Q2) native;

These are causing the slowdown and are accomplishing nothing. The first line makes the field protected, the second makes it unprotected again. You also don't need the setcapturetype above. The capture type is already set in the field properties on the form.

I don't understand question 2. It is already a single choice question (radio button).
yanina
Posts: 60
Joined: October 31st, 2016, 9:37 am

Re: If Char logic

Post by yanina »

Hi Josh

Awesome. Amazing. Wow.
After I remove set attributes(Q2) protect; set attributes(Q2) native;
It is working like a charm now.

For question 2: I mean on P2 on ExampleFood.zip.
But I think it has been solved. Single Answered just set Num field rather than alpha .

Again many thanks Josh for your help.
Post Reply