Main Page About Ldoc+ Error Lists Main Index Index Groups

Ldoc+ Lingo Group:
    STRINGs

 info D5/601:
      string()
 6    3 elements new in Director 6.0,
  !   4 contain Dictionary fixes 601 & 501,
   + 30 miss from the 'Appendix' 6.0 for STRINGS.


String Keywords and Symbols (8):
      &
      &&
   +  "  (Lingo quotation mark)
      EMPTY
      itemDelimiter
   +  QUOTE
   +  RETURN
 6 +  SPACE

String Editing (19):
  !   char...of
      delete...
x6!+  field (outdated -> member)
  !   item...of
      itemDelimiter
      last char in...
      last item in...
      last line in...
      last word in...
      line...of
   +  number of chars in...
      number of items in...
      number of lines in...
   +  number of words in...
   +  put...after
   +  put...before
   +  put...into
   +  text of member
      word...of
      ...Remember: Editing (chunks of) #field members needs saving!

String Funktions (12):
   +  alert()
      chars()
   +  charToNum()
      contains...
   +  do (stringExpression)
      length()
   +  numToChar()
   +  offset(string)
   +  starts...
      string()
      stringP()
   +  value()

More String Things (12):
   +  scriptText of member  (authoring <> runtime)
  !+  frameLabel
   +  labelList
 6 +  runMode  (test only)
   +  version  (settable)
   +  name of castLib
   +  name of member
   +  name of menu
   +  name of menuItem...of menu
   +  name of the stage
   +  name of window
   +  name of Xtra





[index] _ 601 in 1/97:


"

Lingo's quotation mark

1. TIP: Two quotation marks ("") make up an EMPTY string, which is something you can test: 'set the propertyName = EMPTY', and 'put EMPTY into someVariable'.

2. TIP: Use the keyword QUOTE to produce a quotation mark inside a string.

3. TIP: Peter Small mentions on page 378 of his "Lingo Sorcery" book:
" In Director 5.0 a backlash character (\) can be used in front of the quotation marks to make them literal parts of the text. "
I find this does NOT work (5.01 on Mac).

--

EXAMPLEs:

The keyword EMPTY and the empty string "" are equivalent:
put EMPTY
-- ""
put (EMPTY = "")
-- 1
put (EMPTY <> "")
-- 0

--> Both expressions are strings:
--
put stringP("")
-- 1
put NOT stringP(EMPTY)
-- 0

--> Both expressions are NOT '<Void>':
--
put voidP(EMPTY)
-- 0
put NOT voidP("")
-- 1

