CCS C Software and Maintenance Offers
FAQFAQ   FAQForum Help   FAQOfficial CCS Support   SearchSearch  RegisterRegister 

ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

CCS does not monitor this forum on a regular basis.

Please do not post bug reports on this forum. Send them to CCS Technical Support

where is the mistake......
Goto page 1, 2, 3  Next
 
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion
View previous topic :: View next topic  
Author Message
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

where is the mistake......
PostPosted: Mon Jul 06, 2009 9:46 am     Reply with quote

hi, I have this code, where is the mistake:
Code:

void ScrollMessage(unsigned char row,const char Message[])
{
 char TempS[30];
 unsigned int  MHead=0,Done=0,count;
 if(row >1) row=1;
 row=row*40;
 while(Done==0)
 {
  for(count=0;count<20;count++)
  {
     TempS[count]=Message[MHead+count];
     if(Message[MHead+count+1]==0) Done=1;
    }
    MHead++;
  lcd_gotoxy(1,row);
  lcd_putc(TempS);
  Delay_ms(200);
 }
}


But when I want to make function active:
Code:
ScrollMessage(1,"You Wally! You are only ment to press one key at a time!!!!");


I get this error:

*** Error 12 "main.c" Line 25(14,15): Undefined identifier -- ScrollMessage
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Mon Jul 06, 2009 9:56 am     Reply with quote

Simple, as you havn't posted a complete program I should just let you figure it out for yourself but I am in a good mood.

I assume your function
void ScrollMessage(unsigned char row,const char Message[])
Is defined somewhere after main, infact somewhere after your call to it.

You either need to rearange the code so you define the function before you call it, or you need to put a function definition header either in a header file and included at the top of the page in which you make the call or just place it at the top of your main file after the includes.
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Jul 06, 2009 10:45 am     Reply with quote

The function is in "flex_lcd.c"

and the flex_lcd.c is load in

main.c
Code:

#include "main.h"
#include "flex_lcd.c"
#include "meniu.c"
#include "temperatura.c"
#include "voltmetru.c"
#include "turometru.c"
#include "DS1307.c"


The code from main.c
Code:
#include "main.h"
#include "flex_lcd.c"
#include "meniu.c"
#include "temperatura.c"
#include "voltmetru.c"
#include "turometru.c"
#include "DS1307.c"

#define stanga input(PIN_B5)
#define asterix input(PIN_B6)
#define dreapta input(PIN_B7)

void main()
{
lcd_init();
LCD_Clrscr();
delay_ms(50);

porturi();
ds1307_init();
//setare_ceas_calendar();

while(1)
{
ScrollMessage(1,"You Wally! You are only ment to press one key at a time!!!!");

//interfata++;
//printf("timpi:%4.0i \r",interfata);
//delay_ms(80);
//lcd_send_byte(0, SHIFT_RIGHT);

//citeste_temperaturi();
//citeste_tensiuni();
//turometru();
citire_ceas();
}
}
bungee-



Joined: 27 Jun 2007
Posts: 206

View user's profile Send private message

PostPosted: Mon Jul 06, 2009 12:05 pm     Reply with quote

Your problem lies here: const char Message[]
You have to declare Message size Wink
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Jul 06, 2009 12:22 pm     Reply with quote

It's not working, how to declare the message size, where I put the message?
mkuang



Joined: 14 Dec 2007
Posts: 257

View user's profile Send private message Send e-mail

PostPosted: Mon Jul 06, 2009 12:32 pm     Reply with quote

bungee- wrote:
Your problem lies here: const char Message[]
You have to declare Message size Wink


I don't think so...the const char Message is the input to a function, not a declaration. However, it is incorrectly done. Whenever you want to pass a string to a function you should declare a pointer to the string. So the function should look like:

Code:

void ScrollMessage(unsigned char row,  char *Message)

}

And the subsequent code needs to be modified accordingly.

