Main Page About Ldoc+ Error Lists Main Index Index Groups

Ldoc+ Lingo Groups:
    OPERATORS / MATHEMATICS

 info D5/601:
      # (symbol operator)
 6    0 elements new in Director 6.0,
  !   8 contain Dictionary fixes 601 & 501,
   +  5 miss from the 'Appendix' 6.0 for OPERATORS,
   +  NO 'Appendix' in 6.0 for MATHEMATICS, but Online-Help!


Operators (24):
  !   #   (symbol operator)
      -   (minus sign and subtraction)
      --  (comment delimiter)
      &   (concatenator)
      &&  (concatenator)
      ( ) (parentheses)
      *   (multiplication)
      +   (addition)
      /   (division)
      <   (less than)
      <=  (less than or equal to)
      <>  (not equal)
      =   (equal sign)
      >   (greater than)
      >=  (greater than or equal to)
  !   [ ] (linearList brackets)
  !+  [:] (propList brackets)
      "   (string constant)
      ¬   (continuation symbol)
      @   (pathName operator)
   +  and (both TRUE)
   +  or  (one TRUE)
   +  not (negate to FALSE)
   +  mod (modulus operator)
      ...see also the DATA TYPES Lingo Group.

Mathematical Functions (22):
  !   abs()
  !   float()
      floatP()
  !   floatPrecision
      integer()
      integerP()
      maxInteger
      value()
      mod... (modulus operator)
      exp()
      log()
  !   power()
      sqrt()
      max()
      min()
      atan()
      cos()
      pi()
      sin()
      tan()
      random()
  !   randomSeed





[index] _ D5/601 _ 971210:


#

Lingo's symbol operator

6.0 Dictionary Errors, same in 5.0:

"Symbols are case-sensitive."
= Should read:
"Symbols are NOT case-sensitive."
...'(#lingo=#LINGO) = TRUE'!

"...and names of parameters passed to global variables..."
= Should read:
"...and names of parameters passed to global HANDLERS..."

= Missing:
"See Also: ...new symbol() function"
 --

NEW for Director 3.0 - 601:
  In Windows 3.1, you CANNOT use more than about 5,000
  different variables, handlers, parameters, and symbols
  in a project (because of the 64K memory segmentation).
  Remember: Scripts and fields CANNOT hold more than 32K text!
  --

1. TIP: A symbol can only be a single word, which has to start with an alphabetical character (a - Z; no numbers, no white space, QUOTE or RETURN; limited punctuation), as opposed to normal strings, which can contain any valid character. Symbols are a quality of their own, they actually seem to be NOT case-sensitive at all, not even in a sorted linear or property list. In 6.0, use 'symbol()' to convert a single word string into a symbol. In 5.0, use 'value("#" & "aWord")'. Use 'symbolP(someExpression)' to test if what you get or create is really a symbol. With these commands you can create new entries into a property list on-the-fly from fields, or from other string words like castMember names. See 'Color Values PropList', where an EXAMPLE uses symbols as names in a property list of screen color values.

2. TIP: Use the conversion function 'string(aSymbol)' to turn a symbol into a normal string word.

3. TIP: It's convenient to use symbols as name tags for entries in property lists (but using strings works as fast in memory, and you can use quite a variety of other values too).

4. TIP: Director stores all 'property' variables of your scripts and child objects as symbols, which you can access by using some property list commands like 'count(object)' or 'count(script memberNameOrNumber)'. This is also true for 5.0, see EXAMPLE at 'debug(myObj)'. In 6.0, you can address handlers in scripts by using the symbol operator in front of their name: 'sendAllSprites(#aHandlerName)', 'call(#aHandlerName, script nameOrNumber)'.

--

EXAMPLEs:

