Hyperlink Syntax question

Posted by Horath on Mon 16 Jan 2012 10:53 PM — 2 posts, 12,240 views.

United Kingdom #0
Hi. I've been playing round with hyperlinks and have happily got several working. I'm now running into a problem. I'm hopeing im missing something blindingly obvious and its easy to fix.

All the hyperlinks I have working are in the format

Hyperlink ("!!" .. GetPluginID () .. ":content_save_hyperlink(" .. variable1 .. ")", name_line, "Click", "", "", false)


with a function

function content_save_hyperlink(var1)
print(var1)
end


somewhere in the plugin

if variable1 in the hyperlink were equal to "here" as an example the hyperlink when clicked prints quite simply "here"

I now have a hyperlink I would like to pass 2 variables to at the same time however using

Hyperlink ("!!" .. GetPluginID () .. ":content_save_hyperlink(" .. variable1 .. ", " .. variable2 .. ")", name_line, "Click", "", "", false)


with a function

function content_save_hyperlink(var1, var2)
print(var1, ":", var2)
end


somewhere in the plugin

If for example variable1 = "this" and variable2 = "here" in the hyperlink I now get from the function printing
"this, here: nil" (so var1 = "this, here" and var2 = nil)

Am I missing something or does the hyperlink sub function only accept single variables.

If this is so I can hack around it by passing both values as a single variable and then spliting them into 2 variables in the linked function (based on space, comma or whatever) but this isnt a particularly elegant solution as in the actual plugin the function the hyperlink is calling is used elsewhere as well where it doesnt require extra code to run through to split up lumped variables

Hope Im missing something
Australia Forum Administrator #1
The argument is passed to your function "as a string" as the documentation says. So in your case:


function content_save_hyperlink(var1)
  print(var1)
end



So var1 = "this, here" (as you acknowledge).

All you need to do is use a string.match or similar on that variable to break it into words.