Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
convertTabsToSpaces
#1
How can I convert tabs to spaces?

e.

A[9]A1[9]A2[9]A3
AA[9]AA1[9]AA2[9]AA3
AAA[9]AAA1[9]AAA2[9]AAA3
AAAA[9]AAAA1[9]AAAA2[9]AAAA3



Code:
Copy      Help
A       A1      A2      A3  
AA      AA1     AA2     AA3  
AAA     AAA1    AAA2    AAA3
AAAA    AAAA1   AAAA2   AAAA3
#2
Member function str.TabsToSpaces
Code:
Copy      Help
function# tabWidth

;Replaces tabs to spaces.
;Returns the number of found tabs.


;tabWidth - the number of characters that fit in a tab (eg 8 in notepad, 4 in qm).

;EXAMPLE
;str s.getsel ;;copy selected text from eg notepad
;s.TabsToSpaces(8)
;s.setsel



if(tabWidth<1) end ES_BADARG

str ss.flags=1; ss.all(this.len)
int i j
for i 0 this.len
,sel this[i]
,,case 9 ss.set(32 ss.len tabWidth-j); j=0
,,case [13,10] ss.geta(this i 1); j=0
,,case else ss.geta(this i 1); j+1; if(j=tabWidth) j=0
this=ss
#3
can you put this one into the next version of QM?
thanks.
An old blog on QM coding and automation.

The Macro Hook
#4
Probably. Also, str.addline, str.getshortpath, and more.
#5
Thanks, but in

Code:
Copy      Help
str a="AAAAAAA[9]AAAAAAAAA[9]AAAAA[]AAA[9][9]AAAAA[9][9]AAA[]AAAA[9][9]AAA[9][9]AAA"
out a
out " "
a.TabsToSpaces(8)
out a

doesn't work...
#6
updated


Forum Jump:


Users browsing this thread: 3 Guest(s)