PDA

View Full Version : txt file add to line.


bobbie
02-14-2007, 05:30 PM
I have this from the manual :
And it works fine adding the four to the line 2 .
What I would like to do is add it to the line at the end of a paragraph .
So it would read like ....
toolbar.borderColor: White and add the White to the paragraph.
Little help with this anyone.
Thanks
-- Read the contents of a text file to a table.
text_contents = TextFile.ReadToTable("C:\\MyFile.txt");

-- Get the error code of the last action.
error = Application.GetLastError();

-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
-- Remove the second item in the table (second line in the text file).
--Table.Remove(text_contents, 2);
Table.Insert(text_contents, 2, "White");


-- Write out the modified text file.
TextFile.WriteFromTable("C:\\MyFile.txt", text_contents, false);

-- Get the error code of the last action.
error = Application.GetLastError();
-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end
end

bobbie
02-14-2007, 06:08 PM
Well gotten this far but still can't add to the line from Input1?
Just adds the toolbar.borderColor:.

-- Read the contents of a text file to a table.
text_contents = TextFile.ReadToTable("C:\\MyFile.txt");
Input1 = Input.GetText("Input1");

-- Get the error code of the last action.
error = Application.GetLastError();

-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
Table.Insert(text_contents, 2,"toolbar.borderColor:", "Input1");


-- Write out the modified text file.
TextFile.WriteFromTable("C:\\MyFile.txt", text_contents, false);

-- Get the error code of the last action.
error = Application.GetLastError();
-- If an error occurred, display the error code message.
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
end
end

Dermot
02-14-2007, 06:25 PM
Try

Table.Insert(text_contents, 2,"toolbar.borderColor:"..Input1);

bobbie
02-14-2007, 06:28 PM
Thank you so much, I will try it right now.

bobbie
02-14-2007, 09:53 PM
How can I add a space in the line so they don't follow right after the end?
I tried a tab bit didn't seem to help.
So it looks like this with the printout.
toolbar.color: space here #420000
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION);
else
Table.Insert(text_contents, 1,"style.name:" ..Input1);
Table.Insert(text_contents, 2,"style.author:" ..Input2);
Table.Insert(text_contents, 3,"style.date:" ..Input3);
Table.Insert(text_contents, 4,"style.credits:" ..Input4);
Table.Insert(text_contents, 5,"style.comments:" ..Input5);
Table.Insert(text_contents, 6,"toolbar:"..Input6);
Table.Insert(text_contents, 7,"toolbar.color:"..Input7);
Table.Insert(text_contents, 8,"toolbar.colorTo:"..Input8);
Table.Insert(text_contents, 9,"toolbar.font:"..Input9);
Table.Insert(text_contents, 10,"toolbar.fontHeight:"..Input10);
Table.Insert(text_contents, 11,"toolbar.fontWeight:"..Input11);
Table.Insert(text_contents, 12,"toolbar.justify:"..Input12);
Table.Insert(text_contents, 13,"toolbar.textcolor:"..Input13);
Table.Insert(text_contents, 14,"toolbar.button:"..Input14);
Table.Insert(text_contents, 15,"toolbar.button.color:"..Input15);
Table.Insert(text_contents, 16,"toolbar.button.colorTo:"..Input16);
Table.Insert(text_contents, 17,"toolbar.button.picColor:"..Input17);
Table.Insert(text_contents, 18,"toolbar.button.pressed:"..Input18);

Dermot
02-14-2007, 10:00 PM
Just put the space like this after the :

Table.Insert(text_contents, 7,"toolbar.color: "..Input7);

bobbie
02-14-2007, 10:35 PM
Thank you again. I see what I was doing wrong now. heh heh