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
« Next Oldest Return to Top Next Newest »

Messages In This Thread
Beginning Javascript [Part 1] - by vikke on 10-01-2006 at 06:53 AM
RE: Beginning Javascript [Part 1] - by -dt- on 10-01-2006 at 07:15 AM
RE: Beginning Javascript [Part 1] - by CookieRevised on 10-01-2006 at 09:24 AM
RE: Beginning Javascript [Part 1] - by vikke on 10-01-2006 at 09:33 AM


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