Bug? Global string(s) compiler error

Bert Oudshoorn

Member
Licensed User
A one-dimensional string is not allowed, but an array of strings seems to work?

Sub Process_Globals
Private x As String
Private y() As String
End Sub

Private Sub AppStart
x = "123"
y(0) = "123"
End Sub

'Error compiling program. Error description: Cannot set a Const variable (global
'non-primitive variables are always constants). Occurred on line: 14, x = "123"
 

Bert Oudshoorn

Member
Licensed User
Thank you! Indeed, that works! Even a flexible length :)
s(0) = "abc" : Log(s(0)," ",s(0).length)
s(0) = "abcd" : Log(s(0)," ",s(0).length)
s(0) = "ab" : Log(s(0)," ",s(0).length)
 

Bert Oudshoorn

Member
Licensed User
Is this a restriction? No return value of a (ByteConverter) SubString to a Global
Sub Process_Globals
Public Serial1 As Serial
Private bc As ByteConverter
Private s(2) As String
'Private b(4) As Byte 'here not allowed
End Sub
Private Sub AppStart
Serial1.Initialize(115200) : Delay(3000) : Log("AppStart")
Dim b(4) As Byte '<<--- here
s(1) = "abcd"
b = bc.SubString(s(1),1) : Log(b) 'bcd
OtherThings
EndSub
 
Last edited:
Top