This file ran fine twice then stoped running

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

This file ran fine twice then stoped running

Post by Aaron » Tue Apr 24, 2007 8:17 am

I worked on this all day seaching differant post and wrote the script below.

I ran the script twice then it stoped running. If anyone could see why it would stop responding please help out.

Im allways needing to back up my files as im just a beginner and experiment alot with code from the forums.

Thanks in advance

Code: Select all

WaitWindowOpen>Editor - Script_05

WaitWindowClosed>Editor - Script_05

Let>WriteFromFileName=Script_05.scp

Let>WriteFromFile=C:\Documents and Settings\Owner\My Documents\Macro Scheduler\Script_05.scp

Let>WriteToFile=C:\Edited_Script_05.txt

Day>the_day

Month>the_month

Year>the_year

GetTime>time

Let>msg=The Script Named: %WriteFromFileName% was Edited on %the_month%/%the_day%/%the_year% at 

ConCat>msg,time

WriteLn>%WriteToFile%,result,%msg%
Aaron

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 24, 2007 8:38 am

Why don't you just enable backups in the editor under Tools/Backup on Save?
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

Backup on save

Post by Aaron » Tue Apr 24, 2007 2:20 pm

Wow, I dont know how I missed that in the tutorial.

Great feature.

Still, I wont learn much if I just take the easy way out and never finish what I start.

Could you give me some idea why the script would stop working?

I was also hoping to use this script in backing up other files I change often.


Thanks
Aaron

User avatar
Marcus Tettmar
Site Admin
Posts: 7395
Joined: Thu Sep 19, 2002 3:00 pm
Location: Dorset, UK
Contact:

Post by Marcus Tettmar » Tue Apr 24, 2007 2:24 pm

> Could you give me some idea why the script would stop
>working?

My guess is because the first two lines wait for "Editor - Script_05" window to open and then close again. If neither of these things ever happen (the editor window may not always have Script_05 open in it) then the script will wait for ever.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar

Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

Any idea what to do about it

Post by Aaron » Tue Apr 24, 2007 4:57 pm

So whats the solution?

I Want the program to run hidden when I start the computer.
If the script runs I dont want it to close down after it runs the first time.

I want it to always be waiting to run the script the next time around.

Perhaps the WaitWindowOpen and the WaitWindowClose is not the best option, considering I would like to save the edited version even if the script was run without being saved or closed.

After the time and date is saved, I want to write the line of code that was changed, perhaps if posible along with the line numbers included.

Next, I would like to write the new edited version to the file after process 1 and 2

This will save time when going back over the notes.

Can I have a macro that knows somehow that the script was run or saved, then run the processes above.

I looked into the FileChanged.
If I understand it correctly, it seems that it opens and reads the file on an hourly schedual to see if changes have been made

Could there be a SRT that checks every second or so, or better yet something that waits so as not to use to much of the cpu.

By the way, would you let me know where the backup on saved files are?
I cant find them anywhere and there dose not seam to be any documentation in the help.
If there is, Please point me to it.

Thanks
Aaron

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Apr 24, 2007 5:12 pm

Aaron,

Could you go back a couple of steps and just explain what you want to achieve with this script?

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

Post by Aaron » Tue Apr 24, 2007 8:13 pm

I was trying to get the macro to Wait until I open my script up in MS advanced editor.

It would then watch the window and when it closes, it would write to a text file the name of the file along with the date and time that it was edited.

This of course was only one part of the code as you can see from the last post. I wanted to let everyone see what the overall script is suppose to do so that if I'm going about this all wrong it could be spotted now.

If I were to use it without the WaitWindowClose it would give me the time and date, but I would need to save the script then close it and reopen it again to get the edited code posted to the text file.

Maybe it would work without the WaitWindowOpen?

Any ideas would be appreciated.
Aaron

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Apr 24, 2007 8:49 pm

So you want to maintain a history of each time you edit a macro?

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

Exactly

Post by Aaron » Tue Apr 24, 2007 10:03 pm

Any idea how to work with the WaitWindowOpen and WaitWindowClose to accomplish this?
Aaron

Me_again
Automation Wizard
Posts: 1101
Joined: Fri Jan 07, 2005 5:55 pm
Location: Somewhere else on the planet

