how to use a string variable in( if statement ).

General discussion on mikroPascal PRO for PIC.
Post Reply
Author
Message
waleed shorbagy
Posts: 1
Joined: 24 Jul 2016 01:11

how to use a string variable in( if statement ).

#1 Post by waleed shorbagy » 24 Jul 2016 01:28

hi,

i need to use a string variable in (if statement ),the code is:
//----------------------------------------
var str:string[12];//global variable;

if(str='string1')then {do some code}
//----------------------------------------
the compiler is mikropascal v6,
it give this error: Operator "=" not applicable to these operands "str" test1.mpas

what is wrong?i do not know. :shock:

trevor
Posts: 121
Joined: 28 Jun 2010 13:21

Re: how to use a string variable in( if statement ).

#2 Post by trevor » 25 Jul 2016 10:22

Code: Select all

if (strcmp(str, 'string1') = 0) then
      // code
else
      // code

Post Reply

Return to “mikroPascal PRO for PIC General”