Re: TO Pete LOMAX re - tab spacing ........ I'm Lost
- Posted by don cole <doncole at pacbell.net> Feb 15, 2007
- 464 views
</eucode> {{{ constant SPACE=' ', TAB='\t' global function ExpandTabs(sequence text) -- Replace any tabs with spaces. -- Fast (92,000 lines/second or better) integer tab while 1 do -- for ever and ever unless we stop it with exit tab=find(TAB,text)--We are looking for TAB in a sequence called text if not tab then exit end if--if we don't find it then get out and --return --the text sent in(at point 1) --it was not tab so it must be that tab was assigned a --number text=text[1..tab-1] --redefing text from the first letter to --the position --where the tab was found minus 1 & --and repeat(SPACE,--all the follow is muliplied by SPACE isTabWidth --you declared this value somewhere Pete says 3 - -- minus remainder(tab-1,isTabWidth)--you can look this up in the docs -- --under remainder & --and text[tab+1..length(text)]--text is now redefined with --SPACEs replacing TABS --at some point all the TABs will be - --replaced with --SPACEs and we will not find any tab -- --so we will --exit and all the --modified text will be returned at ---- --point 1 end while return text --(point 1) end function </eucode> {{{ Don Cole