Post by Me_again » Tue Apr 24, 2007 10:20 pm

No, sorry, I don't know how to make it work the way you are trying.

I can answer the backup question though. Mine are saved in the same directory as the .scp's, so each time mymacro.scp is saved it is backed up as mymacro.001, mymacro.002, mymacro.003 etc.

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Tue Apr 24, 2007 11:08 pm

you want to maintain a history of each time you edit a macro?
How about starting the editor with a macro?

The macro could prompt you to select the macro file that you want to edit, do a time/user stamp to a log file, open the editor for that macro file, and the macro would end.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Post by jpuziano » Tue Apr 24, 2007 11:39 pm

Hi Aaron,

You do come up with some interesting challenges...

My macro files (and backup copies of them) are found in:

C:\Documents and Settings\myusername\Application Data\Macro Scheduler

If you don't find them there, you might try:

C:\Program Files\MJT Net Ltd\Macro Scheduler

And if you still can't find where they are, just use file explorer to search for all *.scp files on your hard drive and it should find them.

Yes, I would highly recommend you keep backups turned on. A few times I have gone in and made changes to a macro, saved (or so I thought), ran the macro to test, it contains a coding error so it locks up or dies in some strange way... and then I've found the text of my macro has vanished. :shock:

Now if I didn't have backups turned on, I'd be ticked. As it is, I just open the most recent backup file (macroname.001 or whatever), copy the text, open the now-empty macro in Macro Scheduler Advanced Editor and paste the whole macro back in, no harm done.

How often does this happen? Very rarely these days... twice a year perhaps. And to be fair, it could even be one of my own macros being triggered and deleting the text. If I ever find out how to replicate the problem I'll post the steps for Support but until then, the backup setting is staying on.

You seem to be trying to make a macro that will log the names of macro files you've changed and the dates you've changed them as a sort of programming exercise... is that right?

I would guess your code stops working for the same reason Marcus guessed, because the editor window may not always have Script_05 open in it. Do you only care about logging changes made to just that particular macro? Or are you looking to log changes made to all macros?

If all macros, does each macro get its own separate change log file or are you dropping everything into one huge log file?

You said you wanted to actually write the changed lines to the logfile along with the line number if possible. What about deleted lines or brand new lines? How would you log those? How would your macro zero in on just the one line that changed and write only that line to the log file? And what part of it changed? Would you want to write both the OLD LINE and the NEW LINE one after the other into the logfile so you could see the before and after? It gets complex in a hurry.

Turning on backups takes care of all this automatically, saving a complete copy of a macro file every time you make (and save) a change. For any macro you've updated 3 times or more, you'll have the current version, say "macro.scp" and "macro.001", "macro.002" and "macro.003".

Let us know what you try next. Bob's idea is certainly interesting...
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

User avatar
Bob Hansen
Automation Wizard
Posts: 2475
Joined: Tue Sep 24, 2002 3:47 am
Location: Salem, New Hampshire, US
Contact:

Post by Bob Hansen » Wed Apr 25, 2007 2:45 am

In any case, whatever you do about this issue .......

..... even if you just want to experiment to learn the syntax and make something useful .... I find it very helpful to write out a skeleton of what I want to do in an outline form, referencing keystrokes and mouse movements, loops, etc. Then I go to each section and write the code for that. Test it, debug it, and move to the next section.

If you provide an outline of what you are trying to do, you can then write the code, test it, and submit it here for help. I think at this point you have jumped ahead, and written out the code, but not provided us a clear enough picture of what you are trying to do.
Hope this was helpful..................good luck,
Bob
A humble man and PROUD of it!

Aaron
Pro Scripter
Posts: 113
Joined: Mon Apr 09, 2007 1:35 am
Location: Wyoming

Thanks, I'm going with the backup on save

Post by Aaron » Wed Apr 25, 2007 5:38 am

Wow what a handful of questions to answer, I do appresiate the response.

First of all, let me thank you for helping out with the backup location. I did find them.

Let me start with jpuziano.


Q1. You seem to be trying to make a macro that will log the names of macro files you've changed and the dates you've changed them as a sort of programming exercise... is that right?

