If i have something which is being saved into a logfile, is it possible that you can make sure that the logfile will always show, if the script is cancelled?
#RumbaHi Besafe,
can you elaborate?
My reading of this is that you have a script executing that is writing to a file, and that when you manually stop the script you want the file to which you have been writing to automatically popup on screen in Notepad of some other viewer/editor.
Thanks in advance.
If i have something which is being saved into a logfile, is it possible that you can make sure that the logfile will always show, if the script is cancelled?
#Rumbawhat i mean is that i have a script running some processes for me, but to keep track of what exactly is being done, i would like to see me logfile even if i shut the processes down manually.
If i have something which is being saved into a logfile, is it possible that you can make sure that the logfile will always show, if the script is cancelled?
#RumbaHi Besafe,
this is my third time attempting to post this, and I lost both other attempts :-(
There are two things you need to consider.
1. If you want to update and view the log concurrently then you should log to Excel/Word or some other application which will has an OLE/COM interface, simply writing to a file on disk will not fly (very well).
2. If you want to automated post execution processing then you need to control how you half the script execution.
Given that you have been playing with Excel it's probably the easiest solution, however having said that Word is pretty easy to use also, it has a similar interface to Excel and they are lots of samples on the internet which you can use for inspiration !!
#2 is a little trickier. I had a play with this earlier and here is what I came up with.
First my macro that is doing the work.
Sub Main
'To create the trigger file
If Dir("C:\\Temp\\MyTriggerFile.txt") = "" then
Dim MyTriggerFile as Integer
MyTriggerFile = FreeFile
Open "C:\\Temp\\MyTriggerFile.txt" for Output As #MyTriggerFile
Close #MyTriggerFile
End If
Dim RowResult as Integer, ColumnResult as Integer
For i = 1 to 10
If Dir("C:\\Temp\\MyTriggerFile.txt") > "" then
EMWaitText 10,"===>", 19, 1, RowResult, ColumnResult
Else
Goto Here:
end If
Next i
Msgbox i
Exit Sub
Here:
If Dir("C:\\Temp\\MyTriggerFile.txt") > "" then
Kill "C:\\Temp\\MyTriggerFile.txt"
End If
Msgbox i
End Sub
As you can see above the main part of the macro, is the For loop, it simply waits for some text to appear in my terminal display. The original code would have been
Sub Main
Dim RowResult as Integer, ColumnResult as Integer
For i = 1 to 10
EMWaitText 10,"===>", 19, 1, RowResult, ColumnResult
Next i
End Sub
To that I have add code at the beginning to check to see if a file exists on disk and to create it it not (my trigger).
Next I wrap an If clause code around the code in my loop, to check if the file exists and if yes continue and if not jump to my "Here:" label.
Then I add an exit sub just before my "Here:" label, and I add the code I want to execute before halting execution after my "Here:" label.
So while the macro is executing it will continue to work as it did before, unless I delete the trigger file (C:\\Temp\\MyTriggerFile.txt).
Then I create a new script to delete the trigger file
Sub Main
Kill "C:\\Temp\\MyTriggerFile.txt"
End Sub
Now instead of stopping the script in Rumba using the Stop Script command, I can control the halting of the script, by executing my DeleteTriggerFile macro.
To bring the Excel or Word log file to the Foreground you can make it visible and use AppActivate to show it to the user.
If you wish to stop the Rumba script from the Excel or Word side you should be able to execute the same Kill command in Excel/Word VBA to halt the Rumba macro execution (in a controlled fashion).
Hope that helps,
Tom