On https://freebasic.net/wiki/KeyPgstring you mean? I think you are right, fixed-size apparently means that the size is determined at compile time and only a constant for the size can be used, but that is not very obvious form the manual page. I'll wait for other responses...
I guess I've never ever thought about it. To me "fixed-size string" is self-evident that it must be defined at compile time and would therefore require a constant expression. Dunno. I also think the error message is clear and points you in the right direction.
I note line:
A simpler and safer method for dynamic allocation /deallocation is to use the advanced New / Delete keyword (which itself also calls the constructor / destructor of the string object).
Could you provide an example of usage of this perhaps, I have not seen strings created this way.
Dim As String Ptr ps = New String
*ps = "FreeBASIC"
Print *ps
Delete ps
dodicat wrote:IA simpler and safer method for dynamic allocation /deallocation is to use the advanced New / Delete keyword (which itself also calls the constructor / destructor of the string object).
If using [C]Allocate, the code is less straightforward:
I wonder if the info about allocate/new/delete etc. could go in its own section somehow.
Most people reading the article won't be interested in how to store string descriptors in allocated memory, but nor do we want to remove that information.
I can't remember off the top of my head, does the wiki support custom subheadings?
counting_pine wrote:I can't remember off the top of my head, does the wiki support custom subheadings?
For the styles that are recognized well by the wiki and doc generator: FBWikiFbdocAction
For a custom heading can use: {{fbdoc item="section" value="Section"}}
To add a new fbdoc item section, for example {{fbdoc item="advanced"}} with some custom title, then need to update the wiki PHP and fbdoc generator - which is minor code changes.
counting_pine wrote:I wonder if the info about allocate/new/delete etc. could go in its own section somehow.
Most people reading the article won't be interested in how to store string descriptors in allocated memory, but nor do we want to remove that information.
- For the special case of var-len string dynamic allocation with Allocate/Callocate/Reallocate/Deallocate, the mandatory precautions to be taken are then described both on the 'String' page and on the 'Allocate'/'Callocate'/'Reallocate'/'Deallocate' page.
- For the case of var-len string dynamic allocation with New/Delete, as no precaution is to be taken (the implicit call to the constructor and the destructor doing all the work), nothing is then described on the 'New'/'Delete' page.