NextAvailable = {}
local flag = '0'
for i = 1, 100 do
table.insert(NextAvailable , SKIN:GetVariable('B'..i))
if NextAvailable[i] == '1' then
flag = '1'
SKIN:Bang(string.format('!WriteKeyValue Variables B%s "0" "#@#FileToEdit.txt"', #NextAvailable))
break
end
end
I want to use the current i instead of the #NextAvailable (as this is a table and not a number) but when I write this: SKIN:Bang(string.format('!WriteKeyValue Variables B%s "0" "#@#FileToEdit.txt"', #i)) it doesn't work as it reports a syntax error. What would the correct syntax be in order to write something in the variable B#i#?
If the BXX variables are definitely numbers, try to convert the got variable to number, using the tonumber function: table.insert(NextAvailable , tonumber(SKIN:GetVariable('B'..i))).
If this doesn't fix the issue (and probably it doesn't), please pack the config and upload it, to can check what's going on.
balala wrote:If the BXX variables are definitely numbers, try to convert the got variable to number, using the tonumber function: table.insert(NextAvailable , tonumber(SKIN:GetVariable('B'..i))).
If this doesn't fix the issue (and probably it doesn't), please pack the config and upload it, to can check what's going on.
balala wrote:Really? I'm a bit surprised, but I'm glad in this case.
Yea, just so I'm sure I understand what happened here, does the tonumber command converts everything to numbers? And I suppose that in my table everything was strings?
kyriakos876 wrote:does the tonumber command converts everything to numbers?
Everything which is possible. There is no way to convert for example an a to number, but if a string is composed from digits, then yes, it is converted to number.
kyriakos876 wrote:And I suppose that in my table everything was strings?
this doesn't work but as soon as I remove the filetowrite parameter, it works normally. What could be causing that?
Try this: SKIN:Bang(string.format('!WriteKeyValue Variables B%s "1" [color=#FF0000]"[/color]#@#FileToEdit.txt[color=#FF0000]"[/color]', LastAdded))
As you can see I included the file into quotations. This will help especially if the file path contains spaces. But even if it doesn't, it worth a try.
Please let me know if it did help.