Contents
Articles
Behaviors
Books
Director News
Director Web Sites
FAQ
Games
Mailing Lists
News Groups
Project Examples
Reviews
Software
Tools
Useful Web Sites
Utilities
Xtras

Don't miss these
A* Pathfinder in Lingo
KKT Interactive
Rosetta Xtra
Orbiter
SMARTSCRIPT
Get Line Number of Word
Rollover Fader-Alphamania
Wait for a MouseClick or Keypress
Color Fader-Alphamania
Sprite generation
 

 

 

Behavior List display, export

Added on 6/4/2001

 

Compatibilities:
D7 D8 D8_5 Mac PC Script Shockwave

This item has not yet been rated

Author: Markie (website)

This utility handler is designed to make a list easier to read during development.

-- This utility was originally written by Jason Winshell in 1995
-- I have updated the handler to work without support Xtras or other functions being called
-- I've also optimized the string handling somewhat
-- Additionally, I added the ability to specify the delimiter for output
-- You can specify the delimiter between items (default to TAB)
-- Or you can specify the delimiter between lines (default to RETURN)
-- NOTE: If you use the " " (space) for the first and "\" (backslash) for the latter, you should be able to compile the output
-- The actual functionality is almost entirely untouched
-- Mark Castle, Castle Productions, May 2001
-- Example:
-- x = [#winken, #blinken, #nodd,[1,2,3,[#first:1,#second:2]]]
-- put ListToDisplayString( x )
on ListToDisplayString incomingList, fieldDelimiter, lineDelimiter
  --  Create an empty string to contain the formatted display text
  outputString = ""
  
  listWalker = [0:0]
  currList = incomingList
  currListPos = 1
  thisDepth = 0
  --  Replace the field delimiter if necessary
  if voidP( fieldDelimiter ) then
    fieldDelimiter = TAB
  end if
  --  Replace the line delimiter if necessary
  if voidP( lineDelimiter ) then
    lineDelimiter = RETURN
  end if
  
  put "[" & lineDelimiter after outputString
  
  repeat while listP(currList)
    
    -- outside if test so we can use tabs in else clause
    lineString = ""
    repeat with depthCount = 0 to thisDepth
      lineString = lineString & fieldDelimiter
    end repeat
    
    if currListPos <= count( currList ) then
      
      if ilk( currList, #proplist ) then
        prop = getPropAt( currList, currListPos )
        if ilk( prop, #symbol ) then
          put "#" & string( prop ) & " : " after lineString
        else if ilk( prop, #string ) then
          put QUOTE & string( prop ) & QUOTE & " : " after lineString
        else
          put lineString & string( prop ) & " : " after lineString
        end if        
      end if
      
      -- what kind of value
      isListValue = FALSE
      value = getAt( currList, currListPos )
      if ilk( value, #proplist ) OR ilk( value, #linearList ) then
        isListValue = TRUE
        addProp( listWalker, currList, currListPos + 1 )
        currList = value
        currListPos = 1
        
        thisDepth = thisDepth + 1
        put "[" after lineString
        
      else if ilk( value, #string ) then
        put QUOTE & string( value ) & QUOTE after lineString
        currListPos = currListPos + 1
        
      else if ilk( value, #symbol ) then
        put "#" & string( value ) after lineString
        currListPos = currListPos + 1
      else
        put string( value ) after lineString
        currListPos = currListPos + 1
      end if
      
      -- add comma if not last element in list
      if currListPos <= count( currList ) AND not isListValue then
        put "," after lineString
      end if
      
      put lineString & lineDelimiter after outputString
      
    else
      -- if the current list was a zero element property list
      -- output a single ':'
      
      -- pop back up
      if ilk( currList, #proplist ) then
        if count( currList) = 0 then
          put " : " after lineString
          
          put lineString & lineDelimiter after outputString
        end if
      end if
      
      currList =  getPropAt( listWalker, count( listWalker ) )
      currListPos =  getAt( listWalker, count( listWalker ) )
      thisDepth = thisDepth - 1
      lineString = ""
      if thisDepth >= 0 then
        deleteAt( listWalker, count( listWalker ) )  
        repeat with depthCount = 0 to thisDepth
          put fieldDelimiter after lineString
        end repeat
        
        --        --        put "]" after lineString
        -- add comma if not last element in list
        if currListPos <= count( currList )  then
          put "," after lineString
        end if
        
        put lineString & lineDelimiter after outputString
      end if
      
    end if
    
  end repeat
  
  put "]" & lineDelimiter after outputString
  
  return outputString
end  

 


Contact

MMI
36 South Court Sq
Suite 300
Newnan, GA 30263
USA

Send e-mail