Reputation: 13
Am having this problem from when I try to make information in a table as a variable.
If I write;
Username = "admin"
Password = "admin"
table = {["p_targetId"] = 0 ,["p_cmd"] = "getProductListSaved" , ["p_userName"] = Username, ["p_password"] = Password , ["p_data"] = {{}}}
Get_Info = rapidjson.encode(table)
I get
{"p_targetId":"0","p_cmd":"getProductListSaved","p_userName":"admin","p_password":"admin","p_data":[{}]}
which I want to get. But when I write;
Enter_Password = Controls.Enter_Password
Password = "admin"
table = {["p_targetId"] = 0 ,["p_cmd"] = "getProductListSaved" , ["p_userName"] = Username, ["p_password"] = Password , ["p_data"] = {{}}}
table["p_password"] = tostring(Enter_Password.String)
table2 = rapidjson.encode(table)
When in Textbox I write admin enter image description here , I get
{"p_targetId":"0","p_cmd":"getProductListSaved","p_userName":"admin","p_password":"","p_data":[{}]}
After reading some forums. It seems my input Textbox string is not being saved into local Password, thus in table will stay as "".
Is there a way to store "admin" in Textbox into a variable, also changes when another string is in Textbox?
Upvotes: 0
Views: 69
Reputation: 13
Found the solution, basically needed to make a function with string.format() to save my Input in a variable.
if Enter_Password.String ~= "" then
Password = string.format("%s", Enter_Password.String)
table["p_password"] = Password
end
Upvotes: 1