mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2007
Posts: 6
I
Ish Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Oct 2007
Posts: 6
Ok, I'm officially stumped.

I saw a post on here last night that had a snippet of code in it that would work perfectly for me but I've just searched for over an hour and can't find it so here is my problem:
Code:
I have an auto updater which does this:
  reads from online file and checks for version number
  if version number is greater then:
    get the whole file and write it line by line to a local file
    remove current script
    rename the local file to the name of the (now ex-) current script
    reload current script


I have found that mIRC is freezing for anything up to 20 seconds doing this. I believe that grabbing the file down to a hash table then writing the hash table to a file would work a little quicker but I'm a bit stuck on how to put the info into the table and read it back out again.

I want this: (e.g.)
htable name: update
items:
1 line 1
2 line 2
3 line 3
n line n
etc...

The only way that I can think of doing this is by using a global variable but tbh, I hate global variables!

Any thoughts?
(Sorry it's not more detailed with code snippets n stuff - I've got about 3 mins to write this before I go back to work)

Joined: Aug 2004
Posts: 7,252
R
Hoopy frood
Offline
Hoopy frood
R
Joined: Aug 2004
Posts: 7,252
It would help a lot more if you could post your updater script, or if it's large, post it to a pastebin and give us a link to the script in the pastebin, or, since you said you saw it here, post a link to the code you got from here.

Joined: Nov 2007
Posts: 19
J
Pikka bird
Offline
Pikka bird
J
Joined: Nov 2007
Posts: 19
The updating script I use connects to a FTP server, and reads the file, line by line. Socketing to a HTTP port should still work, and write it line by line to a file.

Something like this should work.
Code:
on *:sockread:download: {
  sockread &s
  bwrite NAME.hsh -1 -1 &s
}
on *:sockclose:download: echo -a Download: NAME.hsh finished!


Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
As RusselB said, if you show us the script, we can offer more help. A normal socket script should not freeze mIRC at all when writing the data to a file, then reloading the script with the updated version. It should be virtually instantaneous unless the page you're downloading is huge and then it's a matter of the time to download the file. There may possible be an issue with write speed if you're going to use the /write command on every line, but that's why there is /fwrite. Of course, you can also echo it all to a window and save the contents of the window to the file in a single write, or use binary as was also suggested.

In any case, writing to a hash table would not make it faster.

Last edited by Riamus2; 03/11/07 10:34 PM.

Invision Support
#Invision on irc.irchighway.net
Joined: Oct 2007
Posts: 6
I
Ish Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Oct 2007
Posts: 6
Originally Posted By: Riamus2
In any case, writing to a hash table would not make it faster.


Thanks for giving the whole truth dude. I was thinking that it was a write spd issue coz it had to wait for the next line from the socket. I thought that writing to a hash table would then speed it up coz it already had the info there available.

I have been educated laugh

EDIT: I've tried both /fwrite and /bwrite like this:
(Sockread is read to %read which is then tokenized)
1: fwrite wcnconn2 $1-
2: fwrite -n wcnconn2 $1-
3: bwrite wcnconn2 -1 $1-
4: bwrite wcnconn2 -1 -1 $1-

(have also tried $mircdir $+ wcnconn2 instead of wcnconn2)
I have also tried replacing all of the "$1-" with "%read".
Each time I get the messages: insufficient parameters or invalid parameters.

Also, using bwrite caused a HUGE mIRC freeze.

Last edited by Ish; 04/11/07 07:10 PM.
Joined: Oct 2007
Posts: 6
I
Ish Offline OP
Nutrimatic drinks dispenser
OP Offline
Nutrimatic drinks dispenser
I
Joined: Oct 2007
Posts: 6
FIXED!

Way cool advice dude.

I used a custom window and then used aline @update $$1- to put the text in there then used filter -wf @update wcnconn2 to export it to a file and it works perfectly and only lags mIRC for about 4-5 seconds. A huge improvement on the 15+ seconds of lag that I was getting before.

Thankyou one and all again and again and again!

Last edited by Ish; 04/11/07 09:36 PM.
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Try this:

Code:
on *:sockread:newver: {
  var %read
  sockread %read
  if (scriptversion isin %read) { set -u10 %download.script On }
  if (%download.script) { write wcnconn2 %read }
}


No lag for me.


Invision Support
#Invision on irc.irchighway.net
Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Originally Posted By: Ish
Also, using bwrite caused a HUGE mIRC freeze.

It shouldn't, if used properly. I've never had any freezes and I use sockets a lot.

Code:
on *:sockread:sockname:{
  sockread -f &read
  bwrite FILENAME -1 -1 &read
}

Or, to skip the headers...
Code:
on *:sockread:sockname:{
  if ($sock($sockname).mark) {
    sockread -f &read
    bwrite FILENAME -1 -1 &read
  }
  else {
    var %read
    sockread %read
    if (!%read) { sockmark $sockname 1 }
  }
}


Joined: Dec 2002
Posts: 503
B
Fjord artisan
Offline
Fjord artisan
B
Joined: Dec 2002
Posts: 503
Post deleted by Bekar

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Thanks smile

(Code fixed)

Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
/me puts his magnifying glass aside und notes that there's a final square bracket where a brace should be in the "skip headers" part (...which I pinched brazenly) wink

Joined: Jun 2006
Posts: 508
D
Fjord artisan
Offline
Fjord artisan
D
Joined: Jun 2006
Posts: 508
Cheers smile


Link Copied to Clipboard