[fpc-pascal] Constant strings can't be longer than 255 chars
Graeme Geldenhuys
graemeg.lists at gmail.com
Mon Jul 7 19:26:09 CEST 2008
Hi,
I've got a few functions defined with 'const' string parameters. When
I tried to pass a large string, I got the following error message. Why
is that? I thought string type can hold as much as the memory you
have in your system. I am using the following compiler mode in all my
units: {$mode objfpc}{$H+}
------------------------------
filedialog.lpr(142,56) Error: Constant strings can't be longer than 255 chars
filedialog.lpr(260) Fatal: There were 1 errors compiling module, stopping
------------------------------
Here is the methods I defined... It's the AText parameter that I'm
trying to pass large text 500-1000 characters.
class function Critical(const ATitle: string; const AText: string;
AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton: TfpgMsgDlgBtn =
mbNoButton): TfpgMsgDlgBtn;
class function Information(const ATitle: string; const AText:
string; AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton:
TfpgMsgDlgBtn = mbNoButton): TfpgMsgDlgBtn;
class function Question(const ATitle: string; const AText: string;
AButtons: TfpgMsgDlgButtons = [mbYes, mbNo]; ADefaultButton:
TfpgMsgDlgBtn = mbNo): TfpgMsgDlgBtn;
class function Warning(const ATitle: string; const AText: string;
AButtons: TfpgMsgDlgButtons = [mbOK]; ADefaultButton: TfpgMsgDlgBtn =
mbNoButton): TfpgMsgDlgBtn;
And this is how I normally call those functions... The examples
below work, but if AText contained more than 255 characters, it
doesn't compile. I really don't see the problem? Is the only way
around this problem, by first defining a local variable of type String
and then passing the variable? Not that I can see a difference
between that and what I'm trying to do!
TfpgMessageDialog.Information('Some Information...', 'And this is
where the text goes.', [mbOK], mbNoButton);
TfpgMessageDialog.Question('Some Question...', 'Did everything work
okay?', mbYesNo, mbNoButton);
Regards,
- Graeme -
_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/
More information about the fpc-pascal
mailing list