mIRC Homepage
Posted By: Mpot /write - 04/01/08 06:07 PM
I am trying to /write the contents of /ulist protect to a text file. However, when I try to do so, the resulting file merely contains the text "/ulist protect" instead of the information resulting from /ulist protect. My question is, how to I write information fron a /command to a file instead of writing the text of the command to a file?

I am currently getting around this problem with:

Code:
  if (1 <= $ulist(*,protect)) { /write -c C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,1) }
  if (2 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,2) }
  if (3 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,3) }
  if (4 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,4) }
  if (5 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,5) }
  if (6 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,6) }
  if (7 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,7) }
  if (8 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,8) }
  if (9 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,9) }
  if (10 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,10) }
  if (11 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,11) }
  if (12 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,12) }
  if (13 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,13) }
  if (14 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,14) }
  if (15 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,15) }
  if (16 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,16) }
  if (17 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,17) }
  if (18 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,18) }
  if (19 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,19) }
  if (20 <= $ulist(*,protect)) { /write C:\IcyBot2\Scripts\protect_list.txt $ulist(*,protect,20) }
Posted By: Collective Re: /write - 04/01/08 06:27 PM
Well, you could do:
Code:
//window -eh @temp | editbox -n @temp //ulist protect $(|) savebuf @temp ulist.txt $(|) close -@ @temp

...but that's ugly.

You'd be better off using a while loop.
Posted By: synedyne Re: /write - 05/01/08 04:32 AM
Code:
alias While_Loop {
  var %x = 1
  while (%x <= $ulist(*,Protect,0)) { 
    write -c Location_Here\Protext_List.txt $ulist(*,Protext,%x) 
    inc %x
  }
}


hope this helps =)
Posted By: genius_at_work Re: /write - 05/01/08 04:52 AM
It is bad form to use an identifier in the condition statement of a while loop, because it is evaluated everytime it loops to the top. You should do something like this instead:

Code:

alias While_Loop {
  var %x = 1, %xx = $ulist(*,Protect,0)
  while (%x <= %xx) { 
    write -c Location_Here\Protext_List.txt $ulist(*,Protext,%x) 
    inc %x
  }
}



-genius_at_work
Posted By: Mpot Re: /write - 06/01/08 02:39 AM
So there is really no way to get the /write to put the data from the command in the file instead of the command without doing something like this?
Posted By: genius_at_work Re: /write - 06/01/08 04:11 AM
No.

-genius_at_work
© mIRC Discussion Forums