Page 1 of 1

formatting a text field

Posted: Wed Aug 08, 2012 1:24 pm
by Newbie4
Is there a way to format lines in a text field? I want to line up some columns in a text field as I put separate fields in them.

I tried doing it with setting tabs but that results in widely spaced columns. Is there any way to line up the columns or set column stops?

Thank you

Re: formatting a text field

Posted: Wed Aug 08, 2012 2:53 pm
by Klaus
Hi Newbie4,

to be honest, I don't have the slightest idea what your are trying to do!?
Fields in fields? :shock:


Best

Klaus

Re: formatting a text field

Posted: Wed Aug 08, 2012 4:32 pm
by Newbie4
I am sorry that I did not explain it very well. Maybe a example will help.

For instance, I want to print my address book which has a name, address, phone number, etc stored in an array. I would like to print a report with just the name and phone number and have it nicely lined up in columns.
Right now I am assembling the fields I want into an output field to print
e.g.

Code: Select all

repeat with ctr = 1 to 20
   put pb[ctr]["last"] & ", " & pb[ctr]["first"] & tab & pb[ctr]["phone"] into field "toPrint"
end repeat
 
Then when the loop finishes, I will print the field "toPrint"

The names are different lengths so the phone numbers do not line up correctly. If I make the tab a large enough number to accomodate the longest name, the report is too spread out.

I could set a smaller tab and truncate the longer names to fit.

Is there a better way to do it?

Thanks

Re: formatting a text field

Posted: Wed Aug 08, 2012 5:07 pm
by shaosean
Take a look at the tabStops property to set the tabs on the fly..

Re: formatting a text field

Posted: Wed Aug 08, 2012 11:31 pm
by Newbie4
That was exactly what I was looking for. It works great.

I also discovered vGrid to help in choosing values for the tabStops, (hard since it is in pixels, not chars)
and hGrid which makes its also more readable.

Thanks