Main Page About Ldoc+ Error Lists Main Index Index Groups

Ldoc+ Lingo Group:
    DATA TYPES

 info D5/601:
      ilk(anyData) 
      Data Conversion & Validation
 6    3 elements new in Director 6.0,
  !   8 contain Dictionary fixes 601 & 501,
   + 24 miss from the 'Appendix' 6.0 for DATA TYPES.


Data Types (33):
  !+  abs()
   +  FALSE
      float()
      floatP()
  !+  floatPrecision
   +  ilk(anyData)
      integer()
      integerP()
   +  maxInteger
  !+  [ ] (list brackets)
  !+  [:] (list brackets)
      list()
   +  listP()
   +  media of member
   +  new(script)
      objectP()
   +  picture of member
   +  pictureP()
   +  " (quotation mark)
   +  EMPTY
   +  QUOTE
 6 +  SPACE
      string()
   +  stringP()
  !   # (symbol operator)
 6!   symbol()
  !+  symbolP()
   +  TRUE
   +  value()
 6!+  VOID
   +  voidP()
   +  window
   +  windowPresent()
      ...see also the OPERATORS Lingo Group,
      ...and also the Data Conversion & Validation table.

--

6.0 'Appendix' errors for DATA TYPES:
Many elements are missing, see (+) above.
The mentioned element 'object' is not a valid Lingo term,
but you can test 'if ilk(anyObject, #object)'.
Remember: Behavior instances, as well as lists, media,
pointers, points, rects, windows etc. are also objects!





[index] _ D5/601 _ 971203:


Data Conversion & Validation

