This code will compile, but the Esp32 restarts continuously, see error in first post.
B4X:
#Region Project Attributes
#AutoFlushLogs: True
#CheckArrayBounds: True
#StackBufferSize: 300
#End Region
Sub Process_Globals
Public Serial1 As Serial
Public BC As ByteConverter
Public MyString As String = "00000"
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim DynString As String = "hi"
If DynString.Length>0 Then BC.ObjectCopy(DynString, MyString, MyString.Length)
Log(MyString)
End Sub
Constant strings can be optimized and stored in read-only memory.
Change your code to:
B4X:
Sub Process_Globals
Public Serial1 As Serial
Public BC As ByteConverter
Public MyString(10) As Byte
End Sub
Private Sub AppStart
Serial1.Initialize(115200)
Log("AppStart")
Dim DynString() As Byte = "hi"
If DynString.Length>0 Then BC.ObjectCopy(DynString, MyString, MyString.Length)
Log(MyString)
End Sub