Re: adding spaces
Re: adding spaces
- Subject: Re: adding spaces
- From: Nigel Garvey <email@hidden>
- Date: Tue, 26 Aug 2003 10:17:43 +0100
Natalie Lambert wrote on Mon, 25 Aug 2003 20:15:09 -0700 (PDT):
>
I need to take a piece of data and ensure it is a
>
specific character length. If the number of charaters
>
are less than those required then I need to fill the
>
rest with spaces
>
the space the heading needs to fill is 20 characters
>
the heading is "Cars"
>
I know this is going to need a repeat function but I'm
>
a little unclear on the adding spaces bit since I
>
haven't scripted in a while.
You don't actually need a repeat here. The simplest way is to concatenate
twenty spaces to the heading and then use the first twenty characters of
the result:
set heading to "Cars"
set heading to text 1 thru 20 of (heading & " ")
If your original heading has more than twenty characters, it will of
course be truncated rather than padded by this method. If you don't want
that to happen, then:
set heading to "Cars"
if (count heading) < 20 then
set heading to text 1 thru 20 of (heading & " ")
end if
NG
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.