Hiya, Kendall. I've used inline conditionals in Lingo since the early days.
In C, it looked like this: return (total == 0) ? 0 : score / total; In Lingo, you use lists, and it now looks like this: return [score / total, 0][(total = 0) + 1] Christopher Watson Sr. Software Engingeer Director/Shockwave Development Lightspan, Inc. Tel: 858.824.8457 Fax: 858.824.8008 -----Original Message----- From: kendall anderson [mailto:[EMAIL PROTECTED]] Sent: Friday, November 30, 2001 1:01 PM To: lingo-l digest Subject: <lingo-l> Inline conditionals in Lingo? Hey all - I seem to remember this topic from a long time ago but can't find anything in the archives (lingo-l or direct-l), and of course, not knowing the name of what I'm looking for doesn't help. :) What I remember was an 'if/then/else' approach which could be used in a single line of code, and I can't remember whether it was usable in lingo or only other ('real') languages. An example might be: For example: pretend we want to return a percentage, and we have a score and the total. If the total is 0, we want to avoid a divide by zero so we might do the following: return (total=0: 0) ? (a>0: score/total) ie: return the percentage if total is > 0, or just return 0 if total = 0. I realize this could be done with: if (total > 0) then dpercent = score/total else dpercent = 0 end if return dpercent I'm just looking for a more compact, more 'elegant' solution. I also understand this is really a minor point. :) Kendall [To remove yourself from this list, or to change to digest mode, go to http://www.penworks.com/lingo-l.cgi To post messages to the list, email [EMAIL PROTECTED] (Problems, email [EMAIL PROTECTED]) Lingo-L is for learning and helping with programming Lingo. Thanks!]
