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