mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
Here's a simple example using $urlget() to get people started.
I don't see any in the help file, so here's something useful.

Code
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 == 0) {
    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

Is there any error checking capabilities for winsock errors? Besides the initial $urlget() returning a value of 0?



Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Feb 2003
Posts: 2,812
Raccoon Offline OP
Hoopy frood
OP Offline
Hoopy frood
Joined: Feb 2003
Posts: 2,812
I should have put in an affirmation response to let you know that $urlget() is working. So here's the code adjustment.
Line 5:
Code
  if (%ret) {
    echo -atic notice *** Check for Updates: One moment please...
  }
  else {
    echo -atic notice *** Check for Updates: Error. Check your network connection?
  }


Well. At least I won lunch.
Good philosophy, see good in bad, I like!
Joined: Feb 2015
Posts: 138
kap Offline
Vogon poet
Offline
Vogon poet
Joined: Feb 2015
Posts: 138
Here's my €0,02:

Code
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)
    }
  }
}


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


GNU Terry Pratchett - Looking for a mIRC help channel -> Check #mircscripting @ irc.swiftirc.net

Link Copied to Clipboard