A code style question

Richard Gaskin ambassador at fourthworld.com
Tue Jan 20 13:14:18 EST 2015


Thanks for the fix.  Once I took care of the email line wrap it ran 
well.  The first version is still slightly faster, and to my eye more 
readable, so I'd go with that.



on mouseUp
    put 1000 into tIterations
    --
    set the baseID of this stack to empty
    put the millisecs into t
    repeat tIterations
       put baseID1(1000) into r1
    end repeat
    put the millisecs - t into t1
    --
    set the baseID of this stack to empty
    put the millisecs into t
    repeat tIterations
       put baseID2(1000) into r2
    end repeat
    put the millisecs - t into t2
    --
    put t1 && t2 && (r1=r2) &cr& r1 && r2
end mouseUp

function baseID1 newID
    if newID is empty then
       if not exists (the baseID of this stack) then
          set the baseID of this stack to "this card"
       end if
    else
       if exists(newID) or \
             newID is among the items of "this card,card list,background 
list,stack list" then
          set the baseID of this stack to newID
       else
          set the baseID of this stack to "this card"
       end if
    end if
    return the baseID of this stack
end baseID1


function baseID2 newID
    if (newID is not empty and not exists(newID)) or \
          (newID is empty and not exists(the baseID of this stack)) then \
          set the baseID of this stack to "this card"
    if exists(newID) or \
          newID is among the items of "this card,card list,background 
list,stack list" then \
          set the baseID of this stack to newID
    return the baseID of this stack
end baseID2

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com




More information about the use-livecode mailing list