Problem with basic to C conversion ... I need help ...

General discussion on mikroC PRO for PIC32.
Post Reply
Author
Message
Darklakebridge78
Posts: 136
Joined: 12 May 2007 14:04
Location: Italy
Contact:

Problem with basic to C conversion ... I need help ...

#1 Post by Darklakebridge78 » 07 Feb 2022 09:57

Hi to all,
I come from the world of basic and I recently approached C. I'm trying to make a routine to display messages on a TFT, but what worked in basic, I can't get it to work in C. Can you tell me where am I wrong?

Code: Select all

char MessTextHold[40];
unsigned short MessageCtrl;

void main() {
  VisualMessage("WAIT FOR START SIGNAL ...");
}

void VisualMessage(char MessText[40]) {
 MessageCtrl = strcmp(MessText,MessTextHold);
 
 if (MessageCtrl != 0) {
     TFT_Rectangle(32,213,309,229);
     TFT_Write_Text(MessText,36,213);
     MessTextHold = MessText;
 }
}

When I try to compile the code I get this message:

Assigning to non-Ivalue
Implicit conversion of pointer to int


Where am I wrong? Thanks to anyone who will help me understand ...
MikroC PRO for PIC, MikroC PRO for dsPIC, MikroC PRO for PIC32, MikroC PRO for ARM, Visual TFT, Visual GLCD,
http://www.teolab.it

sgssn
Posts: 34
Joined: 13 Sep 2021 16:24

Re: Problem with basic to C conversion ... I need help ...

#2 Post by sgssn » 07 Feb 2022 17:19

Hi
how did you define your function VisualMessage() ?
Seesms it is void VisualMessage(char*); ??
Or didn't you define the prototyüe for the function?
In C you have to define a function-Prototype for all your functions.
Before your main() - function you define as above:
void VisualMessage(char*);


Then function VisualMessage should work right as:

void VisualMessage(char *MessText)
{
MessageCtrl = strcmp(MessText,MessTextHold);

if (MessageCtrl != 0) {
TFT_Rectangle(32,213,309,229);
TFT_Write_Text(MessText,36,213);

MessTextHold = MessText; <- This line will also not work. In C there is no copy-function for strings like in C++

you have to use strcpy():
strcpy( MessTextHold, MessText);

regards Gerhard

Darklakebridge78
Posts: 136
Joined: 12 May 2007 14:04
Location: Italy
Contact:

Re: Problem with basic to C conversion ... I need help ...

#3 Post by Darklakebridge78 » 10 Feb 2022 09:37

Thank you so much! :-)
MikroC PRO for PIC, MikroC PRO for dsPIC, MikroC PRO for PIC32, MikroC PRO for ARM, Visual TFT, Visual GLCD,
http://www.teolab.it

sgssn
Posts: 34
Joined: 13 Sep 2021 16:24

Re: Problem with basic to C conversion ... I need help ...

#4 Post by sgssn » 10 Feb 2022 11:27

Glad to help you! :D

Post Reply

Return to “mikroC PRO for PIC32 General”