A1. Yes to learn, but also I would like to use this for saving files in other situation, not nessasaraly programing.
I also think that it would be easy to go back and see the code changed for quick referance.



Q2. Do you only care about logging changes made to just that particular macro?

A2. I was wanting to save as WorkingOnFile. Once the script works properly I would save the working script in my compleated script folder with a differant name, or as a snippet. I would then delete the file and start over with the next project as the WorkingOnFile. So the answer would be yes.



Q3. You said you wanted to actually write the changed lines to the logfile along with the line number if possible. What about deleted lines or brand new lines? How would you log those? How would your macro zero in on just the one line that changed and write only that line to the log file? And what part of it changed? Would you want to write both the OLD LINE and the NEW LINE one after the other into the logfile so you could see the before and after?

A3. Yes, It dose gets complex in a hurry.That is why I said if possible, I thought a little input would help.
I can see now that the line numbers would not help much because all the line numbers would change due to extra lines being added or deleted.

I think that turning on backups is the best solution since I cant realy save a line of code that has changed.


You said.

" I would guess your code stops working for the same reason Marcus guessed, because the editor window may not always have Script_05 open in it "




Aaron's Question

Are you saying that the WaitWindowOpen and WaitWindowClose will only work once in a script, even if you loop the script back so as to wait for the window to open again?


Thanks jpuziano.








Bob Hansen,

Thanks for your thoughts, Interesting

You said.

" I find it very helpful to write out a skeleton of what I want to do in an outline form, referencing keystrokes and mouse movements, loops, etc. Then I go to each section and write the code for that. Test it, debug it, and move to the next section.

If you provide an outline of what you are trying to do, you can then write the code, test it, and submit it here for help. I think at this point you have jumped ahead, and written out the code, but not provided us a clear enough picture of what you are trying to do "





Aaron's Response

The fist script I posted was the first step. I just have a problem with the WaitWindowClose.

If you read down to by second post, I gave a pretty good idea of what I was trying to do.

I always write sudo code first. But my interpretation of some of the funtions and how they work just dos'nt work always.

I appreciate the responses and have decided to go with the backup on save.


Thanks Bob
Aaron

User avatar
jpuziano
Automation Wizard
Posts: 1085
Joined: Sat Oct 30, 2004 12:00 am

Re: Thanks, I'm going with the backup on save

Post by jpuziano » Wed Apr 25, 2007 12:35 pm

Hi Aaron,
Aaron wrote:Aaron's Question

Are you saying that the WaitWindowOpen and WaitWindowClose will only work once in a script, even if you loop the script back so as to wait for the window to open again?
Nope, they should work multiple times in that case. If you want to troubleshoot, try the debugger but for a really quick way to know what's going on in the macro... just add some MDL> lines at the beginning like this:

Code: Select all

MDL>1) waiting for window "Editor - Script_05" to open
WaitWindowOpen>Editor - Script_05
MDL>2) window "Editor - Script_05" has opened - now waiting for it to close
WaitWindowClosed>Editor - Script_05 
MDL>3) window "Editor - Script_05" has closed - processing...
Then when your "change logger" macro is running, it will tell you where it is in the process and what it is waiting for.

I'm glad you're writing pseudo-code first then actual code later. Its worth the time to do that. I save mine as comment lines in the actual macro itself.

If you want a free tool to help you compare two versions of a macro to see what's different, try WinMerge at http://winmerge.org/

"WinMerge is an Open Source visual text file differencing and merging tool for Win32 platforms." Once you've installed it, you can fire up WinMerge against two versions of one of your macro scripts right from File Explorer like this:

- open File Explorer
- navigate to the directory where your macro files are
- hold the CTRL key down and click to select two files you want to compare, perhaps "macroname.scp" and "macroname.001"
- while still holding CTRL down, right-click on one of the selected file and the right-click-menu will appear
- you should have "WinMerge" as a menu choice, click on it... and WinMerge will fire up and let you visually compare the two files

Take care
jpuziano

Note: If anyone else on the planet would find the following useful...
[Open] PlayWav command that plays from embedded script data
...then please add your thoughts/support at the above post - :-)

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts