i am trying to create a log file this is a .txt file ...what i need is to add text each time on a different line..... write now i can get text to the file using TextFile.WriteFromString but each time it is added to the end of the line and i need it to be on a seperate line each time ap ver5
Announcement
Collapse
No announcement yet.
text file
Collapse
X
-
Hi bufobill and welcome to the forum,
an easy way to append a text file is to read to table and append the next log file line
Here I've done an example for you
Text_Files_And_Tables.apz
Have a play and Cheers
-
thank you so much for your input, im kind of a beginner at this ............but what if i didnt want the user to have any control over entering text in the log.txt file .... i would have the date and time that he started in this log and the time he ended by clicking stop button and then the next time he logged in it would be on the line under the last one ..... and so on and so on .1 Photo
Comment
-
Hi Again,
OK the variable myDT is the path to desktop
Code:myDT = Shell.GetFolder(SHF_DESKTOP);
Code:c:\\kelly
you don't have to use myDT but could use Path = C:\\kelly then
change line TextFile.WriteFromTable(myDT.."\\login.txt", tblResult, false);
to TextFile.WriteFromTable(Path.."\\login.txt", tblResult, false);
Cheers
Comment
-
do you mean like this? if so i get an error on line 1
Path = C:\\kelly
if (File.DoesExist(Path.."\\login.txt")) then
tblResult = TextFile.ReadToTable(Path.."\\login.txt");
tcount = Table.Count(tblResult);
snLine = tcount + 1
else
tblResult = {}
snLine = 1
end
sEndTime = System.GetTime(TIME_FMT_MIL);--Get time logout
--Concat string for user / login /logout
sOut = sUserName.." - Logged in : "..sInstallDateTime.." Logged Out : "..sEndTime
--insert string at end of table
Table.Insert(tblResult,snLine , sOut);
TextFile.WriteFromTable(Path.."\\login.txt", tblResult, false);
Dialog.TimedMessage("Please Wait...", "Now Logging "..sUserName.." OFF", 2000, MB_ICONINFORMATION);
Application.Exit(0);
Comment
Comment