mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 2 1 2
echoingon a .txt #174703 11/04/07 02:23 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
how can i echo the list that is saved txt file

for sample
list.txt

Quote:
text1
text2
text3
text4


learn learn learn
Re: echoingon a .txt [Re: learn3r] #174704 11/04/07 03:01 PM
Joined: Mar 2007
Posts: 139
S
Solo1 Offline
Vogon poet
Offline
Vogon poet
S
Joined: Mar 2007
Posts: 139
/help /filter
That is probabley the fastest way.

Re: echoingon a .txt [Re: learn3r] #174705 11/04/07 03:06 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
/loadbuf -a list.txt

Re: echoingon a .txt [Re: schaefer31] #174706 11/04/07 03:16 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
works properly using
Code:
/loadbuf -a list.txt 


uhm how can it echo like
Quote:

the list contains the ff:
list1 , list2 , list3 , list4


learn learn learn
Re: echoingon a .txt [Re: learn3r] #174712 11/04/07 04:43 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Code:
alias -l list.filter {
  if ($1) %list.filter = $iif(%list.filter,$v1 $+ $chr(44) $1,$1)
}

alias _list {
  set %list.filter
  filter -k list.txt list.filter
  echo -ag the list contains the ff:
  echo -ag %list.filter
  unset %list.filter
}


/_list

Note that it's subject to the line too long error. It also disregards blank lines in the file.

Re: echoingon a .txt [Re: learn3r] #174713 11/04/07 05:12 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Alternatively, you can also use /play with an alias to prevent issues with the line being too long. Or, just use a WHILE loop with $read or $fread.


Invision Support
#Invision on irc.irchighway.net
Re: echoingon a .txt [Re: Riamus2] #174715 11/04/07 06:01 PM
Joined: Aug 2005
Posts: 525
S
schaefer31 Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Aug 2005
Posts: 525
Right, but he said he wanted, at least this is how I understood it, the text from a file which was in this format:

line 1
line 2
line 3

to be echo'd in this format: line 1, line 2, line 3. If he wanted to just echo all of the lines, line by line then loadbuf (as I brought up already) is the easiest way to go if you ask me.

Re: echoingon a .txt [Re: learn3r] #174716 11/04/07 06:17 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
This one shouldn't have a problem with the line too long error.

Code:
alias viewfile {
  if (!$isfile($1-)) {
    echo -abcfilrt Info * /viewfile: No such file ' $+ $1-'
    return
  }
  bread $qt($1-) 0 $file($1-) &file
  breplace &file 10 44
  var %position = 1, %size = $bvar(&file,0)
  if ($bvar(&file,%size) == 44) { bcopy -c &file 1 &file 1 $calc(%size - 1) }
  while (%position < %size) {
    echo -a $remove($bvar(&file,$+(%position,-,$calc(%position + 900))).text,$cr)
    inc %position 900
  }
}


/viewfile <file>

Re: echoingon a .txt [Re: schaefer31] #174717 11/04/07 06:19 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
I was just giving an alternative method that can be used to combine the lines as requested (multiple lines onto one line with commas). That can be done with the methods I gave. Even if one way may be easier, showing alternate methods helps people not only to learn, but also to possibly do something a little different that may not be possible with the easiest method.


Invision Support
#Invision on irc.irchighway.net
Re: echoingon a .txt [Re: hixxy] #174719 11/04/07 07:07 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
* qwerty reminds hixxy of $bvar(&file,%position,900).text


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: echoingon a .txt [Re: qwerty] #174720 11/04/07 07:17 PM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
I didn't know there was one. Thanks smile

Code:
alias viewfile {
  if (!$isfile($1-)) {
    echo -abcfilrt Info * /viewfile: No such file ' $+ $1-'
    return
  }
  bread $qt($1-) 0 $file($1-) &file
  breplace &file 10 44
  var %position = 1, %size = $bvar(&file,0)
  if ($bvar(&file,%size) == 44) { bcopy -c &file 1 &file 1 $calc(%size - 1) }
  while (%position < %size) {
    echo -a $remove($bvar(&file,%position,899).text,$cr)
    inc %position 900
  }
}


Thanks again q

Last edited by hixxy; 11/04/07 07:43 PM.
Re: echoingon a .txt [Re: hixxy] #174722 11/04/07 07:40 PM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
The 3rd parameter is length, not end position. What I wrote before should work here.

Actually either 899 in $bvar() or inc %position 901

Last edited by qwerty; 11/04/07 07:42 PM.

/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: echoingon a .txt [Re: hixxy] #174734 12/04/07 12:20 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
It now works great... thanks

one more question.

if writing on a text is /write line.txt $1-

how to delete a certain text on the txt file?

sample:

Quote:
line1
line2
line3
line4


i echoed it and i want to delete line3


learn learn learn
Re: echoingon a .txt [Re: learn3r] #174735 12/04/07 12:53 AM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
/write -dl<N> <file>

Looking at /help /write would tell you this.

Re: echoingon a .txt [Re: qwerty] #174736 12/04/07 01:18 AM
Joined: Jan 2003
Posts: 2,523
Q
qwerty Offline
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I was better off without the edit :P The correct number would be 900, not sure how I came up with 899.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com
Re: echoingon a .txt [Re: hixxy] #174737 12/04/07 01:26 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
the -l is the line right?
but what if the line aint specified like putting the code into a menu?


learn learn learn
Re: echoingon a .txt [Re: learn3r] #174740 12/04/07 02:13 AM
Joined: Aug 2004
Posts: 7,252
R
RusselB Offline
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
You have to get the line number in some manner in order to ensure that you get the correct line, otherwise you'll end up deleting either the wrong line, or the last line.

If you're using $read in your script, then you can use $readn to return the line (storing it in a variable if you can't do the deletion immediately)

Re: echoingon a .txt [Re: RusselB] #174749 12/04/07 08:44 AM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
how can i do this on a menu?


learn learn learn
Re: echoingon a .txt [Re: learn3r] #174757 12/04/07 11:27 AM
Joined: Sep 2005
Posts: 2,881
H
hixxy Offline
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,881
It depends what you want to delete. The computer isn't psychic and neither are we, tell us exactly what you're wanting to delete from the file.

Re: echoingon a .txt [Re: hixxy] #174760 12/04/07 12:36 PM
Joined: Oct 2006
Posts: 342
L
learn3r Offline OP
Fjord artisan
OP Offline
Fjord artisan
L
Joined: Oct 2006
Posts: 342
Quote:
how to delete a certain text on the txt file?

sample:

Quote:

one
two
three
four



i echoed it and i want to delete three


learn learn learn
Page 1 of 2 1 2