Page 1 of 1

Check Version In Store (code snippet)

Posted: 26 Apr 2012 13:58
by tatewise
Jane, regarding the Check Version In Store snippet, the following variation appears to work well with only one parameter, or if parameter is missing:

Code: Select all

function checkVersionInStore(plugin)
local http = luacom.CreateObject('winhttp.winhttprequest.5.1')
local strRequest = 'http://www.family-historian.co.uk/lnk/checkpluginversion.php?'
if tonumber(plugin) then
      strRequest = strRequest..'id='..plugin
elseif plugin then
      strRequest = strRequest..'name='..plugin
end
ID:6191

Check Version In Store (code snippet)

Posted: 26 Apr 2012 14:12
by Jane
You can add it as a variation on the page, if you like, personally I prefer to try keep the code transparent, so would rather have two parameters or even two different functions, rather than assume a number is an id and a string a name.

Check Version In Store (code snippet)

Posted: 26 Apr 2012 14:39
by tatewise
OK, I will add the one parameter variant as Version 2.

However, the two parameter version might be better as follows:

Code: Select all

local strRequest = 'http://www.family-historian.co.uk/lnk/checkpluginversion.php?'
if pluginname then
      strRequest = strRequest..'name='..pluginname
elseif tonumber(pluginid) then
      strRequest = strRequest..'id='..pluginid
end
that checks 1st parameter is numeric, and fails less abruptly when no parameters.