That said, I have found that passing an array directly to a function as the OP did sometimes DOES compile, and sometimes it even works. But sometimes I can get some results that make me scratch my head so I stopped doing it.
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Mon Jul 06, 2009 12:38 pm     Reply with quote

But the
Code:
TempS[count]=Message[MHead+count];

Is not counting the message length?

What modification is needed? Is there any solution to make a messange scroll?
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

Re: where is the mistake......
PostPosted: Wed Jul 08, 2009 2:53 am     Reply with quote

soulraven wrote:
hi, I have this code, where is the mistake:
I get this error:

*** Error 12 "main.c" Line 25(14,15): Undefined identifier -- ScrollMessage


So you don't get this error anymoe ? How did you fix it ?

As for your other problem,
Quote:

for(count=0;count<20;count++)
{
TempS[count]=Message[MHead+count];
if(Message[MHead+count+1]==0) Done=1;
}
MHead++;
lcd_gotoxy(1,row);
lcd_putc(TempS);


What output do you actually get ? Anything ?
Did you write/modify the flex_lcd code or did someone else ?

Not sure how lcd_putc works when presented with an array of chars that is not a string, how does it know where the end of the chars is or the size of the array is ?
Are you assuming that the definition char TempS[30]; zeros out the array ? It may be possible it does, it may be that the first time the function is called that the memory used is zero. I wouldn't count on it.

Basically you may need to add
TempS[count] = '\0'; after the for loop.
That would put the null terminator at position [20] char number 21 in the array!
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Jul 08, 2009 3:01 am     Reply with quote

no, the error is still here.....

this is the source code

http://s10.transfer.ro/storage/Calculator-da9e8.zip
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Jul 08, 2009 3:32 am     Reply with quote

No, that is just the main.c and main.h files.
it is missing

"flex_lcd.c"
"meniu.c"
"temperatura.c"
"turometru.c"

and any .h files to go with them.

I suspect that we would only need the "flex_lcd.c" and .h file to fix the problem though.
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Jul 08, 2009 3:37 am     Reply with quote

Actually I can tell you what the problem is.
I did a search on the .lst file and there is no ScrollMessage function included.
I cannot find it in the included flex_lcd.c code at all.

So you are either using the wrong version of flex_lcd or you have forgot to add it!

You seem to be changing the parameters for it each time you post as well.

Actually, if the .lst includes functions that were used then it is because your ScrollMessage call is commented out that it is not included in the file.


Last edited by Wayne_ on Wed Jul 08, 2009 3:39 am; edited 1 time in total
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Jul 08, 2009 3:39 am     Reply with quote

http://s4.transfer.ro/storage/Cod_sursa_MPLAB-1b267.rar

this is the all project folder
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Jul 08, 2009 3:45 am     Reply with quote

Again, your code is different to what you have been posting.

You are now calling
Scroll(1,"You Wally! You are only ment to press one key at a time!!!!");

"Scroll"

This function has not been defined anywhere in that project.
soulraven



Joined: 08 Feb 2009
Posts: 72
Location: campulung muscel

View user's profile Send private message Send e-mail Yahoo Messenger

PostPosted: Wed Jul 08, 2009 3:48 am     Reply with quote

yes, i have rename the function, but no change....is i the seam error
Wayne_



Joined: 10 Oct 2007
Posts: 681

View user's profile Send private message

PostPosted: Wed Jul 08, 2009 3:54 am     Reply with quote

soulraven wrote:
yes, i have rename the function, but no change....is i the seam error


Well, until you post the actual code (preferably a cutdown version) that contains everything needed to compile and includes the current problem you have with it then there is nothing anyone can do.

You say you have renamed it, I assume you mean you have renamed it to "Scroll" !
The only mention of "Scroll" in that project/directory is in your main.c file where you call it.

You will get the error you mentioned because you have not defined the function anywhere. If you have then please post the file that has it!
Display posts from previous:   
Post new topic   Reply to topic    CCS Forum Index -> General CCS C Discussion All times are GMT - 6 Hours
Goto page 1, 2, 3  Next
Page 1 of 3

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group