string database

For E-blocks user to discuss using E-blocks and programming for them.

Moderators: Benj, Mods

Post Reply
User avatar
achillis1
Posts: 347
Joined: Thu Oct 09, 2008 9:19 am
Has thanked: 91 times
Been thanked: 8 times

string database

Post by achillis1 »

Hello,

I am trying to have a database sort of like, consisting of strings, so I can have an index and scroll through the strings and compare them with an input.
What I mean. I have a keypad and get a four-digit number. The four numbers then are combined: ex. 2,4,6,8 > are combined to 2468 Two thousand four hundred.......
I do calculation:after first "get keypad number" password=keyval, password=password*10 then after second "get keypad number" password=password+keyval, password=password*10 e.t.c.
Then I would associate the password value to a string which string it will represent a user. Ex I would have 100 passwords assigned to 100 string.
Then I a user will enter his password, it has to be a program routine that will search the 100 strings find which string is assigned to the corresponding password and then match them; for example: "welcome userX" on the LCD screen and then be able trough calculation icons to assign the string which belongs to the user to a "user5string.txt"
and then create for him a txt file in an MMC card and then append in it the time/date taken from an RTC clock(time attendance).
It would be nice if there is a procedure that the administrator to be able to choose first the user number and then assign the password dedicated to him via the keypad.

So far I managed to do this using the EEPROM. I had a menu that prompted the user to enter user number( here the routine took the number entered and assigned it to a variable called "userindex" which then it was used in the "WRITE EEPROM" command at the "addr(INT) parameter), then it is prompting the user to assign password( here the routine takes the four keypad strokes and through the calculations I mentioned before, is forming a 4-digit number-that can be only as INTeger- and later uses that integer in the "write EEPROM" command at the "data(BYTE) parameter).
So by the above, at a specified address in EEprom I would have a prespecified password; then it is easy to have an index which scrolls through eeprom and performs read commands in order to associate the value store with the value taken from keypad.
BUT as I finished making the routine I realized that eeprom could store number up to 255 value!!!!!!!!!!!!!!!!!!!!!!! A password though can have a value of 9999!!!!

I do not know If I am clear on what I want to achieve, if more details required please say so:)

Thank you in advance,
Best Regards,
Achiiles.

Sean
Valued Contributor
Valued Contributor
Posts: 548
Joined: Tue Jun 26, 2007 11:23 am
Has thanked: 6 times
Been thanked: 44 times

Re: string database

Post by Sean »

Hello,

You can split the INT into 2 Bytes and save them separately to EEPROM. Assuming the chip you are using has enough EEPROM capacity to store 2 bytes per user, one possible addresses and data format is:

User * 2 = Code AND 0xff //Low byte
(User * 2) + 1 = Code >> 8 //High byte

It should be possible to write a couple of simple macros that will take your original address and data values and perform the required write and read conversions.

Post Reply