mIRC Homepage


Posted By: bapplander

txt2txt - 10/12/05 01:55 PM

Hello, I have a textfile.txt with data stored as
data1 data2 data3

I would like to change this into newtxtfile.txt, stored as
data2 data1

Is it any small easy way to make a code todo this?
Posted By: DaveC

Re: txt2txt - 10/12/05 02:44 PM

mirc 6.16 only
type at the prompt the following 4 lines

/alias davec { tokenize 32 $1 | write newtxtfile.txt $2 $1 }
/remove newtxtfile.txt
/filter -fk textfile.txt davec
/alias davec

you can actualy just copy them from here and use SHIFT-INSERT to paste them in and all 4 should run.
Posted By: Kelder

Re: txt2txt - 10/12/05 02:52 PM

Here's one script, just realize there are many possibilities to do this, each with it's own pro's and cons, especially for performance...

alias newfile {
  ; if the path or file has spaces, put " " around them
  var %oldfile = test.txt
  var %newfile = newtxtfile.txt
  .fopen old %oldfile
  if ($ferr) { echo %oldfile error | .fclose old | return }
  .fopen -n new %newfile
  if ($ferr) { echo %newfile error | .fclose new | return }
  while ((!$ferr) && ($fread(old))) {
    .fwrite -n new $gettok($v1,2,32) $gettok($v1,1,32)
  .fclose new
  .fclose old
  echo done
  echo error
  if ($fopen(new)) .fclose new
  if ($fopen(old)) .fclose old
Posted By: DaveC

Re: txt2txt - 10/12/05 02:55 PM

nice code, i had assumed this was a one off thing he needed doing so just gave him some commands he could type. I guess we covered it either way now.
© 2019 mIRC Discussion Forums