PDA

View Full Version : How do i get last line in text?


kdh7807
05-29-2006, 04:47 AM
beginning_line = 4;
end_line = 10;

-- populate a table with the contents of a text file
tabText = TextFile.ReadToTable("c:\\test.txt");

-- Initialize variable strLinesOfText
strLinesOfText = "";

-- Set the current line number
line = beginning_line;

-- Loop through table until end condition is reached
while line < (end_line + 1) do
-- Append data to variable strLengthOfText
strLinesOfText = strLinesOfText .. "\r\n" .. "Line " .. line .. ": " .. tabText[line] .. "\r\n";
line = line + 1;
end

i want set end_line automatically
how do i get last line in txt file?

Wonderboy
05-29-2006, 05:22 AM
Look up String reverse Find in help!

Mina
05-29-2006, 09:10 AM
Hi. I haven't tested the code yet, but it should work perfectly :yes
-- Get Last Line
tabText = TextFile.ReadToTable("c:\\test.txt");
tblC = Table.Count(tabText);
Last_Line = tabText[tblC]

kdh7807
05-30-2006, 03:50 AM
Hi. I haven't tested the code yet, but it should work perfectly :yes
-- Get Last Line
tabText = TextFile.ReadToTable("c:\\test.txt");
tblC = Table.Count(tabText);
Last_Line = tabText[tblC]

thanks!!! :D