'=========================================================================== ' Subject: SPACE TRIMMING Date: 04-20-00 (21:22) ' Author: Hermann Seegert Code: PB ' Origin: hermann.seegert@t-online.de Packet: PB.ABC '=========================================================================== $if 0 Detmold, Germany 19.4.2000 ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿Ü ³ Hi everyone! ³Û ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙÛ ßßßßßßßßßßßßßßßßß Possibly you know this problem: You want to trim a string, so that there is only ONE space between the words, but you don't want to dropp the left margin. Well, I know, that my solution isn't the very best, because it can be programed with pointers, but it still does it's work. Comments can be sent to: hermann.seegert@t-online.de Programmed in PowerBASIC, Version 3.2 $endif '--- Demo code begins.... cls ? "Code is trimming spaces between words to one space left. Margines are" ? "untouched!" text$=" Hermann Seegert's solution for trimming spaces" write text$ call treatingspaces(text$) write text$ end '--- Demo code ends.... ' '---------------------- treatement of spaces ----------------------- ' sub treatingspaces(text$) local x,a,z$,help$ for x=1 to len(text$) 'counting left margine spaces z$=mid$(text$,x,1) if z$<>chr$(32) then decr x,2 : exit for 'first sign<>space next x if x=-1 then 'no margine? help$=text$ else 'there is a margine help$=mid$(text$,1+x) end if for a=tally(help$,chr$(32)) to 1 step -1 'if there are more spaces bet- replace space$(a) with chr$(32) in help$ 'ween two words: there's only next a 'one left if x=-1 then text$=help$ else text$=string$(x,32)+help$ 'ceeping left margine! end if end sub ' '******************************** EOF ******************************