mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
OK, so this script is reading from a text file like this:

---------txtfile-----
line1
line2
line3
line4
.....
---------------------

But the output shows up as: line4, line3, line2, line1
I want it to output like:line1, line2, line3, line4

Here is part of the code
Code:
 

...
if ($read(list.txt,w,$+(*,$nick,*))) {
      var %x = $lines(list.txt), %target
        while (%x) {
          var %target = $addtok(%target, 7 $+ $chr(32) $gettok($read(list.txt,%x),1,32) $+  ,44) 
          dec %x
      }
      msg $chan list is:7  %target
...


thanks

Joined: Oct 2003
Posts: 37
R
Ameglian cow
Offline
Ameglian cow
R
Joined: Oct 2003
Posts: 37
use inc not dec the while loop

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
try this

Code:
 if ($read(list.txt,w,$+(*,$nick,*))) {
      var %x = 1, %target
        while $read(list.txt,%x) {
          %target = $addtok(%target, 7 $+ $chr(32) $gettok($v1,1,32) $+  ,44) 
          inc %x
      }
      msg $chan list is:7  %target
 


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
That did it smile Thanks

Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
Now if I only wanted to msg the first 3 lines or 5 lines of the list, what part of the script would change? Thanks

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Change this line

Code:
 while $read(list.txt,%x) { 


to

Code:
 while ( $read(list.txt,%x) ) && ( %x <= 3 )  { 


** Change 3 to your desired number


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
I tried it and it doesnt work. If i set it to 5, it outputs numbers 1, 2, 3, 4, 5, it doesnt read the first 5 from the list.

Thanks

Joined: Nov 2003
Posts: 2,327
T
Hoopy frood
Offline
Hoopy frood
T
Joined: Nov 2003
Posts: 2,327
That won't work because $v1 is set to the %x in this situation, you can simply reverse your if statement and it will work.

Code:
while ( %x <= 3 ) && ( $read(list.txt,%x) ) { 


New username: hixxy
Joined: Jan 2003
Posts: 39
Q
quiglag Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: Jan 2003
Posts: 39
That works. Thanks smile

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
Oh yeah, that's right. Thanks for fixing it.


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!

Link Copied to Clipboard