Page 1 of 1

String Length

Posted: Fri Aug 11, 2017 8:04 pm
by Docara
Hi

Would it be possible to have the option to automatically reserve the precise string length?

At the moment FC defaults to 20 locations why not just analyse the length and reserve accordingly.

Matt

Re: String Length

Posted: Fri Aug 11, 2017 10:16 pm
by kersing
How would Flowcode know what length you need? You might append to strings, get data from external sources etc. If you know the size you can specify the required size yourself: String name[size]
(Being a C programmer I still declare string sizes one element larger than the number of characters for the terminating zero)

Re: String Length

Posted: Sat Aug 12, 2017 12:07 am
by Docara
Hi Kesing,

Like I said an option to have it. To give this some context I am working on displaying scrolling message text on an LCD display, some of which needs to be joined together. It would have been nice to use the length$() command and then be able to amend the reserved buffer space if need be other than arbitrarily reserve a chunk arbitrarily

Matt

Re: String Length

Posted: Sat Aug 12, 2017 9:40 am
by kersing
Matt,

All memory allocations are done at compile time, so the is no way to change them at runtime. And if you know the required size you can set it yourself in stead of the arbitrary size.