mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: May 2003
Posts: 32
Q
quizer Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 32
/write -n that will prevent mIRC from adding automaticly $crlf at the begining of my line.
I mean
Code:
 //set %string abc | //set %fileSize $file(abc.txt).size | //write abc.txt %string | //echo -a string length is $len(%string) and file is: $calc(%fileSize - $file(abc.txt).size)" 
echos 7!
if the file was ending with $crlf so it echos 5

I know I can use
Code:
  /bset -t &bvar $len(%string) %string | /bwrite %fileName -1 -1 &bvar" 
but its kind of workaround 4 a problem that shouldn't exist at all.
its like writing in my local language 4 characters to a new text documet in notepad, saving it in UTF-8 format and c that there is 11 characters in my file...

the other suggestion is to add support for encoding to utf-8/unicode and decoding from it- at least for preventing other scripters from writing these
Code:
  
    if (($asc($mid($1-,%i,1)) > 223) && ($asc($mid($1-,%i,1)) < 251)) var %newString = %newString $+ $chr(215) $+ $chr($calc($asc($mid($1-,%i,1)) - 80))
    else var %newString = %newString $+ $mid($1-,%i,1)

and these:
Code:
    if (($asc($mid($1-,%i,1)) > 143) && ($asc($mid($1-,%i,1)) < 171)) var %newString = %newString $chr($calc($asc($mid($1-,%i,1)) + 80))
    else var %newString = %newString $+ $mid($1-,%i,1)

complex lines.
I think u know from what ansii lanaguage I am coding 2 and from utf-8...
I know unicode/utf-8 real support been requested several times b4- but it is much simpler than a real support and a good temporary solution.

and fix the search error in these forums...
searched for "/write crlf" and got:
Warning: Unknown modifier 'w' in /home/www/showflat.php on line 856

10q.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
/write -n that will prevent mIRC from adding automaticly $crlf at the begining of my line.
I mean
Code:
 //set %string abc | //set %fileSize $file(abc.txt).size | //write abc.txt %string | //echo -a string length is $len(%string) and file is: $calc(%fileSize - $file(abc.txt).size)" 
echos 7!

if the file was ending with $crlf so it echos 5


Sorry I dont beleive you got those results with the above line of code, That above code well echo negitive values since %filesize is always smaller than the current $file(abc.txt).size.

And even when I fixed it to be $calc($file(abc.txt).size - %fileSize) I recieved "5" for write abc.txt and "3" for write -n abc.txt, no crlf$ was appeneded prior to my text on either no -n or -n.

You may however have issues with the method windows has as its default text saving format (maybe)
(i know this is adjustable but i dont remeber where, mainly becuase I have never encountered it)

An example of the type of thing im talking about can be seen in REGEDIT when you export a registry section, w2k and xp export using 2 byte per charcter formating by default, you must specificly tell it to use REGEDIT4 win9x/nt4 formating to get plain text

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I was rather confused by your post, even your example. Here, the code you pasted echoes

string length is 3 and file is: -5

Not 7 or anything. To the point, I didn't undestand what you'd want -n to do, but it already exists. -n prevents /write from appending a $crlf to the end of the written string.

Edit: posted without having seen sneaky DaveC's post.

Last edited by qwerty; 12/02/05 06:57 PM.
Joined: May 2003
Posts: 32
Q
quizer Offline OP
Ameglian cow
OP Offline
Ameglian cow
Q
Joined: May 2003
Posts: 32
sorry.
I didn't get this results, just assumed that it would b after few other expirements I did.
here is a 1 I've just tried:
Code:
  //set %fileSize $file(abc.txt).size | //write abc.txt text | //echo -a $calc($file(abc.txt).size - %fileSize) 

and I got 8.
when I tried 2 make it again- I got 6.

the file wasn't ending with $crlf on the 1st time so mIRC added this $crlf at the begining and at the end- so I got 8. this has nothing to do with the OS.
I was suggesting to add -n switch couz I didn't know it already in use (I am using older version of mIRC which don't have it).
but as I written in the new help file- the -n switch only prevents mIRC from adding $crlf to the end of the line- and not preventing mIRC to add it on the begining of the line.
here is what I got:
Code:
  //bwrite abc.txt -1 -1 abc | set %fileSize $file(abc.txt).size | //write abc.txt text | //echo -a $calc($file(abc.txt).size - %fileSize) 
echos 8.

anyway- after finding that my problem can b solved more easier than I tought with /bwrite I take my words back.


the suggestion about providing identifier to encode/decode utf-8/unicode strings remains. (if this not already added in newer versions than I have). The suggestion is to make mIRC to use the OS 2 provide those identifiers 4 scripters- even without any other internal support.


the suggestion from multi threading also remains. I mean preventing from mIRC to freeze on any long operation. I am not talking about processing events- but about preforming what written in this operation...
here is an example:
$file(abc.dat).size is bigger than 1.5 Gb.
Code:
  
