View Full Version : Use a variable in a table
nicoh
10-26-2008, 08:53 PM
Hi, Im trying to make a search with AMS to collect the results.
Im using the funcion HTTP.Submit, and the values must be stored in a TABLE (not into a string).
I don't know what is the method or the syntax that I must use to set a variable as a value on the table.
My variable is keyWORDS:
if I use myvalues = {q=keyWORDS}; I haven't got any result.
if I use myvalues = {q="keyWORDS"}; It search "keyWORDS"
keyWORDS = Input.GetText("Input1");
myvalues = {q=keyWORDS};
sResult = HTTP.Submit("http://www.searchengine.com/search.php", myvalues, SUBMITWEB_GET, 20, 80, nil, nil);
If somebody knows a solution please tell me :)
ShadowUK
10-27-2008, 01:44 AM
Hi, Im trying to make a search with AMS to collect the results.
Im using the funcion HTTP.Submit, and the values must be stored in a TABLE (not into a string).
I don't know what is the method or the syntax that I must use to set a variable as a value on the table.
My variable is keyWORDS:
if I use myvalues = {q=keyWORDS}; I haven't got any result.
if I use myvalues = {q="keyWORDS"}; It search "keyWORDS"
keyWORDS = Input.GetText("Input1");
myvalues = {q=keyWORDS};
sResult = HTTP.Submit("http://www.searchengine.com/search.php", myvalues, SUBMITWEB_GET, 20, 80, nil, nil);
If somebody knows a solution please tell me :)
All code that you want is in the Go button.
Hi, Im trying to make a search with AMS to collect the results.
Im using the funcion HTTP.Submit, and the values must be stored in a TABLE (not into a string).
I don't know what is the method or the syntax that I must use to set a variable as a value on the table.
My variable is keyWORDS:
if I use myvalues = {q=keyWORDS}; I haven't got any result.
if I use myvalues = {q="keyWORDS"}; It search "keyWORDS"
keyWORDS = Input.GetText("Input1");
myvalues = {q=keyWORDS};
sResult = HTTP.Submit("http://www.searchengine.com/search.php", myvalues, SUBMITWEB_GET, 20, 80, nil, nil);
If somebody knows a solution please tell me :)
-- initialize our table
local myvalues = {};
-- get keywords from user input: using 'tostring' on functions that return strings is too redundant and not necessary.
local keyWORDS = Input.GetText("Input1");
-- At this point it is a good idea to check user input and perform accordingly
If (keyWORDS == "") then return; end -- basic check
-- store value in table: can also be done like; myvalues["q"] = keyWORDS;
myvalues.q = keyWORDS;
-- get search results: NOTE: Use this way if you want to get output of the search results for use in a file or something of the like
local sResult = HTTP.Submit("http://www.searchengine.com/search.php", myvalues, SUBMITWEB_GET, 20, 80, nil, nil);
-- To actually show the results of the search in a Web object in your application you first need to build your URL using your myvalues table.
-- Build our URL
local sURL = "http://www.searchengine.com/search.php?"..myvalues.q;
-- Load the URL with an web object
Web.LoadURL("WebObjectName", sURL);
nicoh
10-27-2008, 03:25 AM
Thanks for the quick answer. Ill try both methods.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.