MikeW
Joined: 15 Sep 2003 Posts: 184 Location: Warrington UK
|
preprocessor directive __FILE__, how can I find its length |
Posted: Fri Nov 04, 2005 4:51 am |
|
|
I am not sure whether to ask this question of CCS support, hopefully Darren will respond
I am trying to embed the file name into the ROM, and also have the ability to strip specific characters during run time.
its easy to print out in the form :-
printf("Software was compiled on ");
printf(__TIME__ " ");
printf(__DATE__ "\n\r ");
printf(__FILE__ "\n\r ");
and that works fine.
I want to get to each individual character, so I can send just certain characters.
for example, I know that the __TIME__, and __DATE are in a fixed format, so by doing this :-
const byte DATE[]= {__DATE__};
const byte TIME[]= {__TIME__};
const byte FILE[]= {__FILE__};
then
the date is stored in ROM as 30 34 2D 4E 6F 76 2D 30 35 (04-Nov-05)
so extracting it by the following is easy.
i=DATE[0]; // 30 ascii 0
i=DATE[1]; // 34 ascii 4
i=DATE[2]; // 2D ascii -
i=DATE[3]; // 4E ascii N
i=DATE[4]; // 6F ascii o
i=DATE[5]; // 76 ascii v
i=DATE[6]; // 2D ascii -
i=DATE[7]; // 30 ascii 0
i=DATE[8]; // 35 ascii 5
and the same for the TIME.
The problem comes with the __FILE__
This of course is not a fixed length
Is there anyway to get the length of the __FILE string , so that I can do a
i=DATE[n]; // last character in the string.
I really dont want to have to predefine a string buffer of say 100 characters, then transfer it, and work on it as a string in RAM
It would also be useful if the __DATE__ had the option of outputting the month number, rather than the three character letters, so that
APR would become 04
Mike |
|