Jump to content
  • 0

how to overwrite already existing items in the table?


hoangninyb

Question

4 answers to this question

Recommended Posts

On 16.10.2021 at 20:11, hoangninyb said:

Oh great bro! Thank u!

Umh! Can I save Table1 to any file .txt?

Sample save - load txt..

if gg.isVisible(true) then 
gg.setVisible(false) 
end 

function main() 
Menu = gg.choice({'Save', 'Print', 'Close'}) 
if Menu == 1 then F1() end 
if Menu == 2 then F2() end 
if Menu == 3 then Exit() end 
end 

local Table1 = {"A","B","C"} 
Table1[1]="A1" 
--Table1[2]="B" 
Table1[3]="C1" 
local filePth = "/storage/sdcard/ShareFolder/test.txt"

function saveTable(t) 
local file = io.open(filePth,"w+") 

for i,k in ipairs(t) do 
file:write(k.."\n") 
end 
gg.alert("Save succesfull")
file:close() 
end 

function loadTable() 
local file1 = io.open(filePth,"r") 
rd = file1:read("*all") 
file1:close() 
return rd 
end 

function F1() 
saveTable(Table1) 
end 

function F2() 
tbl = loadTable() 
if tbl then 
gg.alert("load table:\n"..tbl) 
end 
end 

function Exit() 
gg.toast("SKTİR.COM / By AylinCE") 
gg.sleep(3000) 
os.exit() 
end 

main() 
while(true) do 
while gg.isVisible(true) do 
gg.setVisible(false) 
main() 
end 
end 

 

Link to comment
Share on other sites

5 hours ago, BadCase said:

Table[1] = "New Value"

Yes success.. 

local Table1 = {"A","B","C"}

Table1[1]="A1"
--Table1[2]="B"
Table1[3]="C1"

for i,k in ipairs(Table1) do
print(k.." - "..Table1[i])
end

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.