Does anyone know of command to convert Tabs into Spaces?

of course a STRT will do the trick, except for the tabs that are less than
the characters specified in the STRT.

There is a VB command which I've seen referenced although I don't know if it
will address the problem above.

Edit.ConvertTabsToSpaces

--
Thank You,

Louis

Re: Converting Tabs to Spaces by Man-wai

Man-wai
Thu Aug 10 21:35:00 CDT 2006

Thanks wrote:
> Does anyone know of command to convert Tabs into Spaces?
>
> of course a STRT will do the trick, except for the tabs that are less than
> the characters specified in the STRT.
>
> Edit.ConvertTabsToSpaces

Did you try:

m.lcContent=filetostr("thefile.txt")
m.lcContent=strtran(m.lcContent,chr(9),space(2))
strtofile(m.lcContent, "/path/to/output.txt")


--
SoftMedia Technology Co., Ltd.
Website: http://www.softmedia.hk Tel: (852)2743 4228
* TryEasy Accounting/POS/Trading/ERP solutions

Re: Converting Tabs to Spaces by AA

AA
Fri Aug 11 08:59:10 CDT 2006

CHRTRAN(text, CHR(9), SPACE(1))

-Anders

"Thanks" <louis_sorbera@msn.com> skrev i meddelandet
news:uSiYjkKvGHA.4624@TK2MSFTNGP02.phx.gbl...
> Does anyone know of command to convert Tabs into Spaces?
>
> of course a STRT will do the trick, except for the tabs that are less than
> the characters specified in the STRT.
>
> There is a VB command which I've seen referenced although I don't know if
> it will address the problem above.
>
> Edit.ConvertTabsToSpaces
>
> --
> Thank You,
>
> Louis
>



Re: Converting Tabs to Spaces by Thanks

Thanks
Fri Aug 11 17:07:40 CDT 2006


Thanks for the attempted help, however, tabs are variable length, so a
simple STRT doesn't do it.

Here is a sample, and this is how they line up, because the tabs differ


PROSTATE, CORE BIOPSIES WITH CYTOSPINS:

LA: BENIGN PROSTATIC TISSUE. RA: BENIGN PROSTATIC TISSUE;
LM: BENIGN PROSTATIC TISSUE. MILD CHRONIC INFLAMMATION.
LE: BENIGN PROSTATIC TISSUE. RM: FOCAL GLANDULAR HYPERPLASIA.
LPZ: BENIGN PROSTATIC TISSUE. RE: BENIGN PROSTATIC TISSUE.
LB: MILD CHRONIC INFLAMMATION. RPZ: BENIGN PROSTATIC TISSUE.
LT. CYTOSPINS: BENIGN GLANDULAR RB: BENIGN PROSTATIC TISSUE.
COMPLEXES. RT.
CYTOSPINS: BENIGN GLANDULAR

COMPLEXES.


Here is what we want

PROSTATE, CORE BIOPSIES WITH CYTOSPINS:

LA: BENIGN PROSTATIC TISSUE. RA: BENIGN PROSTATIC TISSUE;
LM: BENIGN PROSTATIC TISSUE. MILD CHRONIC
INFLAMMATION.
LE: BENIGN PROSTATIC TISSUE. RM: FOCAL GLANDULAR
HYPERPLASIA.
LPZ: BENIGN PROSTATIC TISSUE. RE: BENIGN PROSTATIC TISSUE.
LB: MILD CHRONIC INFLAMMATION. RPZ: BENIGN PROSTATIC TISSUE.
LT. CYTOSPINS: BENIGN GLANDULAR RB: BENIGN PROSTATIC TISSUE.
COMPLEXES. RT.
CYTOSPINS: BENIGN GLANDULAR

COMPLEXES.



