Recent

Author Topic: TMemo....help needed  (Read 8944 times)

jshand2010

  • Full Member
  • ***
  • Posts: 236
TMemo....help needed
« on: May 28, 2011, 01:42:35 pm »
hi guys.  just wondering how to get the total nukber of lines in your memo box.  please let me know.  i have tried tmemo.lines.....that doesn't work.
OpenSUSE Tumbleweed x86_64, Lazarus 2.2.0RC2 fixes branch, fpc 3.2.3 fixes branch

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: TMemo....help needed
« Reply #1 on: May 28, 2011, 01:53:51 pm »
YourMemo.Lines.Count
I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

Avishai

  • Hero Member
  • *****
  • Posts: 1021
Re: TMemo....help needed
« Reply #2 on: May 28, 2011, 01:54:16 pm »
I think it's Memo1.Lines.Count
Lazarus Trunk / fpc 2.6.2 / Win32

jshand2010

  • Full Member
  • ***
  • Posts: 236
Re: TMemo....help needed
« Reply #3 on: May 30, 2011, 01:17:47 pm »
thanks for your help

i have place in the meinformationChange procedure this code:

g := meinformation.Lines.Count;

i am unsure if this is working as yet;

the following i have coded in the same procedure:

for d := 1 to g do
  begin
      sm[d].information := meinformation.Lines[d];
 end;

this doesn't seem to work.  please help me.  also loading into the memo box is proving difficult for me as i have little knowledge for this control.

thanks again
OpenSUSE Tumbleweed x86_64, Lazarus 2.2.0RC2 fixes branch, fpc 3.2.3 fixes branch

eny

  • Hero Member
  • *****
  • Posts: 1646
Re: TMemo....help needed
« Reply #4 on: May 30, 2011, 02:00:48 pm »
this doesn't seem to work. 
Based on what? Debugger output?

Lines in a memo are numbered from 0.. Count-1.
Code: Pascal  [Select][+][-]
  1. g := meinformation.Lines.Count;
  2. //...
  3. for d := 0 to g-1 do
  4.   begin
  5.      // sm[d].information := meinformation.Lines[d];  <-- WHAT IS smd[d]?
  6.  end;
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

jshand2010

  • Full Member
  • ***
  • Posts: 236
Re: TMemo....help needed
« Reply #5 on: May 31, 2011, 12:25:30 am »
hi there
sm[d].information is an array of strings.
OpenSUSE Tumbleweed x86_64, Lazarus 2.2.0RC2 fixes branch, fpc 3.2.3 fixes branch

eny

  • Hero Member
  • *****
  • Posts: 1646
Re: TMemo....help needed
« Reply #6 on: May 31, 2011, 09:54:37 am »
hi there
sm[d].information is an array of strings.
Please post the type definitions.
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

jshand2010

  • Full Member
  • ***
  • Posts: 236
Re: TMemo....help needed
« Reply #7 on: May 31, 2011, 01:16:18 pm »
hi eny, below are the type definitions you asked for

type
  StaffMemo = record
    information: string;
  end;

under vars is:

sm: array[1..1000000] of StaffMemo;
OpenSUSE Tumbleweed x86_64, Lazarus 2.2.0RC2 fixes branch, fpc 3.2.3 fixes branch

fabienwang

  • Sr. Member
  • ****
  • Posts: 449
  • Lazarus is the best
    • My blog
Re: TMemo....help needed
« Reply #8 on: May 31, 2011, 01:33:35 pm »
by doing, array[1..1000000], you will take a lot of memory space at the declaration.
as you won't use all of them, i suggest you to define the array dynamically,
m: array of StaffMemo;

maintain a global counter: nbsm: Integer;
and each time you want to add lines into it:
Inc(nbsm);
setLength(sm, nbsm);

I'm using Arch Linux.
Known for: CPickSniff, OpenGrabby
Contributed to: LazPaint

eny

  • Hero Member
  • *****
  • Posts: 1646
Re: TMemo....help needed
« Reply #9 on: May 31, 2011, 01:53:37 pm »
hi eny, below are the type definitions you asked for

Alrighty, now what is that you wish to accomplisch?
Because your initial question has already been answered.

(As FabienWang said, you have defined a rather big static array...)
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

liewald

  • Full Member
  • ***
  • Posts: 144
Re: TMemo....help needed
« Reply #10 on: May 31, 2011, 02:06:02 pm »
Why are you copying the Memo to an array of strings? Memo.lines is essentially a dynamic array of strings anyway with some extra handling built in.  Any line can be accessed using memo1.lines
  • like any normal array. I don’t really understand what you are trying to achieve here.

eny

  • Hero Member
  • *****
  • Posts: 1646
Re: TMemo....help needed
« Reply #11 on: May 31, 2011, 04:59:57 pm »
I don’t really understand what you are trying to achieve here.
Hence my question...
All posts based on: Win10 (Win64); Lazarus 3_4  (x64) 25-05-2024 (unless specified otherwise...)

 

TinyPortal © 2005-2018