B4R Question Objects and assignment

alvinmb

Member
Licensed User
Longtime User
I'm using the example to read configuration data from the esp8266, where it returns the values as Objects.
I want to make these objects available outside of the sub so I created Public variables and tried to assign these objects. for example ClientID = Objects(0)

However I get an error
"cannot modify constant variable. (Non primitive. Non primitive variables are always constants)"
What am I doing wrong?


B4X:
GetStoredData
    'Read settings from EEPROM
    Dim length As Byte = GetStoredDataLength
    Log("Length of data is :", length)
    
    If length > 0 Then 'No data found
        Dim Data() As Byte = eeprom.ReadBytes(2, length)
        Dim Objects() As Object = serializator.ConvertBytesToArray(Data, ObjectsBuffer)

        'Read and log EPROM data
        For Each o As Object In Objects
            Log(o)
        Next
        
    Else
        Log("Network data not found, use AP Mode to set configuration")
        Message("NoNetworkData")
    End If
    
    'Read SSIS and password from EPROM
    ClientID  = Objects(0)
    SSID  = Objects(1) 'ignore
    SSIDPassword = Objects(2) 'ignore
    ServerIP = Objects(3)
    MqttUsername = Objects(4)
    MqttPassword = Objects(5)
    
End Sub
 
Top