View Full Version : write to txt file help needed !!!
GoOgLe
08-19-2009, 10:59 AM
i dont understand why it doesnt write to txt file !!!
new_contents = Input.GetText("Input1");
if e_Key == 13 then
if(new_contents)then
for i, v in new_contents do
TextFile.WriteFromString("AutoPlay\\Scripts\\history.txt", v.."\r\n", true)
end
else
Dialog.Message("Error", "No Text");
end
end
Imagine Programming
08-19-2009, 11:12 AM
Because Input.GetText doesn't return a table, but a string. So looping through it won't work unless you convert it to a table.
From input.
if(e_Key==13)then -- Enter is pressed
if(new_contents~="")then -- Making sure the new content is nog empty!
TextFile.WriteFromString("Autoplay\\Scripts\\history.txt", new_contents.."\r\n", true);
else
Dialog.Message("Error", "No Text");
end
end
GoOgLe
08-19-2009, 11:22 AM
com'on man it doesnt work again ?!
can it b because it is scripts folder !
new_contents = Input.GetText("Input1");
if(e_Key==13)then -- Enter is pressed
if(new_contents~="")then -- Making sure the new content is nog empty!
TextFile.WriteFromString("Autoplay\\Scripts\\history.txt", new_contents.."\r\n", true);
else
Dialog.Message("Error", "No Text");
end
end
Imagine Programming
08-19-2009, 11:29 AM
com'on man it doesnt work again ?!
can it b because it is scripts folder !
new_contents = Input.GetText("Input1");
if(e_Key==13)then -- Enter is pressed
if(new_contents~="")then -- Making sure the new content is nog empty!
TextFile.WriteFromString("Autoplay\\Scripts\\history.txt", new_contents.."\r\n", true);
else
Dialog.Message("Error", "No Text");
end
end
Are you sure the object "Input1" exists? Try this example (works fine here)
Powered by vBulletin™ Version 4.0.6 Copyright © 2012 vBulletin Solutions, Inc. All rights reserved.