#MIRC @ Dalnet

MIRC Client Help Forum


Display results as :

Rechercher Advanced Search

Latest topics
» Dalnet Services Help Popups
Mon Oct 24, 2011 7:16 am by HorseC

» DCC Problem Checking Script
Fri Sep 30, 2011 11:43 pm by Rukbat

» general question
Fri Sep 30, 2011 5:25 am by Rukbat

» Banned by dal.net
Sat Aug 13, 2011 11:25 pm by HorseC

» "MISHBOX" tutorials on mirc scripting.
Tue Aug 02, 2011 7:16 am by HorseC

» A very good guide to mIRC Scripting
Tue Aug 02, 2011 7:08 am by HorseC

» Dialog tool for DALnet services
Mon Aug 01, 2011 7:53 am by HorseC

» Scripting Class Level 2 Class 4
Sat Jul 30, 2011 1:01 am by HorseC

» Scripting Class Level 2 Class 3
Sat Jul 30, 2011 12:49 am by HorseC


We have 32 registered users
The newest registered user is boed1

Our users have posted a total of 38 messages in 36 subjects

You are not connected. Please login or register

Scripting Class Level 2 Class 2

Go down  Message [Page 1 of 1]

1 Scripting Class Level 2 Class 2 on Sat Jul 30, 2011 12:37 am

Welcome to Level 2 Class 2
This class is going to introduce you
to the very basic concept of the
IF-THEN-ELSE Logic. We are going
to start very simple and build from

The IF-THEN-ELSE is really a simple
concept. This tells your computer..
"IF" (Argument), "THEN" (do this),
or "ELSE" (do this).

Concept Example (not code!):

IF the bathtub is full THEN turn water off,
or ELSE keep filling the bathtub.

This is a simple example, and not written
as a program, but it gives you an idea of
what I am referring to.

The computer likes to use parenthasis "( )"
and brackets "{ }" to make it easier to
process, (also much faster).

Taking our example from above...
IF (bathub == full) THEN { turn water off }
ELSE { keep filling bathtub }

Just so you know "==" means equals or equal to Smile
(not case sensitive)

Lets build an example of something
simple to try out this concept.

We are going to create an alias,
that will ask us to input a parameter.
Using IF THEN ELSE, we will have
it respond accordingly.

Place this in your Remote,
and test it in the lab.

Alias bathtub {
set %tub $$?="Is Tub Full Yes / No"
IF (%tub == yes) { msg $chan Tubs full }
ELSE { msg $chan Tub is filling }

Please be sure that for every
Opening Bracket "{" , you have a
closing Bracket "}" . If you dont, you
will have all sorts of problems Wink

Please remove the "Bathtub" alias at this time.

Now lets create an alias that is a little
more complex. It will have
"IF-ELSEIF-ELSE" instead
of "IF-THEN-ELSE" logic.
The IF-ELSEIF-ELSE" statment(s) allow
you to test multiple conditions and take
appropriate action for each,
whereas "IF-THEN-ELSE" only
allows you to test one condition.

Write this into your remote
and test it in the lab.

Alias Number {
set %num $$?="Enter 1 or 2"
IF (%num == 1) { msg $chan Number Was ONE }
ELSEIF (%num == 2) { msg $chan Number Was TWO }
ELSE { msg $chan I am a MORON! }

At this time, please remove the alias
"Number" from your remote.

Ok.. We are going to keep on building,
on what we have done so far today..

Lets have a little fun.

We are going to create an alias,
that will use "$rand? and the
"IF-THEN-ELSE" statements. We are also
going to use multi line for the "THEN"
part of the logic..

This alias will create a random number,
between 1 and 4 .. and give a silly
response based on that random number.
Please add this to your remotes, but
do not test it yet.

Alias F3 {
set %num $rand(1,4)
IF (%num == 1) {
msg $chan Hey Dummy! }
ELSEIF (%num == 2) {
msg $chan Hi ya Moron! }
ELSEIF (%num == 3) {
msg $chan NO! not NUMBER 3! }
ELSE { msg $chan DOH! }

Before we run this, lets look
at what it does, line by line.

set %num $rand(1,4) creates a
random number between 1 and 4.

If %num equals 1, then it msgs
the channel "Hey Dummy!"

If %num equals 2, then it msgs
the channel "Hi ya Moron!"

if %num equals 3, then it msgs
the channel "No! not NUMBER 3!"

if %num equals anything else it
msgs the channel "DOH!"
Ok.. lets test F3 in the lab.

Now, lets modify that so that
everytime you hit it, it can
not give you the same answer.

To do this, we will use a LOOP.

A loop is a part of the
script/program, that may be
repeated if nessesary. A loop
uses the "GOTO" command. This
simply tells the computer to "go to"
a specific part of the script.

NOTE: when you incur a loop with the
goto command, you do not use the ":"
The ":" is used to identify or "label"
the item where you want to "go to".

:loop goto loop
(WARNING... DO NOT CODE THIS! never ending loop)

NOTE: in the code that follows...
The first IF line is used
incase there is NO "%old.num" variable.
This will prevent a possible error.

If there was no "%old.num"it would be
impossible for the computer to compare
it to the "%num".

Please add this alias and test it in the lab.

Alias F3 {
IF (%old.num == $null) {
set %old.num 5 }
Set %num $rand(1,4)
IF (%num == %old.num) {
goto loop }
Set %old.num %num
IF (%num == 1) {
msg $chan Hey Dummy! }
ELSEIF (%num == 2) {
msg $chan Hi ya Moron! }
ELSEIF (%num == 3) {
msg $chan NO! not NUMBER 3! }
ELSE { msg $chan DOH! }

This concludes level 2 class 2.
If you have any questions concerning
todays material, This is the time to
ask. If not.. see ya next week!

View user profile http://www.mirc.org

Back to top  Message [Page 1 of 1]

Permissions in this forum:
You cannot reply to topics in this forum