Use the following functions and elements to convert and validate different data types (see index at top for links, see ilk() for more info):
Conversion:   -> Validation:      -> More exact:
anyData (x)      -> ilk(x)              -> (ilk(x) = #dataType)
abs()            -> ...                 -> (x > 0)
behaviors        -> objectP()           -> ilk(x, #instance)
EMPTY            -> stringP()           -> (x = ""), ilk(x, #string)
float()          -> floatP()            -> ilk(x, #float)
globals          -> ...                 -> voidP()
integer()        -> integerP()          -> ilk(x, #integer)
list()           -> listP(), objectP()  -> ilk(x, #linearList)
[ ]              -> listP(), objectP()  -> ilk(x, #linearList)
[:]              -> listP(), objectP()  -> ilk(x, #propList)
media of member  -> objectP()           -> (ilk(x) = #media)
member           -> ...                 -> (ilk(x) = #member)
new(script)      -> objectP()           -> ilk(x, #object), ilk(x,#instance)
parameters       -> paramCount()        -> voidP(param(i))
picture of mem.  -> objectP()           -> pictureP(), ilk(x, #picture)
properties       -> objectP()           -> NOT voidP(getaProp(x)), count()
point()          -> listP(), objectP()  -> ilk(x, #point)
rect()           -> listP(), objectP()  -> ilk(x, #rect)
sprites          -> ...                 -> (type of sprite <> 0)
string()         -> stringP()           -> ilk(x, #string)
symbol()         -> symbolP()           -> ilk(x, #symbol)
value("#" &"a")  -> symbolP()           -> ilk(x, #symbol)
value()          -> ...                 -> (x <> 0)
VOID             -> voidP()             -> ilk(x, #void)
window           -> objectP()           -> windowPresent(), ilk(x, #window)





[index] _ D5/601 _ 971201:


ilk()

data type validation function

5.0 Dictionary Error, cleared in 6.0:
The Dictionary states that the 'ilk()' function accepts the type #linearList for points and rects. But the type #linearList is only correct for pure LINEAR lists, NOT for points and rects; those evaluate TRUE only for the common type #list.

1. TIP: In 6.0, a copy (pointer) of a behavior is an 'instance' and tests true on 'ilk(behaviorOffspring) = #instance' and 'ilk(behaviorOffspring, #object)'.

2. TIP: The 'ilk()' function is Director's most powerful instrument for data evaluation and has 3 syntaxes: 'ilk(anyData)', 'ilk(anyData, #dataType) = TRUE', and 'ilk(anyData) = #dataType', with the third syntax providing the most accurate testing.

3. TIP: You can use 'ilk()' to test on many different data types, like: #instance, #integer, #media, #member, #object, #picture, #point, #rect, #string, #symbol, #void, #window, etc: 'if ilk(anyData) = #dataType', or 'if ilk(anyData, #dataType) = TRUE'. Some more types cannot be tested directly, but will be given as the result of 'ilk(anyData)' (see the table Data Conversion & Validation). Try it out in the Message window and have a nice personal talk with your Director about some facts of life... ;-)

--

EXAMPLEs:

put ilk( ["A","B"] )
-- #list
put ilk( ["A","B"], #list )
-- 1
put ilk( ["A","B"], #linearList )
-- 1

put ilk( [1:"A",2:"B"] )
-- #propList
put ilk( [1:"A",2:"B"], #propList )
-- 1
put ilk( [1:"A",2:"B"], #list )
-- 1
put ilk( [1:"A",2:"B"], #linearList )
-- 0

put ilk( point(1,2) )
-- #point
put ilk( point(1,2), #point )
-- 1
put ilk( point(1,2), #list )
-- 1
put ilk( point(1,2), #linearList )
-- 0

put ilk( rect(1,2,3,4) )
-- #rect
put ilk( rect(1,2,3,4), #rect )
-- 1
put ilk( rect(1,2,3,4), #list )
-- 1
put ilk( rect(1,2,3,4), #linearList )
-- 0


--> Now examine everything that can't run away quick enough:
--
set x = the number of member "myPict"
put ilk(x, #integer)
-- 1

set x = the picture of member "myPict"
put x
-- <Picture:1568d14>
put ilk(x)
-- #picture
put ilk(x, #picture)
-- 1
put ilk(x) = #picture
-- 1

set x = the media of member "myPict"
put x
-- (media 1568d78)
put ilk(x)
-- #media
put ilk(x, #media)
-- 0
put ilk(x) = #media
-- 1

set x = member "myPict"
put x
-- (member 3 of castLib 2)
put ilk(x)
-- #member
put ilk(x, #member)
-- 0
put ilk(x) = #member
-- 1

put ilk(the stage)
-- #window
put ilk(the stage, #window)
-- 0
put ilk(the stage) = #window
-- 1

put ilk(sound 1)
-- #sound
put ilk(sound 1, #sound)
-- 0
put ilk(sound 1) = #sound
-- 1

put ilk(sprite 121)  --> ;-)
-- #sprite
put ilk(sprite 121, #sprite)
-- 0
put ilk(sprite 121) = #sprite
-- 1





[index] _ D5/601 _ 971201:


objectP()

object validation function

6.0 Dictionary Error, same in 5.0
" ...indicates wether...is an object produced by a parent script, Xtra, or XObject. "
...should read:
" ...indicates wether...is an object, produced by a parent script, Xtra, or XObject, or is a behavior instance, a list, or a variable containing a pointer to some list, media, picture, or window etc. "

1. TIP: Besides using the 'objectP()' function to validate your own child objects or XObjects, you can use it on a lot of things which are objects in Director, like lists, media, pictures, points, rects, windows, etc. With the 'ilk(someObject, #object)' test, only some of these things will return TRUE, as its test is tighter.

2. TIP: When creating child objects, ALWAYS use 'objectP(goMyObject)' to check if the birthing of your object was succesful. Even when calling a handler from an object, first see if that object is ok: 'global goMyObject .. if objectP(goMyObject) then myHandler(goMyObject)'. Remember: In 6.0 you can use the new 'call()' and 'callAncestor()' commands for handlers in objects and scripts.

3. TIP: Testing 'objectP()' on a global child object will temporarily create a copy of the pointer to it, which will increase the 'offspring' number of the copy. Same as when putting a global child object into something.

4. TIP: 3.0 - 5.0: Testing 'objectP(goMyGlobalObject)' in a #score script ('on exitFrame' or 'on mouseDown' handlers) WITHOUT declaring that variable 'global' will return TRUE, and a call to one of that object's handlers from there will succeed. But to stay in style, better declare your global child object as 'global' whenever using it... ;-)

5. TIP: Handle with care: Copies (instances,ponters) of any kind of objects or script are neither equal nor different to each other. Testing 'objectCopy1 = objectCopy2' results in FALSE, but so does 'objectCopy1 <> objectCopy2', and 'NOT (objectCopy1 = objectCopy2)' results in TRUE, same as 'NOT (objectCopy1 <> objectCopy2)'.
But what you CAN do, is to test 'word 2 of string(goMyObject)', which contains the name of the object's parent script. If both objects contain the same parent script name in their object expression or varibale, then they are both children (offsprings) from the same parent code.

6. TIP: See the Ldoc+ entry on 'debug(myObj)' for an object debugging script.






[index] _ 601 in 1/97:


pictureP()

object validation

5.0 Dictionary Error:
The Dictionary's states: '...you must test whether a cast member has a picture by checking the cast member's picture of member property.'
Should read: You CANNOT test 'the picture of member' of a castMember that has no 'picture', because that produces an error alert.

WORKAROUND:
The 'rect of member' of castMembers without a 'picture of member' property is 'rect(0,0,0,0)'. You can test if a member has a 'picture' with 'if NOT (the rect of member x = rect(0,0,0,0) )'. Testing the 'rect of member' of an empty member slot AFTER the last castMember in a castLib produces an error alert. An empty member slot BEFORE the last member in a castLib might return a strange 'rect of member', like 'rect(373, -29664, 180, 22346)'. Well, at least happened to me... ;)


TIP: Equivalent to 'pictureP(x)' is 'ilk(x, #picture)'. You can also store 'the picture of member' into a variable, and then assign a castMember to it, but consider memory problems. See more tips at 'picture of member'.






[index] _ D5/601 _ 971212:


symbol()

6.0 symbol conversion function

6.0 Dictionary Errors:

"This function takes a string, stringValue, and returns a symbol."
= Not exact; should read:
"This function takes a one-word string starting with an alphabetical
 character (a - Z) as stringValue, and returns it converted to a symbol."

= Missing:
"See Also: symbolP(), # symbol operator (check out '#' in the docs!)"
 --

1. TIP: The new 6.0 function 'symbol(stringValue) turns a valid one-word string starting with an alphabetical character (a - Z; no numbers, no white space, QUOTE or RETURN; limited punctuation) into a symbol, same as: 'value("#" & "aWord") = #aWord'. See also the Dictionary's entry on '#' (symbol operator), because that's where it provides a decent explanation for symbols and their special conditions.

2. TIP: The 'symbol()' function returns 'Void' for an unsuccessful conversion! Best to test 'if symbolP( symbol(myString) )' of 'if voidP( symbol(myString) )'.

3. TIP: Remember: Integer or floating numbers like '999,09' CANNOT be turned into a symbol, and the 'symbol()' function returns 'Void' (= 0/FALSE) for such an invalid conversion.

--

EXAMPLEs:

Here are some return values from the new 6.0 'symbol()' function:
put symbol("Denis")
-- #Denis
put symbol(#Denis)
-- #Denis

put symbol("Denis Wieger")
-- #Denis
put symbol(Denis)
-- Void

put symbol(999-1000)
-- Void
put symbol(3)
-- Void
put symbol(3.2)
-- Void
put symbol("#" & "3.2")
-- ##
put symbol("#")
-- ##

put symbol([1])
-- Void
put symbol(["Denis":1])
-- Void
put symbol( getPropAt(["Denis":1], 1) )
-- #Denis


--> Now lets check the 'symbolP()' function:
--
put symbolP(#999)
-- 0
put symbolP("#" & "999")
-- 0
put symbolP( value("#" & "999") )
-- 0

put symbolP("Denis")
-- 0
put symbolP("#" & "Denis")
-- 0
put symbolP(#Denis)
-- 1
put symbolP( value("#" & "Denis") )
-- 1

put symbolP( [#Denis:1] )
-- 0
put symbolP( getPropAt([#Denis:1], 1) )
-- 1





[index] _ D5/601 _ 971212:


symbolP()

symbol validation function

6.0 Dictionary Errors, same in 5.0:

"This function determines whether...is a symbol."
= Not exact; should read:
"This function INDICATES whether...is a symbol."

"...checks wether #3 is a symbol:
    put symbolP(#3)"
= This is very STUPID and does NOT work, and misses:
"   put symbolP(#3)"
    -- 0"

...Symbols can only start with alphabetical characters (a - Z;
   no numbers, no white space, QUOTE or RETURN). Better example:
   set x = #oneWord
   put symbolP(x)
   -- 1

= Missing:
"See Also: symbol(), # symbol operator (check out '#' in the docs!)"
 --

1. TIP: Remember: Integer or floating numbers like '999' CANNOT be turned into a symbol, and 'symbolP(#999)' will return FALSE.

2. TIP: A good way to communicate with handlers and to trigger special conditions in a handler, is to submit symbols as parameters to them, like 'myHandler(#init)', or 'myHandler(#turnOn)'. Test 'if symbolP( param(x) )' to evaluate such parameters quicker.

3. TIP: See the above 'symbol()' for EXAMPLEs.






[index] _ D5/601 _ 971218:


VOID

6.0 data constant

6.0 Dictionary Errors:

"This constant is the value VOID."
= Not enough; should read:
"This constant is the value VOID, which equals 'no value',
 not yet initialized, nothing, absolutely empty.
 Something 'Void' is also FALSE (0)."

= Missing:
"See Also: voidP(), FALSE, clearGlobals"
 --

1. TIP: Use the 'voidP(myVariable)' to initialize variables if they haven't been set yet, or if an argument for a handler was NOT given: 'if voidP(thisThing) then set thisThing = 1', or 'if voidP(param(1)) then...'. In earlier versions, the result of testing something void would be '<void>'; this will now be 'Void'. A global or property variable not yet initialized is always 'Void'.

2. TIP: And: 'VOID = 0', 'VOID = FALSE', but 'VOID <> EMPTY', because EMPTY ("") is a Lingo string constant.





(Top)

URL = "http://www.a3w.de/Lingo/Ldoc_DataTypes.html"  (971212)

 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