Hi Guys,
Haven't Been On Here For A While, Been Pretty Busy With Work.
I Now Have A Need To Create A New Script That I Can Use For The Sending Of SMS Messages Via Email.
What I Am After Is A Dialog Box That Counts Characters While The User Is Typing.
Eg A Standard SMS Message Is 160 characters (including spaces)
I Am After A Dialog Box That The User Can Type Into & It Counts Down From 160 To Zero. It Can Go Into The Minus As Well, But I Would Prefer It To Not Allow You To Type Anymore Characters In The Dialog.
The Counter Is The Main Thing I Am After.
Note I Only Have MS v9. I Have MS Since v4-5 I Can't Remember, But I Can't Afford To Upgrade Anymore, Now That I Am In A Government Role, They Wont Pay For The Upgrade So I Have To Source It Myself, Which I Can't Do At Present.
SMS Dialog Count Charaters
Moderators: Dorian (MJT support), JRL
- CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
SMS Dialog Count Charaters
FIREFIGHTER
- CyberCitizen
- Automation Wizard
- Posts: 721
- Joined: Sun Jun 20, 2004 7:06 am
- Location: Adelaide, South Australia
Here is the "Dialog Field Length Limiting" example modified so that the included file is part of the main script. I have commented the lines added to provide and display the current characters remaining count.
Code: Select all
//Added a variable for the total length just for ease of explanation
Let>StringLength=160
Dialog>Dialog1
Caption=Field Length Limiting
Width=193
Height=239
Top=0
Left=CENTER
Max=0
Min=0
Resize=0
//Added a label to accept the current remaining characters count
Label=msLabel1,72,16,True
Edit=msEdit1,32,40,121,
Memo=msMemo1,32,72,121,65,
Button=Ok,56,168,75,25,3
Default=Ok
EndDialog>Dialog1
Show>dialog1
Label>Loop
GetDialogAction>dialog1,res1
If>res1=2,EOF
If>res1=3,Process
//Dialog field length limit usage:
//Gosub>FieldLimit,Character Limit,Dialog Name,Object Name
//Place one GoSub>FieldLimit line for each object that needs a length limit
GoSub>FieldLimit,StringLength,dialog1,msedit1
GoSub>FieldLimit,8,dialog1,msMemo1
//Added a line to subtract the current characters count from the total characters count
//providing the remaining characters count. This number is dynamically displayed as
//msLabel1 in Dialog1
Let>Dialog1.mslabel1=%StringLength%-%Dialog1.msEdit1.Length%
Goto>Loop
SRT>Process
MDL>%dialog1.msedit1%%CRLF%%dialog1.msMemo1%
ResetDialogAction>dialog1
Press End
END>Process
SRT>FieldLimit
Let>value=%FieldLimit_var_2%.%FieldLimit_var_3%
StringReplace>value,%CR%,,value
Length>%value%,elen
Separate>value,%LF%,var
If>var_count>1
If>var_%var_count%=
Sub>var_count,2
Else
Sub>var_count,1
EndIf
Let>FieldLimit_var_1={%FieldLimit_var_1%+(%var_count%*1)}
EndIf
If>elen>%FieldLimit_var_1%
MidStr>%value%,1,%FieldLimit_var_1%,value
Let>%FieldLimit_var_2%.%FieldLimit_var_3%=%value%
LibFunc>user32,SetFocus,SetRes,0
ResetDialogAction>%FieldLimit_var_2%
EndIf
//Added a line to uniquely identify the current edit box character count
Let>%FieldLimit_var_2%.%FieldLimit_var_3%.Length=%elen%
END>FieldLimit
Label>EOF
-
- Newbie
- Posts: 18
- Joined: Wed Aug 18, 2010 5:51 pm
character limiting
Hi, I'm looking for something similar however without the input box. Something that will simply cut a variable to 40 characters.
-Ben
-
- Automation Wizard
- Posts: 1101
- Joined: Fri Jan 07, 2005 5:55 pm
- Location: Somewhere else on the planet
Re: character limiting
Sounds too easy, maybe I'm missing something but can't you use MidStr> ?allthenames wrote:Hi, I'm looking for something similar however without the input box. Something that will simply cut a variable to 40 characters.
Edit: I now see you posted this in two places, at least you got the same answer both times