Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

How2 define all the string into a lookup table??

Status
Not open for further replies.

brennbar67

Member level 3
Joined
Jul 26, 2004
Messages
54
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Activity points
580
improve sequential search

Anyone know how to define all the string into a lookup table??
After define all the string into lookup table, how we can access it??
 

You should tell us which line of micro-controller you're using.
 

i'm using M16c(Mitsubishi) MCU.

Actually does matter what MCU we using,right? All the format is same.
Example: english&japanese

const char text [size] [language_number] ={
{ "thank you" , "aligator"},
{"goodbye", "sayonara"},
....
...
..};

That mean i need2 create many languages that we can allow user to choose...But my compiler have error when i written like this. So i need the proper format...
So anyone know abt this??
 

Lookup table. You have to arrange your data in the table so that it can be retrieved by manipulating its address in the comfortable way. So it depends on your objective and processing algorithm.
 

There are different ways of dealing with strings search and parsing . Different approaches can be taken to string processing based on following requirements :
- Whether strings set is fixed or not (could be there strings which are not known and you should recognize no match case)
- Does any string have to added to your string database dynamicaly at run time .
- How string set is big .
- What is your run time requirements - how fast your lookup table must match string from db .
- ...

a. If string set you are dealing is fixed and no new strings will be added to you lookup db the best and fastest way is to use perfect hashing (gperf tool from gnu generate source code for your string combination )

b. If your string set is not big you can deal with sequencial string array searching to find match .
You can littele bit improve sequential search by storing them into array in sorted form such as
aa
aab
ab
abc
c
so when you are matching string "aac" your search will be stopped at "ab" not at "c" string

c. If your string set is big and not fixed you can use following approaches (the list is not complete):
- lookup with hash table with following collision resolution . It is the best lookup but given hash fucntion must be carefully choosen to avoid numerous collisions . Better way is to use double hashing for reduce collision as it was described in "Art of Computer Programming" from Knuth .
- binary search trees - different tree variations exist.
- Skip list

Search google for something like "sorting and searching coockbook" (not sure in name - try its variations) - that will give you base to start working with matching .
 

This code has to work:

const char text [size] [language_number] ={
"thank you" ,
"aligator",
"goodbye",
"sayonara",
....
...
..};


Mr.Cube
 

Try using the following:

const char *text [size] [language_number] ={
{ "thank you" , "aligator"},
{"goodbye", "sayonara"},
....
...
..};


Note the "const char *", as each element is a pointer to an
to the first element of an array of char.
 

This is the approach I use in multi language embedded apps.

// pointer to current language
unsigned char** pLang;

#define GetString(index) pLang[index]

const unsigned char * const pEnglish[] = {
"ENGLISH",
"SELECT UNIT TYPE"
};

const unsigned char * const pFrench[] = {
"FRANCAIS",
"MODE D'OPERATI"
};

const unsigned char * const pSpanish[] = {
"ESPANOL",
"SELEC. TIPO"
};

const unsigned char ** const pLanguages[3] = {
pEnglish,
pFrench,
pSpanish
};

#define LANGUAGE 0
#define SELUNIT 1
...

The language is set such as:

// set current language
// 0-English, 1-French, 2-Spainish
pLang = (unsigned char**)pLanguages[0];

// then use as follows
printf( GetString( SELUNIT ));

Regards
NTFreak
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top