Jump to content

UniMemo Count Chars


ravedadave

Recommended Posts

53 minutes ago, Sherzod said:

Hi,

Sorry, for what purpose do you want to use it?

Hi,

Thanks for the reply.

So I need to count the characters entered into an TUniMemo (i.e. You have entered 64 characters of 160)

it's for sending an SMS Text to let the end user know when they are reaching the length of the maximum text.

 

Link to comment
Share on other sites

56 minutes ago, ravedadave said:

So I need to count the characters entered into an TUniMemo (i.e. You have entered 64 characters of 160)

it's for sending an SMS Text to let the end user know when they are reaching the length of the maximum text.

Ok.

It is better to use a client-side solution.

For example:

1. UniLabel, UniMemo1

2. UniMemo1.ClientEvents.UniEvents:

function beforeInit(sender, config)
{
    config.enforceMaxLength = true;
    config.maxLength = 160;
}

3. UniMemo1.ClientEvents.ExtEvents:

function keyup(sender, e, eOpts)
{
    MainForm.UniLabel1.setText('You have entered '+ sender.getValue().length +' characters of 160');
}

4. 

procedure TMainForm.UniFormReady(Sender: TObject);
begin
  UniLabel1.JSInterface.JSCode(#1'.setText(''You have entered ''+'+ UniMemo1.JSName +'.getValue().length + ''  characters of 160'');');
end;

 

Link to comment
Share on other sites

procedure TMainForm.UniMemoChange(Sender: TObject);
begin
  uniLabel_Char.Caption := IntToStr(Length(StringReplace(StringReplace(UniMemo. Lines.Text, #10, '', [rfReplaceAll]), #13, '', [rfReplaceAll])));
end;

 

sorry...wrong post

Link to comment
Share on other sites

On 6/29/2020 at 11:23 AM, Sherzod said:

Ok.

It is better to use a client-side solution.

For example:

1. UniLabel, UniMemo1

2. UniMemo1.ClientEvents.UniEvents:


function beforeInit(sender, config)
{
    config.enforceMaxLength = true;
    config.maxLength = 160;
}

3. UniMemo1.ClientEvents.ExtEvents:


function keyup(sender, e, eOpts)
{
    MainForm.UniLabel1.setText('You have entered '+ sender.getValue().length +' characters of 160');
}

4. 


procedure TMainForm.UniFormReady(Sender: TObject);
begin
  UniLabel1.JSInterface.JSCode(#1'.setText(''You have entered ''+'+ UniMemo1.JSName +'.getValue().length + ''  characters of 160'');');
end;

 

Thank You!

 

Very much appreciated,

 

Kind Regards. Dave

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...