B4R Question Reading GlobalStore values

RJB

Active Member
Licensed User
Hi,
Is there any way to index global store reading? The below code achieves the required result but isn't very elegant
Thanks
B4X:
    Dim Data() As Byte
    Select Line
        Case 0
            If GlobalStore.Slot0 <> Null Then Data = (GlobalStore.Slot0)
        Case 1
            If GlobalStore.Slot1 <> Null Then Data = (GlobalStore.Slot1)
        Case 2
            If GlobalStore.Slot2 <> Null Then Data = (GlobalStore.Slot2)
        Case 3
            If GlobalStore.Slot3 <> Null Then Data = (GlobalStore.Slot3)
        Case 4
            If GlobalStore.Slot4 <> Null Then Data = (GlobalStore.Slot4)
        Case 5
            If GlobalStore.Slot5 <> Null Then Data = (GlobalStore.Slot5)
        Case 6
            If GlobalStore.Slot6 <> Null Then Data = (GlobalStore.Slot6)
        Case 7
            If GlobalStore.Slot7 <> Null Then Data = (GlobalStore.Slot7)
        Case 8
            If GlobalStore.Slot8 <> Null Then Data = (GlobalStore.Slot8)
        Case 9
            If GlobalStore.Slot9 <> Null Then Data = (GlobalStore.Slot9)
        Case 10
            If GlobalStore.Slot10 <> Null Then Data = (GlobalStore.Slot10)
        Case 11
            If GlobalStore.Slot11 <> Null Then Data = (GlobalStore.Slot11)
        Case 12
            If GlobalStore.Slot12 <> Null Then Data = (GlobalStore.Slot12)
        Case 13
            If GlobalStore.Slot13 <> Null Then Data = (GlobalStore.Slot13)
        Case 14
            If GlobalStore.Slot14 <> Null Then Data = (GlobalStore.Slot14)
        Case 15
            If GlobalStore.Slot15 <> Null Then Data = (GlobalStore.Slot15)
        Case 16
            If GlobalStore.Slot16 <> Null Then Data = (GlobalStore.Slot16)
        Case 17
            If GlobalStore.Slot17 <> Null Then Data = (GlobalStore.Slot17)
        Case 18
            If GlobalStore.Slot18 <> Null Then Data = (GlobalStore.Slot18)
        Case 19
            If GlobalStore.Slot19 <> Null Then Data = (GlobalStore.Slot19)
    End Select
 

RJB

Active Member
Licensed User
OK thanks. That's a shame.
FYI: It is in fact very useful as the global store is set in another sub and is the only way I've found to transfer a string from one sub to another. The Data variable is used in the sub it is declared. The code here is stripped out to show only what is required. I have read and understood Memory, Variables and Objects. The reference to GlobalStore in it and it's importance are a little understated though!
Edit: I should explain, I am using CallsubPlus so can't pass the strings as parameters
 
Last edited:
Upvote 0
Top