From the beginning I have been hearing that I should be using ThrowFocus() instead of GOTO. It has been explained that GOTO was provided as a carryover from Q&A for consistency.
But I recently found that I need to change my thought process and not always use ThrowFocus() instead of GOTO. There is a big distinction between the two. And I believe that GOTO has its place and purpose.
GOTO will change focus and programming control
instantly from that line in the programming code.
ThrowFocus() does not do that.
ThrowFocus() allows the rest of the programming to continue and does not change focus and programming control
until the rest of the programming codes has been executed.
This distinction is critical. I had some code with ThrowFocus() but had unexpected results for me. That is because I was expecting program control to change at that part of the code, but instead it continued with the following lines. That is not what I expected.
This difference can be seen like this:
Make text elements named LE1 and LE2 and LE3
Make a text element named LE3.
Put the following code in LE1, On Element Exit.
LE2 += "Line 1" + " - "
//ThrowFocus(LE3)
GOTO LastName
LE2 += "Line 2" + " - "
LE2 += "Line 3" + " - "
Move the cursor to LE1, and press TAB to exit the element.
This will result in LE2 will say Line 1 and focus will go to LE3.
Now comment out GOTO line and remove comments // from the ThrowFocus line, and repeat exit from LE1.
This will result in LE2 will say lines 1,2,3 and focus will go to LE3. Totally different results.
The Programmers Guide manual is very clear in explaining the difference.
Quote:Moves to layout element when current program has finished.
But I had been listening to instructions here on the forum vs. RTFM, accepting the recommendations blindly, with faith. But the forum recommendations made it sound like they were interchangeable.
Two lessons learned:
1. ThrowFocus() is not a replacement for GOTO. They both have their purpose and behave differently.
2. No matter who provides recommendatioins on the forum, we should go back to the manuals and read the content for full clarification.