mIRC Home    About    Download    Register    News    Help

Print Thread
echo a file with $read #169126 19/01/07 06:53 PM
Joined: Dec 2006
Posts: 31
Y
yetti Offline OP
Ameglian cow
OP Offline
Ameglian cow
Y
Joined: Dec 2006
Posts: 31
How can I echo the whole content of file useing $read?

I write to a file some variables, then I filter them to another file, and then I want to echo the content of the output file starting with the second word of each line..

I tryed this code:
Code:
/write info.txt $4 - $2 
//filter -ffc info.txt out.txt $4*
echo @info $read(out.txt, s, $4)


however this code only echoes the first line in the "out.txt" file, and i need to echo the whole file.

I know I can use the /filter to echo the result directly to @info, but this method doesn't allow me to modify the echoed text (with $read it echoes from the second word in the line, but with /filter it echoes all the line).

I guess I need a loop to check for the EOF, but I dont know how to write it...

Last edited by yetti; 19/01/07 06:54 PM.
Re: echo a file with $read [Re: yetti] #169127 19/01/07 07:00 PM
Joined: Apr 2006
Posts: 464
O
OrionsBelt Offline
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
How about a simple loop?

Code:
var %counter = 1
var %lines = $lines(out.txt)

While (%counter <= %lines) {
  echo -a $read(out.txt,%counter)
  inc %counter
}

Re: echo a file with $read [Re: yetti] #169128 19/01/07 07:02 PM
Joined: Jan 2007
Posts: 1,156
D
DJ_Sol Offline
Hoopy frood
Offline
Hoopy frood
D
Joined: Jan 2007
Posts: 1,156
Filter kicks butt but I'm a noob and have never used it. This is what I would do. Yes a while loop.

var %t = $lines(info.txt), %ti = 1 | while (%ti <= %t) {
echo @info $gettok($read(info.txt,%ti),2-,32)
inc %ti
}

Re: echo a file with $read [Re: yetti] #169133 19/01/07 07:56 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
You can use /play to display all of the lines in a text file. And, if you want to only show the second word and on in each line, then you can use the -a (alias) switch and run the commands through the alias. The alias would just be something like:

Code:
alias PlayStuff {
 ; $1 = Where you're playing it to (nick/chan)
 ; $2- = The line of text... since you want to start at the second word, use $3-.
 msg $1 $3-
}


/help /play to see how to use the command.


Invision Support
#Invision on irc.irchighway.net
Re: echo a file with $read [Re: DJ_Sol] #169135 19/01/07 08:01 PM
Joined: Dec 2006
Posts: 31
Y
yetti Offline OP
Ameglian cow
OP Offline
Ameglian cow
Y
Joined: Dec 2006
Posts: 31
thanks a lot to both of you.

and I have another n00bish question...

how can I assign a var to another without haveing to use "set %"?

ex:
Code:
$remove($6,[,]) = $newname

is that possible?

Re: echo a file with $read [Re: yetti] #169144 19/01/07 09:56 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
All variables have to either be % (normal) or & (binary). $ is an identifier and not a variable.

You can set a temporary variable with:

/var %newvarname = %oldvarname
/var %newvarname = $remove($6,$chr(44))

Or, you'd use /set for a permanent variable. If you already have your variable set up with /var, you can leave off the /var part, but I personally find it easier to quickly read with /var or /set present.


Invision Support
#Invision on irc.irchighway.net
Re: echo a file with $read [Re: Riamus2] #169148 19/01/07 10:12 PM
Joined: Dec 2006
Posts: 31
Y
yetti Offline OP
Ameglian cow
OP Offline
Ameglian cow
Y
Joined: Dec 2006
Posts: 31
is there no way to change the name of an identifier?

I have this case:
Code:
set %x  $remove($6,[,])
//filter -ffc info.txt out.txt $remove($6,[,])*


I use $remove($6,[,] (in raw 311) to get an IP from the fullname, and then I write it to a file.

Then i filter the file useing that ip ($remove($6,[,]).

The problem is that if i dont use "*" after the IP it doesnt work.... so I would need: $remove($6,[,]* (witch is wrong)

If i get the IP from $4 (on other networks) and add the wildcard.. it works... so I have to find a way to give the value of $remove($6,[,]) to another identifier $value in order to be able to add the "*" ($value*)

If i use %x* it doesnt work frown

any ideeas?

Re: echo a file with $read [Re: yetti] #169151 19/01/07 10:26 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
You may need $+ before the *. I don't know the format of that RAW, so I'm not positive, but from your description, it sounds like that could be an issue.

$remove($6,[,]) $+ *
$remove($6,$chr(44)) $+ * <-- Same thing

Now... you did mention you needed to get the IP from the real name. If those are together as $6 in the RAW:

$6 == IP,name

Then, removing the comma will leave you with:

$6 == IPname

You'd need to use $gettok instead...

$gettok($6,1,44)

Then add your * to the end.

Anyhow, you seem to have identifiers and variables mixed up. You can make a custom identifier, but I don't think that's what you're trying to do. I think you're just trying to have 2 variables and have the second one based on the first one.

set %x $remove($6,[,])
set %y %x $+ *


Invision Support
#Invision on irc.irchighway.net
Re: echo a file with $read [Re: Riamus2] #169166 20/01/07 12:26 AM
Joined: Dec 2006
Posts: 31
Y
yetti Offline OP
Ameglian cow
OP Offline
Ameglian cow
Y
Joined: Dec 2006
Posts: 31
Thanks Raimus2.. the "$+ *" did the trick smile

now I have another problem smile

can anyone tell me where is the mistake here:
Code:
raw 311:*:{ 
    window -1 @info 620 0 400 500
    clear @info
    echo @info  Nick: $2
    echo @info  IP: $4 
    echo @info IP was used by:

;looks in info.txt to see if the IP exists 
    //filter -ffc info.txt out.txt $4*

;looks in out.txt to see if the nick with same IP exists
    //filter -ffc out.txt same.txt $2*

;if the ip does not exist, it writes it to info.txt
    if ( $file(out.txt).size == 0 ) { write info.txt $4 - $2  ::  ( $date - $time ) }

;if the ip exists checks the nick, and if the same IP has a different nick, it writes it to info.txt
    elseif ( $file(same.txt).size == 0 ) { write info.txt $4 - $2  ::  ( $date - $time ) }

;if the nick and IP exist, it doesnt write.
    else  { echo @info nick cu ip exista }

;it reads all the nicks that used this IP 
    //filter -ffc info.txt out.txt $4*
    var %t = $lines(out.txt), %ti = 1 | while (%ti <= %t) {
      echo @info $gettok($read(out.txt,%ti),2-,32)
      inc %ti
    } 

    echo @info 14 ---
}


can anyone tell me where is my mistake, cause I it wont work frown

Re: echo a file with $read [Re: yetti] #169213 20/01/07 11:37 AM
Joined: Oct 2003
Posts: 214
S
Sephiroth_ Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Oct 2003
Posts: 214
/loadbuf should be fine
Code:
write info.txt $4 - $2
filter -ffc info.txt out.txt $4*
loadbuf @info out.txt

you could also use "/play -e @info out.txt 0"


one step closer to world domination