What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » Beginning Javascript [Part 1]

Beginning Javascript [Part 1]
Author: Message:
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
O.P. Beginning Javascript [Part 1]
Hello,

I decided to make a javascript tutorial which shows the programming basics and some javascript basics. Sorry about my quite bad english, I hope you understand mostly stuff, if you don't, write a reply.

Comments:
Comments simply comment to the code :). A comment is like this:
code:
// HELLO I'M HERE
The program will not execute that part. I'm using comments to help you out in a code. You don't have to remove them to make your script work.

Variables
Variables could be many different types, here's some of them (AFAIK):

string: this is an array of characters, so it could be "Hello dear mama!!!111" or "õ!  [=", or anything. When declaring strings do like this:
code:
// Creates a string called MyString, and sets it's value to "Hello World"
var MyString = "Hello World";


integer: a integer is a number, without decimals, some values could be 1, 5, 1000, 3245. When declaring integers do like this:
code:
// Creates a integer called MyInteger and sets it's value to 5
var MyInteger = 5;


floats: floats are numbers with decimals. Declare a float like this:
code:
// Creates a float with the value 5.31
var MyFloat = 5.31;


boolean: booleans are true or false, when declaring do:
code:
// Declares 2 booleans and gives them values.
var MyBoolean = true;
var MyBoolean2 = false;


That's variables, hope you now got a clue about it.

Why variables?
It's simply to storage stuff. For example, if you'd like to spam your contact you could do:
code:
SendMessageToContact("Hello!");
SendMessageToContact("Hello!");
SendMessageToContact("Hello!");
SendMessageToContact("Hello!");

But it's much easier to read if you did:
code:
var Message = "Hello!";
SendMessageToContact(Message);
SendMessageToContact(Message);
SendMessageToContact(Message);
SendMessageToContact(Message);

Note: That code doesn't work.

Math:
Now, lets include some math :P
'The most common math-operators are + (plus) - (minus) / (divide) * (times) = (set) += (add to current value) != (not is). Here's some code snippets to use those.
Integers:
code:
var myInt = 1+1; // myInt is now 2
var anotherInt = myInt * 2; // anotherInt is now 4
myInt += anotherInt; // myInt is now myInt + anotherInt, and that's 4+2=6


Strings:
code:
var MyString = "I love scripting";
var anotherString = MyString + " Javascript"; // anotherString is now "I love scripting Javascript"

-, *,  /, doesn't work while it's a string.

Floats: Same as integers.

Booleans:
code:
var myBoolean = true;
var anotherBoolean != myBoolean; // anotherBoolean is now false.


Statments:
if-statement: a if-statment checks if a expression is true or false and then does action. Should be like this:
code:
var myVar = true; // a boolean
if(myVar == true){
    // Do code here which will be executed when myVar is true
}
elseif(myVar == false) {
    // Do code here which will be executed when myVar is false
}
else {
    // If myVar isn't neither false or true.
}


switch-statement: The switch-statement is like the if-statement but more clear.
code:
myInt = 1;
switch(myInt){
  case 1:
     // do what to do if myInt is 1
  case 2:
  case 3:
     // because case 2 is nothing it will still go to 3, so put here what to do if
     //myInt 2 or 3
}


I hope I'll have time to do a second one, which will include Loops, MsgPlus! Scriping usage, Arrays and more!!
Thank you, I hope you enjoyed.

vikke
10-01-2006 06:53 AM
Profile E-Mail PM Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: Beginning Javascript [Part 1]
for further reading look at..

variables : http://developer.mozilla.org/en/docs/Core_JavaScr....5_Guide:Variables
Operators: http://developer.mozilla.org/en/docs/Core_JavaScr..._Guide%3AOperators
conditional statements (If , else , switch...): http://developer.mozilla.org/en/docs/Core_JavaScr...itional_Statements

This post was edited on 10-01-2006 at 07:45 AM by -dt-.
[Image: dt2.0v2.png]      Happy Birthday, WDZ
10-01-2006 07:15 AM
Profile PM Web Find Quote Report
CookieRevised
Elite Member
*****

Avatar

Posts: 15517
Reputation: 173
– / Male / Flag
Joined: Jul 2003
Status: Away
RE: Beginning Javascript [Part 1]
May I note that JavaScript is not the same as JScript.

Plus! scripting uses JScript, not JavaScript...

Although many things are the same, there are many differences too.

For the purpose and in the context of creating a beginners tutorial it is absolutely important to reference to the proper language and not to a language which is similar to what is used in Plus! scripting.

Official JScript 5.6 reference:
http://msdn.microsoft.com/library/en-us/script56/...6-1bbfe2330aa9.asp

Official JScript 5.6 help file (CHM) (includes vbscript too):
http://www.microsoft.com/downloads/details.aspx?F...-8A76-1C4099D7BBB9

JScript tutorials:
* http://csu.colstate.edu/webdevelop/javascript/jscript/jstutor.htm
   http://cobdev.cob.isu.edu/psb/jscript/Jstutor.htm
   http://tergestesoft.com/~manuals/jslang/Jstutor.htm
   http://www.webf1.com/ScriptDoc/jscript/jstutor.htm
* http://www.dnjonline.com/articles/tutorials/jscript1.html

This post was edited on 10-01-2006 at 09:32 AM by CookieRevised.
.-= A 'frrrrrrrituurrr' for Wacky =-.
10-01-2006 09:24 AM
Profile PM Find Quote Report
vikke
Senior Member
****

Avatar

Posts: 900
Reputation: 28
31 / Male / Flag
Joined: May 2006
O.P. RE: Beginning Javascript [Part 1]
Ok. I have no idea of what's the diffference.
10-01-2006 09:33 AM
Profile E-Mail PM 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