* DBLTEST.PRG eliminate large numbers of multiple spaces with the least
* number of replace clauses and no _tally loop
clos data
set talk off
erase ("temp.dbf")
#define SPLEN 254
create table temp (spaces c(SPLEN))
for m.i=1 to SPLEN-2
append blank
repl spaces with "A"+space(m.i)+"B"
endfor
* Changing SPLEN from 16 to 254 only required the addition of space(16) clause
* There might be a more efficient sequence than 2,2,4,8,16
* This handles any number of spaces. Eliminate larger strtran() if the largest number of spaces is known
repl all ;
spaces with strtran(spaces,space(16)," "), ;
spaces with strtran(spaces,space(8)," "), ;
spaces with strtran(spaces,space(4)," "), ;
spaces with strtran(spaces," "," "), ;
spaces with strtran(spaces," "," ")
count for " "$trim(spaces)
if _tally>0 then
?"Fail!"
brow noed for " "$trim(spaces)
else
?"Success!"
endif
clos data
erase ("temp.dbf")
set talk on