"AA" <A@A> wrote in message news:%23MPajDVvGHA.2036@TK2MSFTNGP05.phx.gbl...
> CHRTRAN(text, CHR(9), SPACE(1))
>
> -Anders
>
> "Thanks" <louis_sorbera@NOSPAM.msn.com> skrev i meddelandet
> news:uSiYjkKvGHA.4624@TK2MSFTNGP02.phx.gbl...
>> Does anyone know of command to convert Tabs into Spaces?
>>
>> of course a STRT will do the trick, except for the tabs that are less
>> than the characters specified in the STRT.
>>
>> There is a VB command which I've seen referenced although I don't know if
>> it will address the problem above.
>>
>> Edit.ConvertTabsToSpaces
>>
>> --
>> Thank You,
>>
>> Louis
>>
>
>



Re: Converting Tabs to Spaces by Man-wai

Man-wai
Sat Aug 12 03:57:52 CDT 2006

> Here is what we want
>
> PROSTATE, CORE BIOPSIES WITH CYTOSPINS:
>
> LA: BENIGN PROSTATIC TISSUE. RA: BENIGN PROSTATIC TISSUE;
> LM: BENIGN PROSTATIC TISSUE. MILD CHRONIC
> INFLAMMATION.
> LE: BENIGN PROSTATIC TISSUE. RM: FOCAL GLANDULAR
> HYPERPLASIA.
> LPZ: BENIGN PROSTATIC TISSUE. RE: BENIGN PROSTATIC TISSUE.
> LB: MILD CHRONIC INFLAMMATION. RPZ: BENIGN PROSTATIC TISSUE.
> LT. CYTOSPINS: BENIGN GLANDULAR RB: BENIGN PROSTATIC TISSUE.
> COMPLEXES. RT.
> CYTOSPINS: BENIGN GLANDULAR

Can you specify the rules in plain English (if not formal languages like
Z or VDM)?

--
.~. Might, Courage, Vision, SINCERITY. http://www.linux-sxs.org
/ v \ Simplicity is Beauty! May the Force and Farce be with you!
/( _ )\ (Ubuntu 6.06) Linux 2.6.17.8
^ ^ 16:56:01 up 4 days 21:52 0 users load average: 1.00 1.02 1.03
news://news.3home.net news://news.hkpcug.org news://news.newsgroup.com.hk

Re: Converting Tabs to Spaces by Thanks

Thanks
Sun Aug 13 21:04:32 CDT 2006

What I needs to be done is to calculate the tabs that are less than a set
length and convert those to their spaces, then use the strt to replace the
rest. Tabs count as one character

What do you think of this?

I need to do this for a memo, so the first thing is to bering in the memo
one line at a time. How do I do that? Assuming I did, and the line is line,

line = 'LA: FOCAL CHRONIC PROSTATITIS. RA: BENIGN PROSTATIC TISSUE.'

loca for chr(9) $ line

if found()

t1=at(chr(9), line, 1)
if found()
lineA= left(line, t1-1)
lineB= right(line, len(line) -t1)
t1R= t1/5
t1Rs= str(t1r, 4,1)
t1Rd= substr(t1Rs, at('.', t1Rs)+1, 1)


do case
case t1Rd = 1 or t1Rd = 6 && tab is 5 spaces
line = lineA + space(5) + LineB

do case
case t1Rd = 2 or t1Rd = 7 && tab is 4 spaces
line = lineA + space(4) + LineB

do case
case t1Rd = 3 or t1Rd = 8 && tab is 3 spaces
line = lineA + space(3) + LineB

do case
case t1Rd = 4 or t1Rd = 9 && tab is 2 spaces
line = lineA + space(2) + LineB

do case
case t1Rd = 0 or t1Rd = 5 && tab is 1 space
line = lineA + space(1) + LineB

endcase

etc. Help me out

I also found the untabify method, but don't know how to get it into Fox

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_untabify_method.asp



Re: Converting Tabs to Spaces by Andrew

Andrew
Mon Aug 14 03:25:01 CDT 2006

"Thanks" <louis_sorbera@DONOTSPAM.msn.com> wrote in message
news:eXRq4X0vGHA.4872@TK2MSFTNGP02.phx.gbl...
> What I needs to be done is to calculate the tabs that are less than a set
> length and convert those to their spaces, then use the strt to replace the
> rest. Tabs count as one character
>

