Page 1 of 1

Need to see the length of MEMO Edit box as it is filled.

Posted: Tue Jun 10, 2008 3:42 pm
by Ollie
Hi all.

I am writing an application that sends an SMS. The maximum characters I want the user to enter is 160. I would like to show the user how many chars he has typed so far.

The code below doesn't work because it moves the cursor to the start of the memo field everytime a key is pressed, so typing "ABC" produces "CBA".

How can I do this?

Code: Select all

 
DEFINE DIALOG oDlg RESOURCE "SMS"
REDEFINE GET cCellnumber ID 4001 OF oDlg UPDATE
REDEFINE GET cMessage MEMO ID 4002 OF oDlg UPDATE on CHANGE oDlg:UPDATE()
REDEFINE SAY ID 4003 PROMPT ALLTRIM(STR(LEN(cMessage)))+" of 160 characters used" UPDATE

REDEFINE BUTTON ID 10 of oDlg ACTION ( sendsms( cCellnumber, cMessage ), oDlg:END() ) ) )  //OK

REDEFINE BUTTON ID 20 of oDlg ACTION ( oDlg:END() )  //Cancel

Posted: Thu Jun 12, 2008 7:30 am
by Antonio Linares
Ollie,

Try it this way:

REDEFINE GET cMessage MEMO ID 4002 OF oDlg ON CHANGE oSay:Refresh()

REDEFINE SAY oSay ID 4003 PROMPT ALLTRIM(STR(LEN(cMessage)))+" of 160 characters used"

Posted: Thu Jun 12, 2008 8:18 am
by Ollie
Works perfectly.

Thanks.