* Check Version In Store (code snippet)

Homeless Posts from the old forum system
Locked
User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check Version In Store (code snippet)

Post by tatewise » 26 Apr 2012 13:58

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

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Check Version In Store (code snippet)

Post by Jane » 26 Apr 2012 14:12

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.

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Check Version In Store (code snippet)

Post by tatewise » 26 Apr 2012 14:39

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.

Locked