58 charecters in a memo

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
CatBreath
Junior Coder
Posts: 32
Joined: Fri Jul 08, 2005 6:12 pm

58 charecters in a memo

Post by CatBreath » Tue Sep 06, 2005 12:05 pm

I need a memo that the user can enter no more than 58 chars to it.

How can this be done?

Thanks!

User avatar
support
Automation Wizard
Posts: 1450
Joined: Sat Oct 19, 2002 4:38 pm
Location: London
Contact:

Post by support » Tue Sep 06, 2005 12:37 pm

Do you want this on a modal dialog or non-modal dialog?

A modal dialog is easy:

Dialog>Dialog1
Caption=Dialog1
Width=213
Height=214
Top=161
Left=154
Memo=msMemo1,8,16,185,129,
Button=OK,8,152,75,25,2
EndDialog>Dialog1

//Modal Method
Label>DoDialog
Show>Dialog1,r
Let>l={length(%Dialog1.msMemo1%)}
If>l>58
MessageModal>Text must be 58 or less chars long
ResetDialogAction>Dialog1
Goto>DoDialog
Endif

If a non-modal dialog you need to decide how you want to do the test. The following checks continuously and truncates the entered text so the user can't physically enter more than 58 chars. But you'd probably want to make this a little less brutal:

//Non Modal Method
Show>Dialog1
Label>DlgLoop
GetDialogAction>Dialog1,r
Let>l={length(%Dialog1.msMemo1%)}
If>l>58
Let>Dialog1.msMemo1={Copy(%Dialog1.msMemo1%,1,58)}
ResetDialogAction>Dialog1
EndIf
If>r=2,exit
Goto>DlgLoop

Label>exit
MessageModal>Dialog1.msMemo1
MJT Net Support
[email protected]

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts