That's not what
or does. It doesn't return one value or the other, it returns
true if one or the other given value
is truthy. Or rather, if
any of the given values is truthy, since you can have any amount of values to check if they're non-zero.
For comparison,
and is
true if
all its arguments are truthy.
You must be talking about this line in the OG LSL5 source:
((or subI mainI) nsLeft?). Considering you
must have a main text and
may end up with a multi-language subtitle,
mainI will always be a valid
non-zero pointer and
subI may be.
(or subI mainI) will return the pointer to either
DText object, and
that control's
nsLeft is then queried to pass on to
editI. If there
was a subtitle, it'll use the subtitle's
nsLeft. If there wasn't, the pointer will be zero, false-y, and the guaranteed main text is used instead. The same trick is then used to move
editI below the text (plus a bit) regardless of
subI's existence.
... wait, hold up. That explanation doesn't track with observation.
*checks the relevant original Sierra docs*.
(or e1 e2 [e3...])
Evaluates to TRUE if any of the expressions are non-zero, else FALSE.
I must've misunderstood what
Print does there.
Edit: came back to do some more in-person testing. The manual is right.
;; Sanity checks.
(= theOne 42)
(= theOther 420)
(Printf "theOne = %d\ntheOther = %d" theOne theOther)
(Printf "one OR the other = %d" (or theOne theOther))
;; ^- should be TRUE
(= theOne 0)
(= theOther 420)
(Printf "theOne = %d\ntheOther = %d" theOne theOther)
(Printf "one OR the other = %d" (or theOne theOther))
;; ^- should be TRUE
(= theOne 42)
(= theOther 0)
(Printf "theOne = %d\ntheOther = %d" theOne theOther)
(Printf "one OR the other = %d" (or theOne theOther))
;; ^- should be TRUE
(= theOne 0)
(= theOther 0)
(Printf "theOne = %d\ntheOther = %d" theOne theOther)
(Printf "one OR the other = %d" (or theOne theOther))
;; ^- should be FALSE
(= theOne (DCIcon new:))
(theOne nsLeft: 100)
(= theOther 0)
(Printf "theOne = %d\ntheOther = %d" theOne theOther)
(Printf "one OR the other = %d" (or theOne theOther))
;; ^- should be TRUE
;; v-- Does not compile, "nsLeft is not a property or method on type 'bool'."
;;; (Printf "one OR the other's nsLeft = %d" ((or theOne theOther) nsLeft?))
(Printf "IF one ELSE the other's nsLeft = %d" ((if theOne else theOther) nsLeft?))
;; ^- should be 100
;; v-- Also does not compile, same reason. This is adapted straight from SCI10's Interface.
;;; (theOne
;;; moveTo:
;;; ((or theOne theOther) nsLeft?)
;;; ((or theOne theOther) nsBottom?)
;;; )
(theOne
moveTo:
((if theOne else theOther) nsLeft?)
((if theOne else theOther) nsBottom?)
)
; This tracks with the documentation: OR returns TRUE or FALSE, not the first valid pointer.I
would say that maybe Sierra's compiler handled things Differently?, but both the '88 and '94 manuals agree that what SCI 1.0 does here
should not work.