NIKITAOFF Posted December 12, 2018 Posted December 12, 2018 I want to save to file the text that I entered in gg.prompt function main() m = gg.choice({ "Write", "Exit" },nil,"test") if m == nil then else if m == 1 then write() end if m == 2 then exit() end end farm = -1 end function write() local writename = "/sdcard/Download/log.txt" local write write = io.open(writename,"w") write:write(gg.prompt( {'test'}, {[1]='write here'}, {[1]='text'} )) if crashw == nil then gg.alert("You did not enter anything") main() end gg.setVisible(true) print('Yeah!!!') os.exit() end function exit() os.exit() end while true do if gg.isVisible(true) then farm = 1 gg.setVisible(false) end if farm == 1 then main() end end
NIKITAOFF Posted December 19, 2018 Author Posted December 19, 2018 On Thu Dec 13 2018 at 8:00 AM, Revoxtical said: Try this : function main() local m = gg.choice({"Write", "Exit"}, nil, "test") if m ~= nil then if m == 1 then write() end if m == 2 then exit() end end end function write() local txt = gg.prompt({'test'}, {'write here'}, {'text'}) if txt ~= nil and #txt[1] > 0 then local f = io.open("/sdcard/Download/log.txt", "w") f:write(txt[1]) f:close() gg.setVisible(true) print('Yeah!!!') exit() else gg.alert("You did not enter anything") end end function exit() os.exit() end while true do if gg.isVisible() then gg.setVisible(false) main() end gg.sleep(100) end Thank you very much!!
Revoxtical Posted December 13, 2018 Posted December 13, 2018 14 hours ago, NIKITAOFF said: I want to save to file the text that I entered in gg.prompt function main() m = gg.choice({ "Write", "Exit" },nil,"test") if m == nil then else if m == 1 then write() end if m == 2 then exit() end end farm = -1 end function write() local writename = "/sdcard/Download/log.txt" local write write = io.open(writename,"w") write:write(gg.prompt( {'test'}, {[1]='write here'}, {[1]='text'} )) if crashw == nil then gg.alert("You did not enter anything") main() end gg.setVisible(true) print('Yeah!!!') os.exit() end function exit() os.exit() end while true do if gg.isVisible(true) then farm = 1 gg.setVisible(false) end if farm == 1 then main() end end Try this : function main() local m = gg.choice({"Write", "Exit"}, nil, "test") if m ~= nil then if m == 1 then write() end if m == 2 then exit() end end end function write() local txt = gg.prompt({'test'}, {'write here'}, {'text'}) if txt ~= nil and #txt[1] > 0 then local f = io.open("/sdcard/Download/log.txt", "w") f:write(txt[1]) f:close() gg.setVisible(true) print('Yeah!!!') exit() else gg.alert("You did not enter anything") end end function exit() os.exit() end while true do if gg.isVisible() then gg.setVisible(false) main() end gg.sleep(100) end
Question
NIKITAOFF
I want to save to file the text that I entered in gg.prompt
function main()
m = gg.choice({
"Write",
"Exit"
},nil,"test")
if m == nil then else
if m == 1 then write() end
if m == 2 then exit() end
end
farm = -1
end
function write()
local writename = "/sdcard/Download/log.txt"
local write
write = io.open(writename,"w")
write:write(gg.prompt(
{'test'},
{[1]='write here'},
{[1]='text'}
))
if crashw == nil then
gg.alert("You did not enter anything")
main()
end
gg.setVisible(true)
print('Yeah!!!')
os.exit()
end
function exit()
os.exit()
end
while true do
if gg.isVisible(true) then
farm = 1
gg.setVisible(false)
end
if farm == 1 then main()
end
end
2 answers to this question
Recommended Posts
Archived
This topic is now archived and is closed to further replies.