Retrieving various data from DAT blocks
CassLan
Posts: 586
Hi folks,
I'm trying to make a re-usable menu function, where the menu choices, # of choices is stored in DAT blocks for now.
I cant seem to get this right, the code below prints "M" on the screen which makes sense, but as soon as I incement the dattemp variable, which is supposed to be the offset of the starting menudata, I get junk.
Anyone know where I'm going wrong?
PUB Main
· 'start term
· text.start(12)
· 'start the keyboard
· kb.start(26, 27)
· 'Display the Main Menu
· textmenu(MainMenu)
PUB TextMenu (StartofMenuData)
· dattemp :=0
· ''Start By Displaying Name of Menu
· text.out(StartofMenuData[noparse][[/noparse]dattemp])
DAT
MainMenu····· byte "Main Menu·· ",0,4
············· byte "System Info ",0
············· byte "Setup······ ",0
············· byte "Another Opt ",0
············· byte "Last Option ",0
I'm trying to make a re-usable menu function, where the menu choices, # of choices is stored in DAT blocks for now.
I cant seem to get this right, the code below prints "M" on the screen which makes sense, but as soon as I incement the dattemp variable, which is supposed to be the offset of the starting menudata, I get junk.
Anyone know where I'm going wrong?
PUB Main
· 'start term
· text.start(12)
· 'start the keyboard
· kb.start(26, 27)
· 'Display the Main Menu
· textmenu(MainMenu)
PUB TextMenu (StartofMenuData)
· dattemp :=0
· ''Start By Displaying Name of Menu
· text.out(StartofMenuData[noparse][[/noparse]dattemp])
DAT
MainMenu····· byte "Main Menu·· ",0,4
············· byte "System Info ",0
············· byte "Setup······ ",0
············· byte "Another Opt ",0
············· byte "Last Option ",0
Comments
Cause I'm assuming that all 66 bytes of data here start at memory address [noparse][[/noparse]MainMenu] and go continuous until the 0 after "Last Option".
Additionally, to the matter of indexing each option..my goal is to create a function that only needs to be told the begining of a menu's data, from that point on it will be able to render the menu, regardless of how many choices, the length of the choice names, or the outcomes of such choices.
In this manner the menu can be changed in the DAT block (or eeprom later) and the program will still function, if I add or remove choices.
Thanks,
Rick
Post Edited (CassLan) : 2/28/2009 8:58:57 PM GMT
Also you should pass the address of MainMenu to the method: textMenu(@MainMenu)
Then text.out ... becomes
text.out(byte[noparse][[/noparse]StartOfMenuData+n]) 'where n is an index into the array.
There are easier ways to do it though with text.str and the @@ operator ....
See page 279 of the bookmarked manual for more details.
Using grasshopper's example ...
MainMenu long @Menu1, @Menu2, @Menu3
Then call with
textMenu(@@MainMenu)
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
--Steve
I had tried @ when calling the method, but had not used·byte when referencing the data.
Thanks!!
Rick
i am also just writing such a menu system, many thanks for your hints.
If its ready i will post my code
Regards
Markus