B4R Question Converting an array to a string

janderkan

Well-Known Member
Licensed User
Longtime User
Years ago I had the same problem and it was solved as you can see in this post
https://www.b4x.com/android/forum/t...eeprom-in-mqtt-initialize2.72492/#post-461148

Now I have updated to Arduino 2.3.4 and B4R 4.0 (I dont know if this is the problem, because I have been away from B4R for some time)

When I try to use ObjectCopy , that was part of the solution , I get a 'Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.'
I can only copy array to array, not string to string.

That leaves me with a problem with Mqtt library as you can see in this post
https://www.b4x.com/android/forum/threads/how-to-use-a-string-from-eeprom-in-mqtt-initialize2.72492/

I have tried to copy the eeprom data to a GlobalStore but the problem with Mqtt library remains.

Mqtt library needs a literal string and byteconverter.StringFromBytes returns a dynamic string.

Anyone have any ideas and I will be very happy.
 

emexes

Expert
Licensed User
Does your app from 2016 still compile and run without that error, in the updated Arduino and B4R environments?

as in, trying to narrow down whether the new error is due to:

1/ something different about the development environments, or
2/ something different about your code
 
Last edited:
Upvote 0

emexes

Expert
Licensed User
When I try to use ObjectCopy , that was part of the solution , I get a 'Guru Meditation Error: Core 1 panic'ed (LoadStoreError). Exception was unhandled.'
I can only copy array to array, not string to string.

Are you saying that this code that
takes a dynamic string and copies it to a global variable:
B4X:
Sub Process_Globals
   Public Serial1 As Serial
   Private bc As ByteConverter
   Private GlobalString As String = "000000000000000000000000" 'must be long enough to hold the string
End Sub

Private Sub AppStart
   Serial1.Initialize(115200)
   Dim DynamicString As String = bc.StringFromBytes("m21.cloudmqtt.com".GetBytes)
   bc.ObjectCopy(DynamicString, GlobalString, DynamicString.Length + 1)
   'Now you can use GlobalString
End Sub

no longer works?
 
Last edited:
Upvote 0

janderkan

Well-Known Member
Licensed User
Longtime User
Yes , the only problem for now is the object copy.
Yes , the short snippet from Erel does create a panic when trying to copy a string to a string.
 
Upvote 0
Top