Recent

Author Topic: Display in a TMemo  (Read 2037 times)

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Display in a TMemo
« on: March 01, 2019, 01:04:04 am »
Maybe this can't be done.

I would like to do the following:

MemoString.Lines.ADD(' Present := IsWordPresent('Day', aString, [' ']);');

However the compiler gives an error on the single quotes.
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

dbannon

  • Hero Member
  • *****
  • Posts: 2791
    • tomboy-ng, a rewrite of the classic Tomboy
Re: Display in a TMemo
« Reply #1 on: March 01, 2019, 02:05:57 am »
You need to look at the location of single quotes.

Maybe what you want is (without trying it) -

Code: Pascal  [Select][+][-]
  1. MemoString.Lines.ADD(' Present := ' + booltostr(IsWordPresent('Day', aString, [' '] ), True) );
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: Display in a TMemo
« Reply #2 on: March 01, 2019, 02:09:47 am »
If for what ever reason you are trying to put all of this in a string, although you may mean something else , look at this.
Code: Pascal  [Select][+][-]
  1. 'Present := IsWordPresent(''Day'', aString, ['' '']);';
  2.  

But I am sure you meant this..
Code: Pascal  [Select][+][-]
  1. Mmeo1.Lines.Add(Present.ToString);
  2.  
  3.  

Ect
The only true wisdom is knowing you know nothing

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Display in a TMemo
« Reply #3 on: March 01, 2019, 02:25:08 am »

Restated:
 I would like to display in Memo1"

    "Present := IsWordPresent('Day', aString, [' ']); "

 However when I code the following I get an error of the single quotes in the following line of code.

    MemoString.Lines.ADD(' Present := IsWordPresent('Day', aString, [' ']);');
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

JLWest

  • Hero Member
  • *****
  • Posts: 1293
Re: Display in a TMemo
« Reply #4 on: March 01, 2019, 02:29:38 am »
@jamie

That's It;
FPC 3.2.0, Lazarus IDE v2.0.4
 Windows 10 Pro 32-GB
 Intel i7 770K CPU 4.2GHz 32702MB Ram
GeForce GTX 1080 Graphics - 8 Gig
4.1 TB

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: Display in a TMemo
« Reply #5 on: March 01, 2019, 02:51:39 am »
When you end a Quote and start another with no items between the compiler will assume you want to
actually use a quote literal in your string.

So as a single character you can do this...
''''
that is 4 " ' ".
The first ' starts the string, the next two together assumes you want a " ' " and the last one ends the string.

in this case however, its only a character so you can do this

MyCharVar := '''';

The only true wisdom is knowing you know nothing

 

TinyPortal © 2005-2018