Reading Tickboxes in a ListIconGadget
Posted: Sat Dec 18, 2004 7:18 pm
I have a problem reading the checkboxes within a ListIconGadget for some reason. The ListIconGadget is populated depending on the contents of a file read beforehand. As shown below (The variable EntrySelect is set from an unshown ListIconGadget and 1 is added to it's vaule as a ListIconGadget starts at 0 and not 1, this way the program knowns which set of options to display).
The file which is read looks like this:
For some reason the tickboxes are not read right. If there are 5 options available (as shown in the example) the last one always get an "A" for ticked even when it isn't (e.g Acc$="OOOOA" and not "OOOOO" if no boxes are ticked).
What have I done wrong? I found out how to read tickboxes from an example in the PureBasic Code Archive and though it should work as I have done.
Hopefully there is enough information there to make sense of what I have done.
Thanks in advance.
Max
Code: Select all
TextGadget(#Text_19, 60, 290, 90, 30, "Accessories Included", #PB_Text_Center)
SetGadgetFont(#Text_19, FontID3)
ListIconGadget(#ListIcon_2, 50, 320, 110, 190, "Accessory", 100, #PB_ListIcon_CheckBoxes | #PB_ListIcon_GridLines)
TextGadget(#Text_21, 600, 290, 110, 30, "Variant Information", #PB_Text_Center)
SetGadgetFont(#Text_21, FontID3)
ListIconGadget(#ListIcon_3, 600, 320, 110, 190, "Variant", 100, #PB_ListIcon_CheckBoxes | #PB_ListIcon_GridLines)
Dim Accessories.s (30,20)
Dim AccList.b (30)
If ReadFile (10,"C:\Program Files\PureBasic\TF Database\VS\Teletran\DBAccList.tdb")
Repeat
Rd$=ReadString()
If Left(Rd$,2)="--"
For Cx=Count2 To 20
Accessories(Count1,Cx)=""
Next Cx
Count1 = Count1+1
Count2 = 1
Else
Accessories (Count1,Count2)=Rd$
AccList (Count1) = Count2
Count2 = Count2+1
EndIf
Until Eof(10)
CloseFile (10)
EndIf
EntrySelect=EntrySelect+1
Accs=0
For Count=2 To AccList(EntrySelect)
If Left(Accessories(EntrySelect,Count),4)="Var:"
t$=Mid(Accessories(EntrySelect,Count),5, Len(Accessories(EntrySelect,Count)))
AddGadgetItem (#ListIcon_3, -1, t$)
Else
AddGadgetItem (#ListIcon_2, -1, Accessories(EntrySelect,Count) )
Accs=Accs+1
EndIf
Next Count
- Jazz
Gun
Launcher
Missile 1
Missile 2
Missile 3
Var:Rub Symbol
Var:No Rub Symbol
--
Laserbeak
Var:Rub Symbol
Var:No Rub Symbol
--
Code: Select all
Acc$=""
If Accs>0
For Cnt=1 To Accs
Result = GetGadgetItemState(#ListIcon_2, Cnt)
If Result & #PB_ListIcon_Checked
Acc$=Acc$+"A"
Else
Acc$=Acc$+"O"
EndIf
Next Cnt
EndIf
Debug "Acc$ = "+Acc$
What have I done wrong? I found out how to read tickboxes from an example in the PureBasic Code Archive and though it should work as I have done.
Hopefully there is enough information there to make sense of what I have done.
Thanks in advance.
Max