Knocked this up, does it help? Seems to work OK in my hasty unthorough
testing..
Watch out for line wrapping problems when I've sent it. I've tried to keep
lines quite short but maybe not short enough..
The whole thing when run should create a cursor with a couple of memo
fields, one has some test data with tabs, the other is replaced with my
functions to convert the tabs to spaces.

Don't forget to look at the data with a monospace font!


*************************
* replace tabs with spaces respecting differing tab size..

#DEFINE c_crlf CHR(13)+CHR(10)
#DEFINE c_tab CHR(9)

CREATE CURSOR tabtest (withtabs M, withspcs M)
INSERT INTO tabtest (withtabs) VALUES ;
('Here is a tab test...'+c_crlf+;
c_tab+'this line is one tab in...'+c_crlf+;
'+'+c_tab+'this line is also one tab in'+c_tab+c_tab+'and now I want to
line'+c_crlf+;
REPLICATE(c_tab, 10)+'these bits up....'+c_crlf+;
'which should be not too impossible'+c_tab+c_tab+'|--- lined up!')



&& ensure memowidth at least as wide as widest memo line
SET MEMOWIDTH TO 150
REPLACE withspcs WITH untabmem(withtabs, 4)



*******************
FUNCTION untabmem
*******************
* return contents of memo field with tabs replaced by
* spaces, preserving alignment (in monospaced font)
PARAMETERS m.pmemofield, m.ptabsize
* pmemofield [R] M - memofield to convert
* ptabsize [R] N - size of tabstops for conversion purposes

PRIVATE ALL LIKE l*
_MLINE=0
m.loutput=''
FOR m.lline=1 TO MEMLINES(m.pmemofield)
m.loutput=m.loutput+tab2space(MLINE(m.pmemofield, 1, _MLINE),
m.ptabsize)+c_crlf
NEXT
RETURN m.loutput

*******************
FUNCTION tab2space
*******************
* return line of text with tabs replaced by spaces
* for given tabstop size
* only works correctly for a single line of text (no EOL chars)
PARAMETERS m.pline, m.ptabsize
PRIVATE ALL LIKE l*

m.ltabpos=AT(CHR(9), m.pline)
DO WHILE m.ltabpos>0
m.lspaces=(CEILING(m.ltabpos/m.ptabsize)*m.ptabsize)-m.ltabpos+1
m.pline=STUFF(m.pline, m.ltabpos, 1, SPACE(m.lspaces))
m.ltabpos=AT(CHR(9), m.pline)
ENDDO
RETURN m.pline


--
HTH
Andrew Howell



Re: Converting Tabs to Spaces by AA

AA
Mon Aug 14 05:22:34 CDT 2006

You could extract the contents to VFP cursors or tables. As I see it there,
there are headers and lines.
Lines have two colons ( : ) preceded by varying-length codes like LA: or RA:
or LT. CYTOSPINS:
The text part following the code: ends with a full stop dot.
Headers are texts like
PROSTATE, CORE BIOPSIES WITH CYTOSPINS:
These header lines end with a single : and have no dots.
The headers should go in a cursor with a structure like
CREATE TABLE Headers (headerid Int AutoInc , headertext C(100))
The rest would be insterted n a table with the structure
CREATE TABLE xx (headerid Int , code Char(30), linetext C(100))

Lines in a VFP memo end with a linebreak character, chr(13).
You can scan a memo using the functions MEMLINES(), MLINE() and speed up
performance by using _MLINE
LOCAL lcLine
_MLINE=0
FOR i = 1 TO MEMLINES(tablename.memoname)
lcLine = MLINE(tablename.memoname, 1,_MLINE)
* analyze lcLine
NEXT

You analyze each line with OCCURS(), AT and extract parts with LEFT(),
RIGHT(), SUBSTR() and perhaps simpler with STREXTR()
lcLine="LA: BENIGN PROSTATIC TISSUE. RA: BENIGN PROSTATIC TISSUE;"
? STREXTRACT(line,'',':')
LA

