Finding an item in a collection of types

Blitz3D Forums/Blitz3D Programming/Finding an item in a collection of types

Why not check against the gadget handle instead of the name? Just like images, sounds and meshes, gadgets have a handle number.

Type checkbox
    Field hnd
End Type

For i=1 to 5
    chk.checkbox = new checkbox
    chk\hnd = CreateButton(.......)
Next

Function FindChecked.checkbox()
    ; This function returns a chk type reference so you can use it like...
    ; chk.checkbox = FindChecked()

    For chk.checkbox = each checkbox
        If ButtonState(chk\hnd) = 1
            Return chk
        End If
    Next
End Function