August 2, 2002   Tip of the Week Mailing List
The Tip

I hate nested if-then statements! So I rarely use them. How do I avoid them? I use "exit" to jump out of the calculation in instances where I know I am finished processing.

Say, for instance, you wanted to give feedback based on the number of times a user has attempted a question if it is wrong, but you always want to give the same feedback if it is right, and move on. The code might look like this:

If UserAnswer=RightAnswer then
Feedback := "Yay! You're right!"
exit
End if

If ~TimesMatched then
Feedback := "Sorry, try again"
exit
End if
Feedback := "The correct answer is "¬
^RightAnswer^"."
GoOn:= True

In this instance, you don't really save much by doing it this way, but when you have more complicated conditions, like "The password must have at least four letters and two numbers, the old password must be correct and the new password must match the retype of the new password," the code becomes much simpler and easier to read when you don't have to unpick six or eight levels of if-then statements.

In addition, I often find that my exiting condition would have been the "else." By reordering the statements this way, Authorware only has to read the one that applies, not check the if and then the else. This lets the code run a tiny bit faster, if you are concerned with such things.



 
Did you know?

I like to use System variables and functions where possible, rather than creating my own custom variables. Both the Functions and the Variables windows have a Category Drop-down list that makes it easier to figure out which variable to use.

For instance, what if you wanted to set a Decision to be Random to any path, but you wanted it to continue to repeat until all of the paths had been shown. How would you do this? Look at the variables in the "Decision" category, and see if you can figure it out.



 
Next Chat scheduled-Flash in Authorware

The next chat will be Saturday, August 10, at 10:00 am CDT. The subject will be Flash in Authorware. That is 6 hours later current UK time, 5 hours later Greenwich Mean Time. That's 11 am Eastern, 9 am Mountain, 8 am Pacific.

I am currently working to schedule guests.



 

Blog

Texas seems to have an extremely varied bug population. I must have seen at least 6 or 7 different species of grasshopper alone. I was surprised and delighted to find fireflies here, the first I'd seen since I was about 7 or 8 years old.

Less pleasant are the fire ants, which seem to invade my house about this time each year. Just when I think I have eradicated them, I find a new trail wending its way through somewhere inconvenient.

My favorites, though, have got to be the golden argiope spiders. I have to say, though, that mine are prettier than these (the little one is a boy). Rather than having those bee-like black markings, mine have deep orange markings. I had argiope egg sacs hanging off my fence through the winter, and several of the babies have hung around this year.


TAAC 7

If you haven't registered for TAAC (the Alternative Authorware Conference) yet, you should go ahead and do it. Some of the best speakers in the business will be there, including Joe Ganci, Jennie Thornton, Jamil Zainasheff, and Steve Howard will all be on hand.

This year it is much more affordable than last year, and TAAC has adopted the idea originated at TAW of scheduling time for attendees to meet one on one with their favorite gurus.

I hope to see you there!



  http://www.Authorware-Amy.com