[Lazarus] strcat problem

David W Noon david.w.noon at googlemail.com
Sat Jun 25 00:59:16 CEST 2016


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, 24 Jun 2016 22:46:45 +0200, Koenraad Lelong
(lazarus2 at de-brouwerij.be) wrote about "Re: [Lazarus] strcat problem"
(in <576D9C35.4060107 at de-brouwerij.be>):

[snip]
> I think we're spoiled (fpc users), but not too much. The original
> c-code was this : char *TEXT= "\n\ Now is the winter of our
> discontent\n\ Made glorious summer by this sun of York;\n\ And all
> the clouds that lour'd upon our house\n\ In the deep bosom of the
> ocean buried.\n\ Now are our brows bound with victorious
> wreaths;\n\ Our bruised arms hung up for monuments;\n\ Our stern
> alarums changed to merry meetings,\n\ Our dreadful marches to
> delightful measures.\n\ Grim-visaged war hath smooth'd his wrinkled
> front;\n\ And now, instead of mounting barded steeds\n\ To fright
> the souls of fearful adversaries,\n\ He capers nimbly in a lady's
> chamber\n\ To the lascivious pleasing of a lute.\n\ ";

That is some ugly code, even for C. I would have written it differently.

> I had to "improvise" and somehow put together that string which is 
> really a constant here, or put that whole string on one line. Or
> does fpc have a similar construct to break strings in different
> lines like this c-code does ?

  const
     TEXT : ansistring =
        #10'Now is the winter of our discontent'#10
        'Made glorious summer by this sun of York;'#10
        'And all the clouds that lour''d upon our house'#10
        'In the deep bosom of the ocean buried.'#10
        'Now are our brows bound with victorious wreaths;'#10
        'Our bruised arms hung up for monuments;'#10
        'Our stern alarums changed to merry meetings,'#10
        'Our dreadful marches to delightful measures.'#10
        'Grim-visaged war hath smooth''d his wrinkled front;'#10
        'And now, instead of mounting barded steeds'#10
        'To fright the souls of fearful adversaries,'#10
        'He capers nimbly in a lady''s chamber'#10
        'To the lascivious pleasing of a lute.'#10#0;

Note that '\n' is actually #10, not #13.

You can now use @TEXT as your PChar pointer value.
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
david.w.noon at googlemail.com (David W Noon)
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2

iEYEARECAAYFAldtu0QACgkQogYgcI4W/5QgjACfb/WbAPNmHfs+X5CeP0nqjnzv
ZNsAnibU3Kf+z6ih+r0DjDXCMTZOQnH6
=OQIa
-----END PGP SIGNATURE-----



More information about the Lazarus mailing list