? STREXTRACT(line,':','.',1)
FOCAL CHRONIC PROSTATITIS

? LTRIM(STREXTRACT(line,'.',':',1))
RA

? STREXTRACT(line,':','',2)
BENIGN PROSTATIC TISSUE.

Once the data has been properly structered and stored you can create VFP
reports that will print them any way you want.

-Anders


"Thanks" <louis_sorbera@DONOTSPAM.msn.com> skrev i meddelandet
news:eXRq4X0vGHA.4872@TK2MSFTNGP02.phx.gbl...
> What I needs to be done is to calculate the tabs that are less than a set
> length and convert those to their spaces, then use the strt to replace the
> rest. Tabs count as one character
>
> What do you think of this?
>
> I need to do this for a memo, so the first thing is to bering in the memo
> one line at a time. How do I do that? Assuming I did, and the line is
> line,
>
> line = 'LA: FOCAL CHRONIC PROSTATITIS. RA: BENIGN PROSTATIC TISSUE.'
>
> loca for chr(9) $ line
>
> if found()
>
> t1=at(chr(9), line, 1)
> if found()
> lineA= left(line, t1-1)
> lineB= right(line, len(line) -t1)
> t1R= t1/5
> t1Rs= str(t1r, 4,1)
> t1Rd= substr(t1Rs, at('.', t1Rs)+1, 1)
>
>
> do case
> case t1Rd = 1 or t1Rd = 6 && tab is 5 spaces
> line = lineA + space(5) + LineB
>
> do case
> case t1Rd = 2 or t1Rd = 7 && tab is 4 spaces
> line = lineA + space(4) + LineB
>
> do case
> case t1Rd = 3 or t1Rd = 8 && tab is 3 spaces
> line = lineA + space(3) + LineB
>
> do case
> case t1Rd = 4 or t1Rd = 9 && tab is 2 spaces
> line = lineA + space(2) + LineB
>
> do case
> case t1Rd = 0 or t1Rd = 5 && tab is 1 space
> line = lineA + space(1) + LineB
>
> endcase
>
> etc. Help me out
>
> I also found the untabify method, but don't know how to get it into Fox
>
> http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcug98/html/_asug_untabify_method.asp
>
>



Re: Converting Tabs to Spaces by Andrew

Andrew
Tue Aug 15 02:31:07 CDT 2006

"Andrew Howell" <ajh@work> wrote in message
news:u5Vt4A4vGHA.3264@TK2MSFTNGP03.phx.gbl...

After a sleepless night, there are a couple of corrections below:

> *******************
> FUNCTION untabmem
> *******************
> * return contents of memo field with tabs replaced by
> * spaces, preserving alignment (in monospaced font)
> PARAMETERS m.pmemofield, m.ptabsize
> * pmemofield [R] M - memofield to convert
> * ptabsize [R] N - size of tabstops for conversion purposes
>
> PRIVATE ALL LIKE l*
> _MLINE=0
> m.loutput=''
> FOR m.lline=1 TO MEMLINES(m.pmemofield)
> m.loutput=m.loutput+tab2space(MLINE(m.pmemofield, 1, _MLINE),
> m.ptabsize)+c_crlf
> NEXT
> RETURN m.loutput

Inserting this line immediately before RETURN above removes the extra
trailing crlf I added..

m.loutput=LEFT(m.loutput, LEN(m.loutput)-2)

>
> *******************
> FUNCTION tab2space
> *******************
> * return line of text with tabs replaced by spaces
> * for given tabstop size
> * only works correctly for a single line of text (no EOL chars)
> PARAMETERS m.pline, m.ptabsize
> PRIVATE ALL LIKE l*
>
> m.ltabpos=AT(CHR(9), m.pline)
> DO WHILE m.ltabpos>0
> m.lspaces=(CEILING(m.ltabpos/m.ptabsize)*m.ptabsize)-m.ltabpos+1

I think the line above is nicer if replaced with

m.lspaces=m.ptabsize-((m.ltabpos+m.ptabsize-1)%m.ptabsize)


--
regards
Andrew Howell