* resolving unnamed return value in place.

For users to report plugin bugs and request plugin enhancements; and for authors to test new/new versions of plugins, and to discuss plugin development (in the Programming Technicalities sub-forum). If you want advice on choosing or using a plugin, please ask in General Usage or an appropriate sub-forum.
Post Reply
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

resolving unnamed return value in place.

Post by Ron Melby »

local _pl = string.format('%s%s%s', __ipath.temp, ((rtvpgnam())), '.fh_prf')
ipath resolves in place
how do I get rtvpgnam to resolve in place? there is one return value
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28434
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: resolving unnamed return value in place.

Post by tatewise »

local _pl = string.format('%s%s%s', __ipath.temp, rtvpgnam(), '.fh_prf') should work OK.
You don't need the enclosing parentheses if rtvpgnam() only has one return value.

However, that return value must be a text string to satisfy the %s format.
If it is not a text string then tostring(rtvpgnam()) might convert it, but won't work if the return value is a table or a pointer.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: resolving unnamed return value in place.

Post by Ron Melby »

I absolutely think it should work too, and I must be missing something simple. I am sure I have done this type of thing before.

fred = rtvpgnam()
local _pl = string.format('%s%s%s', __ipath.temp, rtvpgnam(), '.fh_prf')
local _pl = string.format('%s%s%s', __ipath.temp, rtvpgnam, '.fh_prf')
local _pl = string.format('%s%s%s', __ipath.temp, tostring(rtvpgnam()), '.fh_prf')

fred = "fhF264"
bad argument #2 to 'format' (string expected, got function)
is the errror for any of the three _pl statements


and here is the function, just because:

function rtvpgnam()
local pg = fhGetContextInfo('CI_PLUGIN_NAME')
if pg == '' then
pg = debug.getinfo(2).source:gsub('.*~',''):gsub('%.%w*','') -- because fh sloshes out incorrect results again
end
return pg
end
FH V.6.2.7 Win 10 64 bit
User avatar
tatewise
Megastar
Posts: 28434
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: resolving unnamed return value in place.

Post by tatewise »

You are trying to fix the wrong argument.
argument #1 to 'format' is '%s%s%s'
argument #2 to 'format' is __ipath.temp ~ so this is the bad function ~ try replacing it with a 'string'
argument #3 to 'format' is rtvpgnam()

i.e. Does the following fail?
local _pl = string.format('%s%s%s', 'xyz', rtvpgnam(), '.fh_prf')
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Ron Melby
Megastar
Posts: 928
Joined: 15 Nov 2016 15:40
Family Historian: V6.2

Re: resolving unnamed return value in place.

Post by Ron Melby »

dont know why my brain did not see '%s%s%s' as an arg. fixed, but more issues in the offing, thanks to non-consistent fh.
FH V.6.2.7 Win 10 64 bit
Post Reply