I need a memo that the user can enter no more than 58 chars to it.
How can this be done?
Thanks!
58 charecters in a memo
Moderators: Dorian (MJT support), JRL
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
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]
[email protected]