put QUOTE
-- """
put charToNum(QUOTE)
-- 34
put (QUOTE = EMPTY)
-- 0

put (QUOTE & "This appears between doubled quotes!" & QUOTE)
-- ""This appears between doubled quotes!""





[index] _ D5/601 _ 971218:


contains

string testing operator

TIP: The 'contains' operator (low precedence level of 1) is very useful when working with strings, and it can easily serve as a filter: 'if (the movieName contains ".DIR")...', 'if (field "MyField" contains "Denis")...', 'if ("1234567890" contains the key)...'.

--

EXAMPLEs:

set digits = "1234567890"
--
put (digits contains "1")
-- 1
put (digits contains "2" = 1)
-- 1
put NOT (digits contains ".")
-- 1

--> The following will strip an extension from a movie name:
--
set myMovie = (the pathName & the movieName)
--
if (myMovie contains ".") then
  set StopChar = offset(".", myMovie)
  set  myMovie = char 1 to (StopChar-1) of myMovie
end if





[index] _ 601 in 1/97:


EMPTY

string keyword

5.0 Dictionary Error:
The Dictionary gives examples that erase all text in a field by putting EMPTY ("") into it, but that is NOT recommended, because the field will lose all its font formattings, like typeface, style and size.
Should read: Put a white SPACE (" ") into a field that you want to empty, because then it will keep the formattings from the first char (and line) of that field.


TIP: According to Gretchen's 501 BugList, on Macintosh 'EMPTY <> 0', on Windows 'EMPTY = 0'.


EXAMPLEs:

put char 1 of EMPTY
-- ""
put item 1 of EMPTY
-- ""
put line 1 of EMPTY
-- ""
put word 1 of EMPTY
-- ""
--
--> On a Macintosh:
--
put (EMPTY = "")
-- 1
put (EMPTY = 0)
-- 0
put NOT (""=0)
-- 1





[index] _ 601 in 1/97:


offset(string)

string conversion function

5.0 Dictionary Error:
Small typo in the Dictionary: 'This function gives the first place that THE first character...occurs...' ;)






[index] _ 601 in 1/97:


string()

string conversion function

5.0 Dictionary Errors:
a) The Dictionary's example forgets to show the result of 'put string(2+2)' as '-- "4" '.
b) The Dictionary's example: 'This statement converts the symbol #red to a string: put string(123) -- "123" '
Should read: That's a different example. It should read: 'put string(#red) -- "red" '.


1. TIP: You can use the conversion function 'string()' to turn any kind of object into a normal string expression and then check its contents: 'string(myChildObject)', 'string(myMIAW)', etc.

2. TIP: You can check if a member ID contains a certain castLib number: 'if (string(member 122) contains "castLib 13")'.


EXAMPLEs:

put string(#Ldoc)
-- "Ldoc"

put member 122
-- (member 122 of castLib 1)
put string(member 122)
-- "(member 122 of castLib 1)"
put "This member is from castLib " & word 5 of string(member 122)
--"This member is from castLib 1"

set x = window "Ldoc_Test"
put x
-- (window "Ldoc_Test")
put string(x)
-- "(window "Ldoc_Test")"

put gObject
-- <offspring "myParentScript" 3 248ad0>
--
set x = string(gObject)
put x
-- "<offspring "myParentScript" 4 248ad0>"

--> The number of instances from the parent script is:
--
put word 3 of x
-- "4"

--> The object's location in memory is:
--
put word 4 of x
-- "248ad0"

put (word 2 of x = "myParentScript")
-- 1





[index] _ 601 in 1/97:


value()

string conversion function

NEW for Director 6.0:
" put value("Penny") .. -- VOID "
... The new result (in 'the return') of this function uses the new 6.0 constant 'VOID', which equals no value, absolutely empty, nothing, not yet initialized. To test for it, you can use: 'if voidP("Penny")'. In earlier versions, sometimes the result of testing would be '<void>'; this should now be 'Void' in all cases.

From the '601 ReadMe':
Using 'set myList = value(myString)' no longer fails when 'myString' is bigger than 32K.


1. TIP: Like the 'duplicate(list)' function, you can use the 'value()' function to make true copies of list variables: 'set myNewList = value(string(myOldList))'. If you just set a new variable to an existing list variable of yours using 'set myNewList = myOldList', it will NOT be a true copy, but only a pointer to the original list, and any changes to your new variable will actually change the original list.

2. TIP: If you store a string version of a linear or property list in a field member ('put myList info field "MyField" '), and then want to turn the field's content back into a list variable (e.g. when your movie starts up), use 'set myList = value(the text of field "MyField")'. In this case, the version of the list in the field will already include the Lingo list brackets '[ ]'. If the backets are not yet part of the field content, use: 'set myList = list(the text of field "MyField")'.

3. TIP: To retrieve the true values of all kind of objects (like child objects, lists, MIAW's, the stage, Xtras, Xobjects, etc), and also to make true copies, use the 'value()' function: 'set x = value(string(aList))', 'add(the windowList, value(the stage))'.

4. TIP: To change a string word into a symbol, you can use 'set mySymbol = value("#" & aWord)'. In 6.0, you can use the new 'symbol()' conversion function: 'set mySymbol = symbol(aWord)'.





(Top)

URL = "http://www.a3w.de/Lingo/Ldoc_Strings.html"  (971218)

 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