Hi folks,
I am trying to set up a list of menu choices for a small device. Right now, it pulls the choices from a resource file, which makes updating the list of choices rather clunky.
What I want to do is declare the list of choices in an array, and show them up on screen one by one as the user cycles through the menu.
Unfortunately, this process is further complicated by the fact that the device's code page is UTF16 - yuck!
Here's what I have so far.
In the global variables section, I set up the constant char arryay of choices.
These will be individually copied into the TextToShow variable, which is picked up by the display function in another module.Code:const char* menuChoices[] = { "Increase Brightness", "Decrease Brightness", "Check Temp", "Save Temp", "Exit" }; //menuChoices
Then, when the user presses the Next button, I try to copy the next choice into the VarToShow variable.Code:extern char TextToShow[];
Naturally, this fails on two counts, one because I can't use the L macro like that, and second because I'm not accessing the data properly.Code:memset (TextToShow, 0, 128); memcpy (TextToShow, L**menuChoices[uCurrentChoiceIndex], 44);
I have tried to use _TEXT() and TEXT() to no avail - it says that function is undeclared. I'm out of ideas.
What does work is this:
but I want the choices to be in an array, instead of buried halfway through the code in a series of ugly if statements.Code:memcpy (TextToShow, L"Increase Brightness", 59);
Finally, if you have a tip on getting the correct length of the string being copied (it seems to be 39+LengthOfAsciiString), I would be most grateful!
Thanks everyone for looking! Sorry, I've been writing Basic code for years, but C is a little new to me!



LinkBack URL
About LinkBacks


