mIRC Home    About    Download    Register    News    Help

Print Thread
#3936 29/12/02 03:27 PM
Joined: Dec 2002
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Dec 2002
Posts: 4
I am trying to write a script that will read a txt file line by line, removing a specified amount of spaces to the right of the start of the line. Now I am unsure if I am using the right identifiers but....would make an alias

alias altered {
set %i 1
write $2 $right($read($1 ,s, * , %i )6))
inc %i
}

usage would be
/altered one.txt two.txt

I know I am also missing a loop to cycle through each line of the file til it's done but I am unsure of how to put that in either...I know it's asking a lot but if I can get some guidance I would appreciate it very much...

TIA
TC

#3937 29/12/02 03:30 PM
Joined: Dec 2002
Posts: 21
S
Ameglian cow
Offline
Ameglian cow
S
Joined: Dec 2002
Posts: 21
I would help, but I'm not sure I understood what you're up to... you want to check a txt file (one.txt) line by line, then on each line find the spaces and remove them... but what are you doing with two.txt ? reporting the line without the space in order to save the first file ? confused


DNWT.net Coalition of irc networks
#3938 29/12/02 03:32 PM
Joined: Dec 2002
Posts: 3,138
C
Hoopy frood
Offline
Hoopy frood
C
Joined: Dec 2002
Posts: 3,138
"removing a specified amount of spaces to the right of the start of the line."

So the first text file would look like this:
    Text

And the second file would look like this:
Text

Is that the idea?

#3939 29/12/02 03:35 PM
Joined: Dec 2002
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Dec 2002
Posts: 4
ok...for example a file which may have lines that look like:

This is wasted words | ftp://127.0.0.1/

I want to remove the "This is wasted words |" and save only
ftp://127.0.0.1/ to the second file. The file has multiple lines but is consistant in the beginning...by this I mean the whole file will start on each line with "This is wasted words |".

Hope that helps more

#3940 29/12/02 03:39 PM
Joined: Dec 2002
Posts: 144
D
Vogon poet
Offline
Vogon poet
D
Joined: Dec 2002
Posts: 144
You can find a good tutorial for writing loops here and here.

As for what you want to do, mIRC has some trouble reading a series of spaces, so I'm not quite sure just how well, this would work. However, if you're talking about reading a certain number of characters from each line only and removing all the other characters on that line, you can use this:

Code:
alias altered {
  if ($exists($2) != $true) { return }
  var %i = 0
  while (%i <= $lines($2)) {
    write $+(-l,%i) $2 $left($read($2,%i),-N)
    inc %i
  }
}

Replace N (in $left($read($2,%i),-N)) with the number of spaces that you wish to remove.


"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
#3941 29/12/02 03:42 PM
Joined: Dec 2002
Posts: 144
D
Vogon poet
Offline
Vogon poet
D
Joined: Dec 2002
Posts: 144
With my previous example, you'd use $right(string,-N) to accomplish this (instead of $left) where N is the number of characters in "this is wasted words".

Dana


"Any sufficiently advanced technology is indistinguishable from magic." - Arthur C. Clarke
#3942 29/12/02 04:05 PM
Joined: Dec 2002
Posts: 4
T
Self-satisified door
OP Offline
Self-satisified door
T
Joined: Dec 2002
Posts: 4
thank you very much....for the links as well...

cool

TC


Link Copied to Clipboard