string array problem

For general Flowcode discussion that does not belong in the other sections.
Post Reply
Maverick
Posts: 69
http://meble-kuchenne.info.pl
Joined: Wed Dec 02, 2020 10:58 am
Has thanked: 27 times
Been thanked: 8 times

string array problem

Post by Maverick »

Any suggestions as to why the attached flowcode appears to add the array index to the end of the string to be printed apart from the last. i have tried it with a ssd1306 display with the same result. this is simulation only, I haven't tried actual hardware yet
Attachments
ssd1322_new_rig_16f18877.fcfx
(15.62 KiB) Downloaded 130 times

mnfisher
Valued Contributor
Posts: 1462
Joined: Wed Dec 09, 2020 9:37 pm
Has thanked: 136 times
Been thanked: 713 times

Re: string array problem

Post by mnfisher »

The strings are 24 characters - if you allow space for a \0 end of string marker then all is well (set string length to 25 in this case).

It looks like Print is looking for a \0 character as end of string rather than using the length passed (FC passes string and str_length to a function)

Martin

BenR
Matrix Staff
Posts: 1926
Joined: Mon Dec 07, 2020 10:06 am
Has thanked: 503 times
Been thanked: 686 times

Re: string array problem

Post by BenR »

Hello,

It looks like it's probably a bug on our end to do with multidimensional strings without null bytes. The Length$ function is maybe being passed the entire size of the array rather than the correct array chunk size.

We will look into solving it in the application but for now the best practise would be to use Martins suggestion and make room for the null bytes to be automatically added for you. In general it is good coding practise to allow for an extra byte in your string variable to make room for the null.

Post Reply