formatting a text field

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

formatting a text field

Post by Newbie4 » Wed Aug 08, 2012 1:24 pm

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
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

Klaus
Posts: 14198
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: formatting a text field

Post by Klaus » Wed Aug 08, 2012 2:53 pm

Hi Newbie4,

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


Best

Klaus

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: formatting a text field

Post by Newbie4 » Wed Aug 08, 2012 4:32 pm

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
Cyril Pruszko
https://sites.google.com/a/pgcps.org/livecode/
https://sites.google.com/a/setonhs.org/app-and-game-workshop/home
https://learntolivecode.com/

shaosean
Posts: 906
Joined: Thu Nov 04, 2010 7:53 am

Re: formatting a text field

Post by shaosean » Wed Aug 08, 2012 5:07 pm

Take a look at the tabStops property to set the tabs on the fly..

Newbie4
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 332
Joined: Sun Apr 15, 2012 1:17 am
Contact:

Re: formatting a text field

Post by Newbie4 » Wed Aug 08, 2012 11:31 pm

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

Post Reply