Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

lining up text that has an '=' in the line 2

Status
Not open for further replies.

coldan

Programmer
Oct 19, 2008
98
AU
Using m to represent a space - (its in arial on the actual post) I want

mmmmmmmmmmmmmmPreposition=in
mmmmmmmmmmmmNameTemplate=colden
mmmmmmmmmmnmmmmmmExhibit=true


If I have the line = lcLine

and x = AT('=',lcLine)

what would the PADL() value be for each line.

I'm a bit rusty this afternoon.

Thanks

Coldan
 
What exactly do you need to know?

PADL() takes a character expression and a number. It left-pads the expressions with enough spaces to make its width equal to the number.

So, if you have the character expression "Coldan", then PADL("Coldan", 10) would give you " Coldan".

But I'm sure you already knew that. Perhaps you could explain your question a little more clearly.

Mike



__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Mea Culpa!

My first message was truncated and missed some details.

The output is to an edit box with Courier New font.

Someone suggested

cMessage = PADL(lcLine,50-(len(left(lcLine,n-1))))

But that produces ragged alignment.

Can you put me straight please, I'm not a mathematician these days.

Thanks

Coldan
 
"But that produces ragged alignment."

As Cetin has indicated, the first challenge to getting things visually aligned will be the individual character spacing.

If you should be using a font with proportional spacing, you will never get things to work.

As he indicated you need to be certain that you are using a font which has uniform spacing (monospaced) regardless of the character. That means that the character width allowed for a "W" will be the same as that allowed for a pipe character "|".

Then adjusting the number of spaces before the intended phrase will reliably work to 'standardize' your visual appearance.

I guess that I am not clear on whether you want all of the equal signs "=" aligned like a column regardless of the non-space characters before and after them like:
Preposition=in
NameTemplate=colden
Exhibit=true

Or do you want the left-most non-space characters to be aligned like:
Preposition=in
NameTemplate=colden
Exhibit=true

Before getting into the specifics of any code to do the job, I'd like to know for certain what your visual goal is.

Good Luck,
JRB-Bldr





 
I think I've read this right. If I did you want the result to be similar to this
Code:
     Exhibit=true
 Preposition=in
NameTemplate=colden

This will return that result. I use 50 as an arbitrary center position.
Code:
lc="Exhibit=true"
?PADL(SUBSTR(lc,1,AT([=],lc)-1),50)+SUBSTR(lc,AT([=],lc))
lc="Preposition=in"
?PADL(SUBSTR(lc,1,AT([=],lc)-1),50)+SUBSTR(lc,AT([=],lc))
lc="NameTemplate=colden"
?PADL(SUBSTR(lc,1,AT([=],lc)-1),50)+SUBSTR(lc,AT([=],lc))

Just replace the 50 with the centerline position you want the = to show at.

Alan
 
Thnaks Alan and everyone.

Alan's code works a treat


Coldan
 
My users have now asked for two changes to what I get with this code

Scan
lc = myLine
cMessage = Padl(Substr(lc,1,At([=],lc)-1),50)+Substr(lc,At([=],lc))
Strtofile(cMessage+Chr(13),'filter.txt',.T.)
Loop
Endscan

They want 2 spaces after the '=' chr to separate the values visually

eg Exhibit= True

They don't want double spaced lines ( means more scrolling) in the edit box.

I tried a chr(10) instead of chr(13) in the print line and left it out altogether but can't get the effect they want.

Can anyone help?

Thanks

Coldan

 
Coldan,

As for the vertical line spacing, you should be seeing each message on a line by itself, with no space between. I can't see why it should be double-spaced - unless cMessage itself contains an embedded carriage-return or line-feed.

What do you see if you do:

Code:
? lcMessage

What spacing are you seeing?

And what happens if you open Filter.TXT in a text editor like Notepad?

By the way, the LOOP command in your code is redundant. Since you are at the bottom of the SCAN loop, control will be returned to the top of the loop in any case.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi Mike,

Indeed the file itself is single spaced.

This is the code in the ini of the edit box form
<code>

This one of a number of cases

thisfile = (mydatapath)+'filter.txt'

endcase

-----------------

cTextString = Filetostr(thisfile)

Thisform.Edit1.Value = cTextString

</code>

On further investigation in Notepad++ with a very wide screen I see that the lines are VERY long - so my guess is they are being 'folded' in the edit box.

Obviously I need to RTRIM the line before its written to the file.

And that has solved my problem.

Many thanks for your help.

Coldan

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top