A literal string can't be bigger than 8192 characters

Just starting out? Need help? Post your questions and find answers here.
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

A literal string can't be bigger than 8192 characters

Post 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.

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

Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
PB
PureBasic Expert
PureBasic Expert
Posts: 7581
Joined: Fri Apr 25, 2003 5:24 pm

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

Post 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.
I compile using 5.31 (x86) on Win 7 Ultimate (64-bit).
"PureBasic won't be object oriented, period" - Fred.
User avatar
Danilo
Addict
Addict
Posts: 3037
Joined: Sat Apr 26, 2003 8:26 am
Location: Planet Earth

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

Post 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
User avatar
eddy
Addict
Addict
Posts: 1479
Joined: Mon May 26, 2003 3:07 pm
Location: Nantes

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

Post 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
Imagewin10 x64 5.72 | IDE | PB plugin | Tools | Sprite | JSON | visual tool
User avatar
Blue
Addict
Addict
Posts: 864
Joined: Fri Oct 06, 2006 4:41 am
Location: Canada

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

Post 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.
"That's not a bug..." said the programmer. "it's a feature! "
"Oh! I see..." replied the blind man.
phaselock.studio
User
User
Posts: 12
Joined: Wed Apr 13, 2022 10:08 pm
Location: Low Orbit

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

Post 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 : )
BarryG
Addict
Addict
Posts: 3292
Joined: Thu Apr 18, 2019 8:17 am

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

Post 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
Post Reply