mIRC Home    About    Download    Register    News    Help

Print Thread
#19196 14/04/03 03:53 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
I did not find any command in mIRC which create arrays.

I want to create variables which their names changes from window to window:

Lets say I am the a windows with $cid = 5
I want to create a variable which will be named %saragani.5

I succeeded with doing so, by /set %saragani. $+ [ [ $cid ] ] the_value_I_gave_it

But when I want to create a function which reads the data from a specific windows, for example:
//echo -a %saragani. $+ [ [ $cid ] ] , the computer only evauates the %saragani. as a variable (and since I didn't defined a variable called %saragani. ), I get the CID itself.


How can I do it correctly?


#19197 14/04/03 04:35 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Well you almost got it right smile A slight reposition of one evaluation bracket and its all good.
//set %saragani. $+ $cid You don't need any brackets when setting the var.
//echo -a %saragani. [ $+ [ $cid ] ]

#19198 14/04/03 04:56 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Thank you, it works :-)

#19199 14/04/03 05:27 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Now I have another probelm frown

I wanted to create a script which connect to servers by a command which comes from a text file.

The format of the text file is:

Network Server Channel

For example:

mirc irc.mirc.net #help


The problem that I had is that is the file has the same network more than once, it connects to it more than once!!

So I created the following script:

var %templines = $lines(aitemp.tmp)
var %b = 1
while (%b <= %templines) {
var %a
scon -at5 if ($gettok($read(aitemp.tmp,%b),1,32) == $!network) || ($gettok($read(aitemp.tmp,%b),2,32) == $!server) { var $eval(%a = $cid,0) }
if !%a {
server -m $gettok($read(aitemp.tmp,%b),2,32)
}
inc %b
}



The script works, but then I descovered that is the network is not on the list of mIRC, it will try to connect to it more that once, if the text file has this network more than once.

This is why I created a function which will give to each status window the network name as it is given in the text file.

I tried to do it by:

var %templines = $lines(aitemp.tmp)
var %b = 1
while (%b <= %templines) {
var %a
scon -at5 if ($gettok($read(aitemp.tmp,%b),1,32) == $!network) || ($gettok($read(aitemp.tmp,%b),2,32) == $!server) || [color:blue] ($gettok($read(aitemp.tmp,%b),1,32) == $!xnetwork)
{ var $eval(%a = $cid,0) }
if !%a {
server -m $gettok($read(aitemp.tmp,%b),2,32)
set %xnetwork. $+ $cid $gettok($read(aitemp.tmp,%b),1,32)
}
inc %b
} [/color]

alias xnetwork {
return %xdwork. [ $+ [ $cid ] ]
}



The only problem is that my genuis plan doesn't work frown, since the %xdccnetwork. [ $+ [ $cid ] ] is applied to the main status window (with the $cid=1), or on the status window that I'm currently on.


Please help confused

#19200 14/04/03 06:26 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Try this
Code:
  var %i = 1
  while $read(aitemp.tmp,%i) {
    ; Read the line and set it to %a, reset %b to null
    var %a = $ifmatch, %b
   
    ; Cycle through connections
    scon -at5 if $gettok(%a,1,32) == $!network || $gettok(%a,2,32) == $!server $eval({ %b = 1 },0)
   
    if !%b {
      ; connect and join the channel
      server -m $gettok(%a,2,32) -j $gettok(%a,3,32)
   
      ; and break out of the loop
      break
   
    }
    inc %i
  }

#19201 14/04/03 06:37 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
confused

I still don't see how it can help me.
The original script was:
Code:
 
  var %templines = $lines(aitemp.tmp)
  var %b = 1
  while (%b &lt;= %templines) {
    var %a
    scon -at5 if ($gettok($read(aitemp.tmp,%b),1,32) == $!network) || ($gettok($read(aitemp.tmp,%b),2,32) == $!server) { var $eval(%a = $cid,0) }
    if !%a { 
      server -m $gettok($read(aitemp.tmp,%b),2,32)
    }
    inc %b
  }

 


And it worked for networks that are in the networks list.

But if I will try to connect to a network which isn't in the networks/servers list of mIRC, it will not get the network name before it connected to the server, and the server name is given only after mIRC has connected to the server (and not while connecting).

So if I try to connect to a network named MOO with server irc.moo.net (I don't think there is such a network), the script I have, and the script you wrote will not work.

This is why I tried to create a variable which is specified to each Connection ID. The problem I have is that the variable name is only givven to the main status window, or to the current status window.





#19202 14/04/03 06:47 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
If the network sends a raw 001 or 005 telling mIRC its called moonet, then mIRC knws you're on moonet.
Where my post differs from yours is mainly with the "/break" command, which stops the looping once it finds a match (or non match grin). This means it will only connect to one new server.
/help /break smile

#19203 14/04/03 07:16 PM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
But the problem is that there are some networks that some of there networks are down, so the network doesn't sent the raw.

So if I have a file like this:
moo irc.moo.net #help
mirc mirc.irc.net #help
moo irc.moo.net #talk

and the server irc.moo.net is down, mIRC will try to connect to the same network twice.

Can you help me with the part that I'm stuck with?

How do I create the variable %xnetwork.$cid so it will be attached to the right cid.
At the current state of my program, the variable is attached to the main status window.

#19204 14/04/03 07:28 PM
Joined: Dec 2002
Posts: 699
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 699
Ah ok, yes I am sorry, I misunderstood that completely. I was thinking you wanted to connect to ONE new server, and not all of the listed networks. blush
Now, why not set one var with all connected/connecting network names in it?
Code:
  var %i = 1
  while $read(aitemp.tmp,%i) {
    ; Read the line and set it to $1-3
    tokenize 32 $ifmatch 
    [color:green]; Check now if it is in the list and if so, skip processing it.[/color]
    if $istok(%xnetworks,$1,32) { inc %i | continue }
 
    ; reset %b to null
    var %b
   
    ; Cycle through connections
    scon -at5 if $1 == $!network || $2 == $!server $eval({ %b = 1 },0)
 
    if !%b {
      ; connect and join the channel
      server -m $2 -j $3
 
      [color:green]; Add it to the list of connected nets
      set %xnetworks %xnetworks $1[/color]
 
    }
    inc %i
  }

#19205 14/04/03 10:51 PM
Joined: Jan 2003
Posts: 3,012
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2003
Posts: 3,012
Why not use an INI? confused \

[Network]
name=description
chans=#mirc,#help

As reguarding it to your line of thinking

[irc.mirc.net]
name=mIRC
chans=#help

then..
Code:
alias example {
  ; the name of the ini file stroing server information...
  /set -u0 %serverIni autojoin.ini

  ; Go thorugh each server name
  /set -u0 %a 1
  while (%a &lt;= $ini(%serverIni, 0)) {
    ; if no connection are open, connect to active status window
    if ($server(0) == 1) /server $ini(%serverIni, %a) -j $readini(%serverIni, $ini(%serverIni, %a), chans)
    else /server -m $ini(%serverIni, %a) -j $readini(%serverIni, $ini(%serverIni, %a), chans)

    ; increase loop
    /inc -u0 %a
  }
}


Note, i didn't test it, but it should work out right. Just list the server in the heading, then the nickname in name, then channels to join in chans (comma delimited). grin

*Edit: Went more in depth


-KingTomato
#19206 16/04/03 09:00 AM
Joined: Feb 2003
Posts: 282
S
Fjord artisan
OP Offline
Fjord artisan
S
Joined: Feb 2003
Posts: 282
Both ideas are good smile

I will try them.

Thanks.


Link Copied to Clipboard