mIRC Home    About    Download    Register    News    Help

Print Thread
replace all instancec of <text> in a file #180764 13/07/07 05:04 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
hey,

is there a way to replace all instances of $crlf in a file with <text>

i was looking at /filter, but it doesnt seem to have a <replacetext> item, any ideas how i could do this in the most efficient manner?


i was thinking /filter -if dialog id file $crlf <newtext>

Re: replace all instancec of <text> in a file [Re: NightChillz] #180766 13/07/07 05:08 PM
Joined: Dec 2002
Posts: 3,547
S
SladeKraven Offline
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
I've never really used filter so I can't say much about it but you could maybe loop through the file or something and replace each instance of it that way.

$replace($read(...,%x),$crlf,<text>)

Or maybe File Handling, although I've not used that either. Sorry I couldn't be much help.

Re: replace all instancec of <text> in a file [Re: SladeKraven] #180767 13/07/07 05:12 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
yeah i realize that, but two key words: most efficient

looping through each line of text in a file isnt very efficient

Re: replace all instancec of <text> in a file [Re: NightChillz] #180772 13/07/07 06:18 PM
Joined: Oct 2004
Posts: 8,327
Riamus2 Offline
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,327
Again, I don't know if filter will do what you need, but if not, then load the text into a custom window and loop through that. It's much faster than doing it through the text file.


Invision Support
#Invision on irc.irchighway.net
Re: replace all instancec of <text> in a file [Re: Riamus2] #180776 13/07/07 06:31 PM
Joined: Dec 2002
Posts: 271
N
NightChillz Offline OP
Fjord artisan
OP Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 271
actually it takesfrom a dialog list and write to a file, for now i am having to use the loop, but i'm hoping for a faster more efficient way. is looping through a dialog listbox faster or slower then looping through a custom win?

Re: replace all instancec of <text> in a file [Re: NightChillz] #180825 14/07/07 08:29 AM
Joined: Feb 2006
Posts: 546
J
jaytea Offline
Fjord artisan
Offline
Fjord artisan
J
Joined: Feb 2006
Posts: 546
don't you want to replace $crlf? $crlf separates lines in a plaintext file, so i don't know why we're discussing looping through lines with $replace and such :X

for generic 'replace text across a whole file' tasks i'd read the file into a binvar with /bread, then loop with $bfind and /bcopy. that would work even if you plan on involving $crlf in the replacement string


"The only excuse for making a useless script is that one admires it intensely" - Oscar Wilde