What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » # of characters in a message?

# of characters in a message?
Author: Message:
citricsquid
New Member
*

<div style="sexy;100%">

Posts: 13
33 / Male / Flag
Joined: Sep 2008
O.P. # of characters in a message?
Hi,
I have a string called "Something" and I want to check what the first # of characters are, for example 3. I then want to strip the first # (for example, 2) characters from the string.

How would I go about doing this? I don't know much of the language used by MSGPLUS, I'm just using examples and my knowledge of PHP to work it out as I go along :)

This post was edited on 11-15-2008 at 05:08 PM by citricsquid.
11-15-2008 04:53 PM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: # of characters in a message?
I suggest you have a look at a JavaScript String reference, such as the one at W3Schools. That should give you a good idea what methods you have.
  • To check the first X characters of a string:
    code:
    var strMessage = "/mycommand param1";
    if(strMessage.substr(0, 3) === "/my") {
       //First 3 characters equal "/my"
       //Do something useful here!
    }
    String.substr(X, Y) basically does the following: Give me the part of the string starting at position X containing at most Y characters. You could also use String.substring(X, Y), where Y is an ending position instead of a length. If you don't specify the second argument in substr() or substring(), it'll go on to the end of the string.
  • To strip the first X characters from a string:
    code:
    var strMessage = "one two three";
    var strPiece = strMessage.substr(4);
    //strPiece now contains "two three"
As you already have PHP knowledge, this should actually be piece of cake for you. Basically, String.substr(start, length) is the JScript equivalent for PHP's substr($string, $start, $length). The difference is that JScript does this in a more OOP-style. :)

This post was edited on 11-15-2008 at 05:25 PM by Matti.
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-15-2008 05:25 PM
Profile E-Mail PM Web Find Quote Report
citricsquid
New Member
*

<div style="sexy;100%">

Posts: 13
33 / Male / Flag
Joined: Sep 2008
O.P. RE: RE: # of characters in a message?
quote:
Originally posted by Matti
OOP-style. :)

Cheers :D
I was sure I read somewhere what MSGPLUS used wasn't Javascript, maybe I'm going mad :D :$

Thanks, should be easy to do this now.
11-15-2008 05:30 PM
Profile PM Web Find Quote Report
Volv
Skinning Contest Winner
*****

Avatar

Posts: 1233
Reputation: 31
35 / Male / Flag
Joined: Oct 2004
RE: # of characters in a message?
It uses JScript which is not the same as Javascript but awfully similar :p
11-15-2008 05:39 PM
Profile PM Find Quote Report
citricsquid
New Member
*

<div style="sexy;100%">

Posts: 13
33 / Male / Flag
Joined: Sep 2008
O.P. RE: RE: # of characters in a message?
quote:
Originally posted by Volv
It uses JScript which is not the same as Javascript but awfully similar :p

:o)
Cheers, I'll try and remember that :D
11-15-2008 05:43 PM
Profile PM Web Find Quote Report
Matti
Elite Member
*****

Avatar
Script Developer and Helper

Posts: 1646
Reputation: 39
32 / Male / Flag
Joined: Apr 2004
RE: # of characters in a message?
Mjeh, Plus! uses the JScript engine of the Windows Scripting Host which doesn't run in a browser and therefore doesn't have thewindow and document objects for interacting with the HTML document, but as for strings, numbers and other objects they're as good as identical for the beginning script developer. :)
Plus! Script Developer | Plus! Beta Tester | Creator of Countdown Live | Co-developer of Screenshot Sender 5

Found my post useful? Rate me!
11-15-2008 08:27 PM
Profile E-Mail PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On