Page 1 of 1

A literal string can't be bigger than 8192 characters

Posted: Sat Sep 20, 2014 9:41 pm
by eddy
Hi,
Do strings have a maximum length ?
If yes, is there a way to retrieve a longer string from DLL procedure ?

Code: Select all

ProcedureDLL.s GetDialogXML()
   Global xml.s="<dialog>"+
                "......"+
                "......"+
                "......"+
                "</dialog>"
   
   ProcedureReturn xml
EndProcedure

Code: Select all

--------------------------------------------------------------------------------
  Building 'DLL'...
--------------------------------------------------------------------------------
Including: PluginInclude.pbi
Line 1126: A literal string can't be bigger than 8192 characters.

--------------------------------------------------------------------------------
  Building 'DLL - x86'...
--------------------------------------------------------------------------------
Using compiler: PureBasic 5.30 (Windows - x86)
Including: PluginInclude.pbi
Line 1126: A literal string can't be bigger than 8192 characters.

--------------------------------------------------------------------------------


Re: A literal string can't be bigger than 8192 characters

Posted: Sun Sep 21, 2014 1:11 am
by PB
> Do strings have a maximum length ?

Runtime strings: no, they're unlimited.

A literal string is different: they're strings that you've physically
typed into the IDE. These have a limit of 8192 characters.

Re: A literal string can't be bigger than 8192 characters

Posted: Sun Sep 21, 2014 1:51 am
by Danilo
eddy wrote:If yes, is there a way to retrieve a longer string from DLL procedure ?
Just split it up:

Code: Select all

ProcedureDLL.s GetDialogXML()
   Global xml.s="<dialog>"+
                "......"
          xml.s+"......"+
                "......"+
                "</dialog>"
   
   ProcedureReturn xml
EndProcedure

Re: A literal string can't be bigger than 8192 characters

Posted: Sun Sep 21, 2014 1:59 am
by eddy
Danilo wrote:
eddy wrote:If yes, is there a way to retrieve a longer string from DLL procedure ?
Just split it up:

Code: Select all

ProcedureDLL.s GetDialogXML()
   Global xml.s="<dialog>"+
                "......"
          xml.s+"......"+
                "......"+
                "</dialog>"
   
   ProcedureReturn xml
EndProcedure
I see.
Thanks

Re: A literal string can't be bigger than 8192 characters

Posted: Wed Jun 08, 2016 9:43 pm
by Blue
This limitation, and the distinction between a string literal and a string variable should really be spelled out in the Help file, in the "Variables & Types" page.

There is nothing obvious about it, but there is no explanation given about it.

Re: A literal string can't be bigger than 8192 characters

Posted: Tue Jul 05, 2022 9:43 pm
by phaselock.studio
Danilo wrote: Sun Sep 21, 2014 1:51 am
eddy wrote:If yes, is there a way to retrieve a longer string from DLL procedure ?
Just split it up:

Code: Select all

ProcedureDLL.s GetDialogXML()
   Global xml.s="<dialog>"+
                "......"
          xml.s+"......"+
                "......"+
                "</dialog>"
   
   ProcedureReturn xml
EndProcedure
Thank you for this : )

Re: A literal string can't be bigger than 8192 characters

Posted: Tue Jul 05, 2022 9:59 pm
by BarryG
Danilo wrote: Sun Sep 21, 2014 1:51 amJust split it up
Or get it from an XML/TXT file directly (if the content doesn't change):

Code: Select all

ProcedureDLL.s GetDialogXML()
  Global xml.s=PeekS(?TXT_Start,-1,#PB_Ascii)
  ProcedureReturn xml
EndProcedure

DataSection
  TXT_Start:
  IncludeBinary "C:\Path\To\Large\XML_file.xml"
  Data.c 0 ; End of text marker.
  TXT_End:
EndDataSection