hoangninyb Posted October 16, 2021 Posted October 16, 2021 local Table = {} I use the insert method in the table and the result is: table.insert(Table, item) Table = {"A","B","C"} how can I overwrite item "A" in Table when I keep inserting "A" into Table?
AylinCE Posted October 17, 2021 Posted October 17, 2021 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
AylinCE Posted October 16, 2021 Posted October 16, 2021 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
hoangninyb Posted October 16, 2021 Author Posted October 16, 2021 3 hours ago, AylinCE said: Vâng, thành công .. Oh great bro! Thank u! Umh! Can I save Table1 to any file .txt?
Question
hoangninyb
I use the insert method in the table and the result is:
how can I overwrite item "A" in Table when I keep inserting "A" into Table?
4 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.