1. TO Pete LOMAX re - tab spacing ........ I'm Lost
- Posted by Les Rogers <selgor1 at verizonmail.com> Feb 15, 2007
- 502 views
Hi Pete , Sorry mate .. I can't follow . the following says it all --Les Rogers wrote: --> .............. output is --> HiThere --> HiThere --> Can I make output --> HiThere --> HiThere --I doubt there is any way to change what the console does when you puts(1,"\t"), --but you can pre-process your output. Here is a routine I use in Edita to convert --tabs to spaces: >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Pete, I am learning and I don't know how to implement your great code. Maybe you could show me ?? >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> I ASSUME IT TURNS tab's 8 spaces into 1 or 2 or 3 ??? I AM REALLY IGNORANT of FUNCTIONS ETC. include get.e constant SPACE=' ', TAB='\t' atom w ,isTabWidth isTabWidth=1 global function ExpandTabs(sequence text) -- Replace any tabs with spaces. -- Fast (92,000 lines/second or better) integer tab while 1 do tab=find(TAB,text) if not tab then exit end if text=text[1..tab-1]& repeat(SPACE,isTabWidth-remainder(tab-1,isTabWidth))& text[tab+1..length(text)] end while return text end function --where isTabWidth needs to be set to/defined as 3 for the example you gave. --You could of course make this a procedure, say Puts1, which displays to the --console rather than 'return text'. --HTH, --Pete ----------->>>> MY JUNK BELOW I THINK IS GARBAGE !! puts(1,"\t") if routine_id=ExpandTabs() then end if puts(1,"HiThere") w=wait_key() cheers, les.r.
2. Re: TO Pete LOMAX re - tab spacing ........ I'm Lost
- Posted by don cole <doncole at pacbell.net> Feb 15, 2007
- 465 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
3. Re: TO Pete LOMAX re - tab spacing ........ I'm Lost
- Posted by Pete Lomax <petelomax at blueyonder.co.uk> Feb 15, 2007
- 455 views
- Last edited Feb 16, 2007
Les Rogers wrote: > Sorry mate .. I can't follow . > > puts(1,"\t") > if routine_id=ExpandTabs() then end if > puts(1,"HiThere") > w=wait_key() Ah, I see you are very new to this. Try first this:
puts(1,"HiThere\n") puts(1,"\tHiThere\n") puts(1,ExpandTabs("\tHiThere\n"))
After that I think you should go back to reading the manual and figure out, on your own, how to make it possible instead of coding:
puts(1,ExpandTabs("\tHiThere\n"))
and similar everywhere, you can just write:
Puts1("\tHiThere\n")
There are at least two ways to do this, from the code and hints already given Regards, Pete