terrypin Posted August 21, 2016 Report Share Posted August 21, 2016 Any IrfanView users here? Or regular users of the On Error/Catch Error commands? (I don't use them as often as I should.) If so, can you see why this doesn't work when applied to a JPG with no EXIF data please? The macro opens the Image Properties window with the'i' keystroke, but then even though no EXIF window appears as a result of the 'e' keystroke, it ignores my On Error stuff and sails on beyond it. What should happen is that a message should be displayed and the macro stopped. // Assumes JPG is open in IrfanViewText Type (Simulate Keystrokes): ie // Opens EXIF Info window.Delay: 0.3 secondsWait for Window Title: - EXIF Info// The On Error tab for the last command was set to 'The condition was not met within the specified amount of time'.On Error Catch Error: The condition was not met within the specified amount of time Text Box Display: Error message Macro Stop End Catch ErrorEnd ErrorThen other commands, intended for JPGs which do have EXIF <COMMENT Value="Assumes JPG is open in IrfanView"/> <TEXT TYPE Action="0" Text="ie" _COMMENT="Opens EXIF Info window."/> <DELAY Flags="\x01" Time="0.3"/> <WAIT FOR WINDOW TITLE Title="- EXIF Info" Partial="TRUE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="2" _HANDLE="0x0014"/> <COMMENT Value="The On Error tab for the last command was set to 'The condition was not met within the specified amount of time'."/> <ON ERROR/> <CATCH ERROR Code="20"/> <TEXT BOX DISPLAY Title="Error message" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 No EXIF\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO STOP/> <END CATCH ERROR/> <END ERROR/> I tried it with Activate Window as well, but same puzzling failure. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Cory Posted August 22, 2016 Report Share Posted August 22, 2016 That's a good question. I use IrfanView a lot and I recreated your example and I don't get a message box. Seems like it should. I can't think of any way to help you on this one. I I try to avoid try/catch in all forms of programming. It's sloppy and a bad practice to rely on error handling as a logical element in your application or macro. It's much better to test something first. In this case I'd open the 'info' window as you have but I'd look to see if the button control exits in the form. Quote Link to comment Share on other sites More sharing options...
terrypin Posted August 22, 2016 Author Report Share Posted August 22, 2016 Thanks Cory. I'll pursue your suggestion. The On Error commands do appear rather unreliable. BTW, whenever I do use them I'm always surprised that the list of conditions is not alphabetically arranged, so you have to search visually for the matching one. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
acantor Posted August 26, 2016 Report Share Posted August 26, 2016 Report it as a bug. About a year ago I discovered an error condition that Macro Express Pro was not catching. I reported the problem to the good people at Insight, and it was fixed in the most recent release. It even made the list of "bugs fixed" in the most recent release notes! Added 'There is no control to capture' to the list of errors for the 'Capture Control' command. I have had mixed experiences with error trapping. Given enough time, I can make a complex MEP script that will work as expected about 99% of the time. Although I use error trapping on occasion to bail when something goes awry, I tend to look for other ways to force a script to exit gracefully, or go back and repeat a step that was not completed. Quote Link to comment Share on other sites More sharing options...
Cory Posted August 26, 2016 Report Share Posted August 26, 2016 As I've studied more programming I've found several references about error handing and it's pretty much a consensus. If you can conceive of a failure then there's a reasonable chance it could occur and you should test for it first. For instance files: Instead of having a "Try" block to read the contents it's better to test "If file exists" first. you still want a try block but only in the case of some other unanticipated problem. Quote Link to comment Share on other sites More sharing options...
Look_Up Posted September 22, 2016 Report Share Posted September 22, 2016 It's really simple to solve when you know where the bug is hiding. Put your commentary from line 5 to line 4 and your waiting for window title from line 4 to line 5. Eh wola - it works. <COMMENT Value="Assumes JPG is open in IrfanView"/> <TEXT TYPE Action="0" Text="ie" _COMMENT="Opens EXIF Info window."/> <DELAY Flags="\x01" Time="0.3"/> <COMMENT Value="The On Error tab for the last command was set to 'The condition was not met within the specified amount of time'."/> <WAIT FOR WINDOW TITLE Title="- EXIF Info" Partial="TRUE" Wildcards="FALSE" Indefinite="FALSE" Hours="0" Minutes="0" Seconds="2" _HANDLE="0x0014"/> <ON ERROR/> <CATCH ERROR Code="20"/> <TEXT BOX DISPLAY Title="Error message" Content="{\\rtf1\\ansi\\ansicpg1252\\deff0\\deflang2057{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n\\viewkind4\\uc1\\pard\\f0\\fs16 No EXIF\\f1 \r\n\\par }\r\n" Left="Center" Top="Center" Width="278" Height="200" Monitor="0" OnTop="TRUE" Keep_Focus="TRUE" Mode="\x00" Delay="0"/> <MACRO STOP/> <END CATCH ERROR/> <END ERROR/> The command and the Error handler MUST BE among themselves. No commentary or other code should between this. Look_Up Quote Link to comment Share on other sites More sharing options...
terrypin Posted September 22, 2016 Author Report Share Posted September 22, 2016 Nice catch, Look_Up, thanks! That's a surprise to me. I've always assumed that Comments are ignored by MX Pro when processing commands. But clearly not in this case. Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.