put #lingo = #LINGO
-- 1
put [#lingo] = [#LINGO]
-- 1

--> ...but also strings tests TRUE on this:
--
put "lingo" = "LINGO"
-- 1
put ["lingo"] = ["LINGO"]
-- 1

--> Lets see HOW case-sensitive symbols are:
--
set x = list(#linGO, #LINgo)

-- 5.0:
put x
-- [#lingo, #lingo]

-- At a different time in 5.0:
put x
-- [#Lingo, #Lingo]

-- 6.0:
put x
-- [#linGO, #linGO]

set x = value("#" & "Lingo Doc+")
put x
-- #Lingo

set x = symbol("Lingo Doc+")
put x
-- #linGO

set x = value("#" && "   LDoc")
put x
-- #LDoc
put ilk(x)
-- #symbol
put symbolP(x)
-- 1
put value(x)
-- #Ldoc
put string(x)
-- "Ldoc"
put x + 0
-- 1011

set x = [:]
addProp(x, #Name1, "Denis")
put x
-- [#Name1: "Denis"]
put the Name1 of x
-- "Denis"

put ilk(x)
-- #propList
put getPropAt(x,1)
-- #Name1
put ilk( getPropAt(x,1) )
-- #symbol
put symbolP( getPropAt(x,1) )
-- 1

put value("#" & "99")
-- 99
put symbol("#" & "99")
-- ##
put symbolP(#99)
-- 0

-->  ...do NOT mess around with the following (<g>):
--
put symbol(#!)
-- #!
put symbolP(#!)
-- 1
put (ilk(value("#" & "_1_2.3ä4Ä5ß_only"), #symbol) = 1)
-- 1





[index] _ D5/601 _ 971201:


--

Lingo's comments delimiter

TIP: Use a special combination of the comment delimiter '--' with another 2 characters to classify certain lines in your code for your personal debugging, example: '--?>'. Later you can go and look for those char combinations (your signatures) all over your code, and examine and turn on or off special command lines. Remember: If you want to keep some Lingo commands disabled (as comments), do NOT use the 'uncomment' command from Director's Script Toolbar!


EXAMPLEs:

The following lines give an example of a part of my code which I will have to go back to (hopefully soon), and I will go through all of my code searching for my special 'signatures', and then remove the front comment to activate the line:
set myDirectors = [2.0,2.1,3.0,3.1,4.0,4.04,5.0,5.01,6.0,6.01]
--
--?> if (gMyUpdate) then add(myDirectors, 7.0)





[index] _ D5/601 _ 971201:


( )

Lingo's parentheses

1. TIP: See the 6.0 Dictionary on page 4 (parenthesis) for important info!

2. TIP: It's a good habit to use parentheses to separate evaluations, and to separate parameters from the handler name when calling it. You should enclose arguments to FUNCTIONS with parentheses, like when calling the 'random()' function. And you should even call your own handler names with trailing parentheses, even if no argument is passed in, like in: 'myHandler()', just to make your code easier to read. Handlers that have the command 'return someValue' in them (to return a value to the calling handler), NEED to be called with trailing parentheses; they are like Lingo functions that return something to you, i.e. the 'random(5)' function that returns an integer number between 1 and 5.


EXAMPLEs:

set myAge = 43 + random(3)

if (myAge = 44) then
  --
  jackpotHandler(16700000, "DeutschMarks")
  --
  enjoyLifeHandler()
  --
else doubleHopeHandler(#waitOneMoreYear)





[index] _ D5/601 _ 971201:


abs()

math conversion function

6.0 Dictionary Errors, same in 5.0:

"This statement calculates the absolute value of the Message window:..."
= Example 1 should read:
"This statement PUTS the absolute value INTO the Message window:..."
...Would you have known the Message window's own value? ;-)

"put abs(-2.2)"
= Example 1 should read:
"put abs(-2.2)
 -- 2.2"
...to indicate the conversion of a negative into a positive number.

"...set the foreColor of sprite 6 to 95"
= Example 2 should avoid using a shape sprite color example
  which only works reliably in 8-bit color depth!

= Missing:
"See Also: integer(), integerP()"
 --

EXAMPLEs:

put abs(42 - 128)
-- 86

put (0 < abs(the mouseH - 1600) )
-- 1

put abs(the Message window)
"Script error: Property not found"

put abs(Message window)
"Script error: One parameter expected"   ;-)





[index] _ 601 in 1/97:


floatPrecision

system math property

TIP:

When using floating point math on Windows, setting 'the floatPrecision' to a higher value than 6 can result in wrong display (mentioned in the docs) AND wrong calculation. John Dowdell from Macromedia Tech Support puts it like this: 'Floats aren't precise, and you can expect a bit of rounding ... add a small fudge factor to float calcs'. This 'fudge factor' needs to be smaller than the set 'floatPrecision', like 0.0000000000000000001 (the maximum digits for 'the floatPrecision' is 19). Best to set a global variable to such a tiny value and add it to all floating point calculations to ensure exact results and display.






[index] _ D5/601 _ 971210:


power()

math exponent funtion

6.0 Dictionary Error, same in 5.0:

"set vResult = power(4,3)"
= Example 1 should read:
"set vResult = power(4,3)
 put vResult
 -- 64.0000"

...in 5.0: 'vResult = 64.0'!

= Missing:
"See Also: exp(), log(), sqrt(),
 float(), floatP(), the floatPrecision"
 --

TIP: In 5.0, the 'power()' function ALWAYS returns a floating point number with either one or two decimal place(s), regardless of the setting of 'the floatPrecision''. In 6.0, the result does depend on the setting of 'the floatPrecision'. BTW: The expression 'power(4,3)' means 4 * 4 * 4.

--

EXAMPLEs:

--> This first part is in Director 5.0:

put the floatprecision
-- 4
put power(4,3)
-- 64.0

set the floatprecision = 0
put power(4,3)
-- 64.00


--> The following part is in Director 6.0:

put the floatprecision
-- 4
put power(4,3)
-- 64.0000

set the floatprecision = 0
put power(4,3)
-- 64





[index] _ D5/601 _ 971210:


randomSeed

movie system property

6.0 Dictionary Errors, same in 5.0:

"This property specifies seed for generating random numbers."
= Should read:
"This property specifies THE seed for generating random numbers,
 which is different on every start-up during authoring or run-time."

"put the randomSeed"
= The Example misses an exemplary output:
"put the randomSeed
 -- 1330369246"

= Missing:
"See Also: random(), the maxInteger"
 --

1. TIP: Director changes its 'randomSeed' property with every new start of the program or projector; sometimes it's even a negative value up to -2147483647. But the 'random()' function CANNOT create a positive random value out of a negative number: 'put random(-10) .. -- 157155892'.

2. TIP: If you use the 'random()' function in your movie, and you want it to reproduce exactly the same numbers everytime the movie runs, then set 'the randomSeed' to a definite integer number in your 'on startMovie' handler, for instance to 'the maxInteger'.

3. TIP: 5.0: There have been reports on the 'random()' function acting different on different platforms, and this might apply to 'the randomSeed' and 'the maxInteger' as well...(??)

--

EXAMPLEs:

put the randomSeed
-- 1365811890

set the randomSeed = the maxInteger
put the randomSeed
-- 2147483647





(Top)

URL = "http://www.a3w.de/Lingo/Ldoc_Operators.html"  (971210)

 Top [Main Page] [About...] [Error Lists] [Ldoc+ Index] [Lingo Groups]
The Ldoc+ © Copyright 97-98 by Denis Wieger Online since June 1, 1997. All rights reserved.
<mailto:Denis@a3w.de
 Top