Jump to content

How to use $urlget


err0r

Recommended Posts

I found a couple of examples that show how to use $urlget. I found them helpful. I am posting them here to ensure there is a copy.

First one is by Raccoon:

F12 mirc_check_for_updates
mirc_check_for_updates {
  var %url = https://www.mirc.co.uk/update.html
  var %ret = $urlget(%url,gb,&b,mirc_check_for_updates_2)
  if (%ret) {
    echo -atic notice *** Check for Updates: One moment please...
  }
  else {
    echo -atic notice *** Check for Updates: Error. Check your network connection?
  }
}
mirc_check_for_updates_2 {
  var %id = $1
  var %target = $urlget(%id).target
  var %text = $bvar(%target,1-).text
  var %version = $regsubex(%text,/.*"v([0-9.]+)".*/s,\1)
  if (%version > $version) {
    echo -atic notice *** Check for Updates: A newer version of mIRC is available! v $+ %version > v $+ $version
    echo -atic notice *** Download it from http://www.mirc.com/get.html
  }
  elseif (%version == $version) {
    echo -atic notice *** Check for Updates: You are using the current version of mIRC. v $+ %version
  }
  elseif (%version < $version) {
    echo -atic notice *** Check for Updates: You must be using a beta version, or you are Khaled. v $+ $version > v $+ %version
  }
  else {
    echo -atic notice *** Check for Updates: Could not get update information. Check your network connection.
  }
} ; by Raccoon 2020

Second one is by kap:

alias getURL {
  if ($1) {
    if ($1 isnum) { 
      if ($urlget($1).state == fail) { echo -atic notice *** Are you connected to the internet? | halt }
      .run notepad.exe $qt($urlget($1).target)
    }
    else {
      var %target getURL.txt
      write -c %target
      return $urlget($1,gf,%target,getURL)
    }
  }
}

/getURL https://www.mirc.com/versions.txt

You can also follow the thread of the original post @ mirc.com forum

Link to comment
Share on other sites

  • 1 month later...

Racoon is a n00b :)

But, regarding the subject: Do you know that $urlget is some slower than to use an vbscript to download the file using $com? My benchs that i've did result:

1. For a file till 5MB the difference is in 1-2 seconds.

2. For a file larger than 50mb the difference is around 7-15 seconds :) 

Of course, vbscript directly use Windows Api for this, but $urlget not so easy.. 

Link to comment
Share on other sites

  • 2 years later...
On 2/24/2021 at 10:22 PM, Loveness said:

Racoon is a n00b :)

Season 1 Lol GIF by NBC

I am not exactly a noob myself, but Raccoon (double "c") is way more knowledgeable than me.

See the last page of the nascent mIRC knowledge base at https://mirckb.readthedocs.io/_/downloads/en/latest/pdf/ to see the list of people who might be considered reasonably expert on mSL. Raccoon's name is there as is mine (twice as it happens because I have used two nicks over the years - not that my knowledge deserves two mentions). But funnily enough, I don't see Loveness mentioned there.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...