mIRC Home    About    Download    Register    News    Help

Print Thread
reading from file comes out backwards #122507 11/06/05 06:46 PM
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

Re: reading from file comes out backwards #122508 11/06/05 08:24 PM
Joined: Oct 2003
Posts: 37
R
Rumie Offline
Ameglian cow
Offline
Ameglian cow
R
Joined: Oct 2003
Posts: 37
use inc not dec the while loop

Re: reading from file comes out backwards #122509 11/06/05 08:36 PM
Joined: Mar 2005
Posts: 420
X
xDaeMoN Offline
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!
Re: reading from file comes out backwards #122510 11/06/05 09:44 PM
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

Re: reading from file comes out backwards #122511 11/06/05 10:00 PM
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

Re: reading from file comes out backwards #122512 11/06/05 10:32 PM
Joined: Mar 2005
Posts: 420
X
xDaeMoN Offline
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!
Re: reading from file comes out backwards #122513 11/06/05 11:07 PM
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

Re: reading from file comes out backwards #122514 11/06/05 11:18 PM
Joined: Nov 2003
Posts: 2,327
T
tidy_trax Offline
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
Re: reading from file comes out backwards #122515 11/06/05 11:54 PM
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

Re: reading from file comes out backwards #122516 12/06/05 12:12 AM
Joined: Mar 2005
Posts: 420
X
xDaeMoN Offline
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!