Yehnfikm8Gq Posted January 28, 2010 Report Share Posted January 28, 2010 I have a bizarre problem with a Repeat not repeating. It was a simple macro set to repeat 100 times. It runs Variable Set String, Prompt for Filename. After messing around and removing all the commands the problem seems to be that any Variable Modify String command that follows causes the repeat to fail. Below is the shortened macro. If the Variable Modify string is enabled the commands run once. If disabled it repeats. Repeats in other macros run normally. Reproducible by others? Repeat Until %T[99]% Equals "Never" Variable Set String %T[1]%: Prompt for a filename Variable Modify String: Replace "\" in %T[1]% with "/" End Repeat <REPEAT UNTIL Variable="%T[99]%" Condition="\x00" Value="Never"/> <VARIABLE SET STRING Option="\x08" Destination="%T[1]%" Value="Choose Folder"/> <VARIABLE MODIFY STRING Option="\x0F" Destination="%T[1]%" ToReplace="\\" ReplaceWith="/" All="TRUE" IgnoreCase="TRUE"/> <END REPEAT/> Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 29, 2010 Author Report Share Posted January 29, 2010 There is definitely an ME Pro issue in here. I'll report it as a bug. I've managed to get the full loop of 20 commands working. Immediately after the Variable Set String, Prompt for Filename, I copied T1 to T11 and used T11 throughout the macro. Having spent many (valuable) hours sorting out Variable problems and seeing the same things in other users (eg Rustywinger today), I have to question the whole issue of variables. There seems to be something fundamentally wrong in the way they are working in ME Pro. That manifests in several areas: The actual setting dialogs where the "Undefined variable or variable of the wrong type" appears when you are sure you entered a variable the same way you did for the last month. Use of variables like my problem in this thread and "variables containing variables" which have appeared several times in this forum. Variable problems where you end up with exactly the same code as you started with but now it works. Almost forgot, the old style variables such as %C[1]% are more robust than variables like %controlname% Quote Link to comment Share on other sites More sharing options...
terrypin Posted January 29, 2010 Report Share Posted January 29, 2010 I agree with you about the apparent flakiness of working with variables. My confidence has been eroded by my own experience and reports from others. The snag is that they're so darned inconsistent, so I have sympathy with ISS over isolating the issues. Nevertheless, a major overhaul looks badly needed IMO. On your specific issue, maybe I've misunderstood. The character '\' is disallowed by Windows in a filename, so it seems an odd choice for your test? If I replace that command with say Variable Modify String: Replace "a" in %T[1]% with "xx" then the Repeat continues correctly until I Cancel. -- Terry, East Grinstead, UK Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted January 29, 2010 Author Report Share Posted January 29, 2010 The commands are changing a filename to a URL. The same problem occurred with changing : to | . It's always puzzled me why people have their home page somewhere on the WWW but that's another story. What seems odd is that it's not an incorrect computation (that operated fine), it is stopping the Repeat. I also tried the Repeat set to 100 times. Thanks for checking it out. Once one starts to lose confidence you end up wasting time troubleshooting because you're not sure if it's the same stuff all over again. In normal programming it's fun trying to figure out what's wrong but if after an hour you find what you originally had now works, fun is not applicable. You've learned nothing. Quote Link to comment Share on other sites More sharing options...
chris Posted February 1, 2010 Report Share Posted February 1, 2010 I've located the issue in this particular instance. It appears that the repeat loop is repeating, but it's being canceled the second time through by the dialog. Here's what's happening: The first time through, the browse dialog pops up and requests a filename. You then take that filename and convert all of the '\' characters to '/'. This part is fine. However, the second time the loop executes, the '/' characters in the path cause the dialog to fail (this is a failing on the part of Windows as this is dialog is not our creation). The reason why the '/' characters are causing it to fail is because we allow setting a default value for the filename prompt by initializing the destination variable to a filename. So, if you were to set %T[1]% in this situation to "C:\My Documents\Some File.txt", then the prompt would be set to the My Documents directory with "Some File.txt" in the filename field. So, one way to fix it would be to set a default value at the beginning of the loop, either by clearing the variable or by setting it to point to a folder and file that you want as the default. I admit that this isn't documented in the help file (and we'll get right on that), but it's behavior that was carried over from Macro Express 3. The other alternative is that we check the variable for correct information before using it as the default value (there isn't a way to force the dialog to not cancel when bad data is entered as it's built into the Windows operating system). We'll investigate this solution as well. Quote Link to comment Share on other sites More sharing options...
Cory Posted February 1, 2010 Report Share Posted February 1, 2010 Good catch Chris! I knew it had to be something like that. Quote Link to comment Share on other sites More sharing options...
chris Posted February 1, 2010 Report Share Posted February 1, 2010 Thankfully it turned out to be something simple. Also, I've already implemented the fix so that if an invalid character (such as a '/' character) is used in the destination variable, then the variable will not be used to set the default for the dialog. This will be available in the next release. Quote Link to comment Share on other sites More sharing options...
Yehnfikm8Gq Posted February 1, 2010 Author Report Share Posted February 1, 2010 I'd also found that setting the variable before the Repeat cured the problem and passed it on to ISS. I didn't try to analyze the issue; that's what the guys there get the big bucks for! 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.