Bluepoint Design

Practical cost effective solutions   
Macro Express Sample Macro: GoTo

Home
Up
Multiple Choice Trick
Multiple Multiple Choice
Occurrences
Repeat Validation
GoTo
First file
Fax PDF Breakup
Day of Year
Multiple Attachments
Multiple eMail Addresses
Text Padding
Building TSV Files

Page last updated: 11/21/2007

Often folks complain about ME’s lack of a ‘GoTo’ command but I have never seen it as a deficiency but rather that ME has a different mental construct for processing instructions. Indeed GoTo is often considered a crutch or sloppy means of accomplishing a task by many experts who think structured flow control should be used instead. This is supported by the fact that as long as I’ve been writing macros I’ve never found an instance where I couldn’t accomplish what I needed without such a command. But I was writing a macro recently that had a series of validation tests on a variable and in each test I wanted to record the reason why it failed. My problem was that the tests were of the type that later test relied on the passage of earlier tests and I thought it dumb to 1) do any more tests after a failure, and 2) wipe out my error result text. I had come up with a solution but it was less than elegant and it got me to wanting a GoTo. Then I realized we do have a sort of GoTo but it only works in a forward direction with limited application.

Here’s the trick: Insert a Repeat Start and set it to one iteration and then insert the Repeat End where you would like skip ahead to. Now whenever you would like to jump ahead, usually in one of many conditional statements, simply insert a Break. And you can really put the first Repeat Start just about anywhere since it's only going to repeat one time.

Another typical application of GoTos in validation is to test the user input and put them back to the prompt until they get it right. But here too one can use repeats to effect this end. The simplest example is a null input. Here we put a repeat in front of and after the input and use a conditional repeat. Just make the condition "Is not equal to null".

You can expand this to do other tests as well. Simply do something like Repeat Until T1 = "Good" and in your failure conditions set T1 to "Bad". Easy!

 

 
Practical cost effective solutions