SMS Dialog Count Charaters

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

SMS Dialog Count Charaters

Post by CyberCitizen » Wed Jan 13, 2010 3:46 am

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.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jan 13, 2010 5:30 am


User avatar
CyberCitizen
Automation Wizard
Posts: 721
Joined: Sun Jun 20, 2004 7:06 am
Location: Adelaide, South Australia

Post by CyberCitizen » Wed Jan 13, 2010 5:34 am

Thanks For That JRL. That Helps With The Limiting Of The Dialog Box, However Its The Counter That I Am More Concerned About.

The Example You Gave Makes It Reliant On Another Scp File, I Am Trying To Keep This As A Standalone Exe At Present.
FIREFIGHTER

User avatar
JRL
Automation Wizard
Posts: 3526
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Post by JRL » Wed Jan 13, 2010 2:20 pm

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

allthenames
Newbie
Posts: 18
Joined: Wed Aug 18, 2010 5:51 pm

character limiting

Post by allthenames » Thu Jun 28, 2012 5:03 am

Hi, I'm looking for something similar however without the input box. Something that will simply cut a variable to 40 characters.
-Ben

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Re: character limiting

Post by Me_again » Thu Jun 28, 2012 3:58 pm

allthenames wrote:Hi, I'm looking for something similar however without the input box. Something that will simply cut a variable to 40 characters.
Sounds too easy, maybe I'm missing something but can't you use MidStr> ?


Edit: I now see you posted this in two places, at least you got the same answer both times :lol:

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