using parameters when creating component

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
Anonymous
Not applicable

Hi, 

   

i'm fairly new to cypress PSoC and this is the first component i'm trying to create.

   

I've setup a parameter for my symbol as a boolean, but now i'd like my API to execute different code depending on it's status.

   

I've searched through the component author guide and watched some tutorials, but i can't find any reference on how to do this.

   

 

   

any help would be greatly appreciated.

   

i'm using creator 3.3

   

 

   

best regards,

   

Damian

0 Likes
1 Solution
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In the API template file use a

   

#if(‘$<parameter>‘ == 0) for conditional compilation

   

or

   

if (‘$<parameter>‘) for program flow

   

where <parameter> is the name you have given in the symbol creation dialog.

   

 

   

Bob

View solution in original post

0 Likes
4 Replies
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

In the API template file use a

   

#if(‘$<parameter>‘ == 0) for conditional compilation

   

or

   

if (‘$<parameter>‘) for program flow

   

where <parameter> is the name you have given in the symbol creation dialog.

   

 

   

Bob

0 Likes
odissey1
Level 9
Level 9
First comment on KBA 1000 replies posted 750 replies posted
        One extra comment: default Cypress constants for use in API parameters evaluation are 'true' and 'false' (lowercase letters), not 'True' / 'False'. So use lowercase only. For example, for both parameters being true, the result of compilation will be different: #define CASE1 (($param1==true) & ($param2==true)) Compiled file: #define CASE1 true And this line will not be evaluated: #define CASE1 (($param1==1) & ($param2==1)) Compiled file: #define CASE1 (($param1==1) & ($param2==1))   
Bob_Marlowe
Level 10
Level 10
First like given 50 questions asked 10 questions asked

I have learnt not to test booleans for true or false. In your examples we were taught to write

   

#define CASE1 ((`$param1`)&&(`$param2`))

   

C-language defined false to be zero, so true is defined as being non-zero.

   

Imagine what the different behaving is, when $param1 has the value of 27 (or any other).

   

 

   

Bob

0 Likes
Anonymous
Not applicable

Thanks Bob and odissey1 this was what i needed to know.

   

I was using the < and > characters and the ' instead of ` characters.

   

 

   

regards,

   

Damian 

0 Likes