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
Bouncing Ball
Turn puppeting off for a range of sprite channels
Curve Sprite - Move a sprite along a curved path.
Graphic Puzzle Dragger
FFT
ECD
Progressive Blend on Rollover
UpDown Timer
myFile
auto scrolling entryfield
 

 

 

Behavior Replace tabs with spaces

Added on 7/1/1999

 

Compatibilities:
D6_5 D7 D8 Mac PC Script

This item has not yet been rated

Author: ColeTierney

Handler function that replaces TABs with spaces and lines up columbs (intended for use with mono spaced fonts). From Cole Tierney"s Code Corner http://homepages.together.net/%7Etierney/cole/code/

--Side effect is a RETURN is added to text.
on deTab thisText, theTabSize  
  if NOT stringP( thisText ) then return ""  
  if integerP( theTabSize ) then set tabSize = theTabSize
  else set tabSize = 8    -- default tab size  
  set tabStr = ""
  repeat with i = 1 to tabSize
    put " " after tabStr
  end repeat  
  set newString = ""  
  set lineCount = the number of lines in thisText  
  repeat with i = 1 to lineCount    
    set thisLine = line i of thisText    
    if thisLine = "" then
      set newLine = " "
    else  -- LOOK FOR TAB CHARS      
      set newLine = ""
      set numOchars = the number of chars in thisLine    
      set tabCount = 0
      set charCount = 0
      repeat with j = 1 to numOchars      
        set aChar = char j of thisLine        
        if aChar <> TAB and aChar <> numToChar( 10 ) then
          put aChar after newLine
          set charCount = charCount + 1
        else          
          if aChar = TAB then            
            set padStr = char 1 to ( tabSize - charCount mod tabSize ) of tabStr            
            put padStr after newLine
            set charCount = charCount + length( padStr)          
            set tabCount = tabCount + 1            
          end if          
        end if        
      end repeat      
    end if    
    put newLine & RETURN after newString    
  end repeat  
  return newString  
end

 


Contact

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

Send e-mail