PDA

View Full Version : Lookup table not accepting strings



lerameur
- 17th January 2011, 21:27
I know PBP do not handle strings too well. I would like to get an idea on how to get this issue solved.
Obviously this Lookup command do not work, but if PBP could handle it, it is exactly what I need. What is the best way to make this work. I think the program is pretty much self explainable.
K



Lookup Beverage_type, [Coke, Pepsi, DietCoke, DietPepsi],B1

'/////////////////////////////////////////
'/////// Selection beverage type ///////////
'/////////////////////////////////////////
Selection_beverage_type:

lcdout $FE,1, " Type: ", B1
lcdout $FE,$C0, "Next or Select"
pause 200
if Selection=1 then return
if Next1=1 then
Beverage_type = Beverage_type+ 1
if Beverage_type > 3 then Beverage_type = 0
Gosub Selection_beverage_type
Endif
Return

HenrikOlsson
- 17th January 2011, 21:41
Hi,
This compiles OK but is not tested, perhaps it could serve as a starting point:

Coke CON 0
Pepsi CON 1
DietCoke CON 2
DietPepsi CON 3

Row1 VAR BYTE[16] 'Array for 1st line of LCD
Length VAR BYTE

Select Case Beverage_Type
Case Coke
ArrayWrite Row1, ["Coke"]
Length = 4
Case Pepsi
ArrayWrite Row1, ["Pepsi"]
Length = 5
Case DietCoke
ArrayWrite Row1, ["Diet Coke"]
Length = 9
Case DietPepsi
ArrayWrite Row1, ["Diet Pepsi"]
Length = 9
END SELECT

LCDOUT $FE, 1, STR Row1 \Length

/Henrik.