|
|
View previous topic :: View next topic |
Author |
Message |
Josszy
Joined: 17 Oct 2010 Posts: 4
|
choice of two arrays with pointer - how can it be? |
Posted: Mon Jul 16, 2018 7:08 am |
|
|
I would like my program to write the texts in two languages so that I can specify a variable with the variable which is the current language.
The Hungarian and English language texts are stored in a single 'char const' array, and I want to solve the script with a pointer. Unfortunately, I have no practice in the pointer address syntax, so please help me.
I copy a sketch of a program outline here, with question marks for me "dark" parts. (now i'm all pretty "dark").
I apologize for my weak English knowledge ....
Code: |
//----definition of variables----
.
.
char char_kiiras1[22]; //display text
int nyelv; // language variable
.
.
.
//----nyelvi konstansok-------
char *muvkiir[32]; // ?? pointer, this is done by making a reference (with an element number)
.
char const muvkiir_hun[32][22] = {{"Hibajelentes"},{"PUTD HIBA!"},{"SETUP vetel HIBA!"},{"Kilep"},…}; // Hungarian text (32-element array)
char const muvkiir_eng[32][22] = {{"Error report"},{"PUTD ERROR"},{"SETUP rec. ERROR!"},{"Exit "},…}; // English text (32-element array)
.
.
.
void main() {
.
//--- Set language texts (nyelv = 0 Hungarian, nyelv = 1 English)---
if(nyelv==0) {
??????;
}
else {
??????;
}
.
.
.
strcpy(char_kiiras1,muvkiir[18]); //preparation of text “Beallitasok” or “Set” (18. element)
.
.
.
glcd_text57(28, 6, char_kiiras1, 1, ON); // Display "Beallitasok" or „Set” text
.
.
}
|
_________________ Josszy |
|
|
temtronic
Joined: 01 Jul 2010 Posts: 9245 Location: Greensville,Ontario
|
|
Posted: Mon Jul 16, 2018 11:14 am |
|
|
Others will offer their suggestion..
here's mine
Make ONE 64 element array, where [0] is the 1st msg, in hung and [1] is the 1st msg in eng. repeat 31 more times.
When lang=0, add 0 to the 'msg offset' value. When lang=1, add 1 to the 'msg offset' value.
The msgs are in 'pairs'..same msg, 2 languages, repeated 32 times.
This 'should' work, I think...
Should be easy to try...
Jay |
|
|
Ttelmah
Joined: 11 Mar 2010 Posts: 19546
|
|
Posted: Mon Jul 16, 2018 11:19 am |
|
|
Or just join the two arrays into a single 3 dimensional array. Make the third dimension '0' for the first language and '1' for the second... |
|
|
Josszy
Joined: 17 Oct 2010 Posts: 4
|
|
Posted: Mon Jul 16, 2018 11:36 am |
|
|
Temtronic, thank you, your suggestion is super, and in any case simpler than the "play with the pointer"
I try to make the 'msg offset' variable simpler to use (elements of the 'muvkiir' array are used in more than 100 locations in the program ...)
Thanks again for the idea! _________________ Josszy |
|
|
Josszy
Joined: 17 Oct 2010 Posts: 4
|
|
Posted: Mon Jul 16, 2018 11:40 am |
|
|
Ttelmah, that's a good idea, thank you! _________________ Josszy |
|
|
Josszy
Joined: 17 Oct 2010 Posts: 4
|
|
Posted: Mon Jul 16, 2018 4:03 pm |
|
|
Temtronic, I did it and it works perfectly. Thanks once again! _________________ Josszy |
|
|
|
|
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
|