alias slowAlias {
  var %i = 0
  while (%i < $file(abc.dat).size) {
    inc %i
    bread abc.dat  %i 1 &abc
    bwrite abc.txt -1 -1 $chr($hget(assChar,$bvar(&abc,1)))
    if ($right(%i,5) == 20000) echo -a now on $round($calc(%i / $file(abc.dat).size),1) $+ $chr(37) char $bytes(%i)
  }
}

when I run /slowAlias from the command line- mIRC displays few lines with "now on..." and then freezes. after few minutes it returns to life and displays all the other messages.
it shouldn't b that way.
actually I didn't tried this alias- but that what would happen if I'd try.Tthe suggestion was to implement kind of multithreading but any other solution would b good also.

10x.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Quote:
Code:
  //set %fileSize $file(abc.txt).size | //write abc.txt text | //echo -a $calc($file(abc.txt).size - %fileSize) 

and I got 8.
when I tried 2 make it again- I got 6.

the file wasn't ending with $crlf on the 1st time so mIRC added this $crlf at the begining and at the end- so I got 8. this has nothing to do with the OS.
I was suggesting to add -n switch couz I didn't know it already in use (I am using older version of mIRC which don't have it).


The last statement is a bit of a hint at things, u shouldnt ask for improvements unless your using the latest version, using -n infact does prevent a /write from appending a $crlf from the front and end. Only the text being written is appened to the file.

Quote:

the suggestion from multi threading also remains. I mean preventing from mIRC to freeze on any long operation. I am not talking about processing events- but about preforming what written in this operation...
here is an example:
$file(abc.dat).size is bigger than 1.5 Gb.
Code:
  
alias slowAlias {
  var %i = 0
  while (%i < $file(abc.dat).size) {
    inc %i
    bread abc.dat  %i 1 &abc
    bwrite abc.txt -1 -1 $chr($hget(assChar,$bvar(&abc,1)))
    if ($right(%i,5) == 20000) echo -a now on $round($calc(%i / $file(abc.dat).size),1) $+ $chr(37) char $bytes(%i)
  }
}

when I run /slowAlias from the command line- mIRC displays few lines with "now on..." and then freezes. after few minutes it returns to life and displays all the other messages.
it shouldn't b that way.


Well thats is an incredibly slow alias, I assume it was written like that to make it slow, but assuming that is how it must performed, one byte at a time from the front of the file to the end.
Then some cleverer coding well make it not freeze mirc at all.
Code:
alias slowAlias2 {
  .timerslowAlias2.timer $file(abc.dat).size 0 slowAlias2.timer $file(abc.dat).size
}
alias slowAlias2.timer {
   var %i = $calc($1 - $timer(slowAlias2.timer).reps)
   bread abc.dat %i 1 &abc
   bwrite abc.txt -1 -1 $chr($hget(assChar,$bvar(&abc,1)))
   if ($right(%i,5) == 20000) echo -a now on $round($calc(%i / $1),1) $+ $chr(37) char $bytes(%i)
  }
}



Quote:

actually I didn't tried this alias- but that what would happen if I'd try.Tthe suggestion was to implement kind of multithreading but any other solution would b good also.


Multithreading while it would be great, also creates a huge stack of its own problems,
Lets say a bot offered a command !send filename the file is then mime encoded zipped up and dispatched (why a bot would do this is not relevent its an example)
Code:
on *:text:!send *:#{
  if $send($nick) { msg $nick your already getting a file piggy! }
  else {
    ...
    while loop to { encode original file to a temp.file }
    some zipup dlll that takes a few seconds as well
    ...
    dcc send $nick temp.file
  }
}


Now if the system was multithread, some user might go
!send blah.avi
!send gogo.exe
!send fred.gif
!send bill.bin

Since each of them would get a thread running the alias before the 1st alias would send the file, the alias would not know of other temp.files being prepeared for sending, so the user would have slipped 4 requests in (or more)

That of course is a simple matter to deal with using flag falls, but was to show how a multithreaded enviroment produces a whole new set of conditions a coder must watch for.


The Best i could think of to make it compatable with current mirc scripts is to have a alias -m aliasname option that means please run this alias in its own thread, then its on the head of the scripter to deal with all the multi thread collisions problems that might arise.

Joined: Jan 2003
Posts: 2,523
Q
Hoopy frood
Offline
Hoopy frood
Q
Joined: Jan 2003
Posts: 2,523
I now believe you're looking for the -a switch. /write, by default, starts a new line. To prevent that, use the -a (append) switch, which makes /write start writing after the last char in the file, without adding a CRLF at the beginning.


/.timerQ 1 0 echo /.timerQ 1 0 $timer(Q).com

Link Copied to Clipboard