PDA

View Full Version : Help inputing text


marsoa5
11-18-2006, 11:16 AM
Hi guys, i'm kinda new to autoplay but i read this forum everyday fro your great projects and help. I need help with something i can't quite grasp yet. I need to on click to delete last line of text in a .lua file, then get text from input and automatically add = "", after the inputed text.
I'm sorry if tis sounds counfusing, my main problem is that i cant add = "", automatically to the text file because ams won't allow it.

help me out please! :huh
thank you in advance!

marsoa5
11-18-2006, 12:03 PM
i figured out how to combine the text from an input and automatically add = "", to it so now all i really need is to find a way to delete the last line of either a text or .lua file. :eek:

any suggestions?

jfxwave
11-18-2006, 01:50 PM
I think you should post the part you need help with. We all do things different so if you post it we can see the way your going and help that way.

:D

marsoa5
11-18-2006, 02:13 PM
heres part of the code im using, it basically finds the text "};" in the specified text file and deletes it. Then it extracts the text from an input box and adds " = ""," to it and appends it to the end of the selected file. Then it adds "};" to the end of the file. My problem now is that when it looks for the text "};" it deletes the whole line it is located in, and when i add it back on it appends it to the end of the last line in the text file which means if i was to reedit it it would delete the last line. I need to find a way to append the text from an input into a new line in a text file. any suggestions would be great.

:huh





-- Declare the location of your text file and the sting you are looking for
g_MyTextFile = "AutoPlay\\Docs\\" .. strManufacturer .. ".lua"
-- Create a global variable and assign a string to it
g_SearchString = " };"

-- Setup an empty table to hold the contents of your text file
t_TextFile = {};

-- Read the contents of your text file to the table (See help file for more info)
t_TextFile = TextFile.ReadToTable(g_MyTextFile);

local index;
local line;
for index, line in t_TextFile do
if String.Find(line, g_SearchString, 1, false) == 1 then
Table.Remove(t_TextFile, index);
end
end

-- Write the results back to your text file
TextFile.WriteFromTable(g_MyTextFile, t_TextFile, false);

strInpData = Input.GetText("Input3")

Input.SetText("Input3", ''..strInpData..' = "",')
finadd = Input.GetText("Input3")
TextFile.WriteFromString("AutoPlay\\Docs\\" .. strManufacturer .. ".lua", finadd, true);
TextFile.WriteFromString("AutoPlay\\Docs\\" .. strManufacturer .. ".lua", g_SearchString, true);
Input.SetText("Input3", "")