Re: stripping an extra character from a text item
Re: stripping an extra character from a text item
- Subject: Re: stripping an extra character from a text item
- From: email@hidden
- Date: Tue, 18 Dec 2001 17:29:18 EST
Robert,
If you know that there will always be exactly one trailing space character,
try this approach (I hope there are no silent coercions at work OMM):
set lHolder to (read x until tab)
set lHolder to text 1 thru -2 of lHolder as number
Jeff Baumann
email@hidden
www.linkedresources.com
In a message dated 12/18/01 3:12:36 PM, Robert Castles wrote:
>
I'm sure that this is something really stupid that I'm doing, but I'm
>
reading/sorting values from a tab-deliminated text file and I can't seem so
>
coerce the values into real or number elements. The script reads a series of
>
numbers into a list and when I go to use the numbers I can't coerce them. I
>
checked the values of the items and they're coming up with the number and
>
then an extra space on the end "87.54 ". I checked the text file and it
>
doesn't have any extra spaces or tabs in it. I've tried to delete the extra
>
character by doing the following:
>
>
delete last character of numberVariable
>
>
and/or
>
>
delete character 6 of numberVariable
>
>
both give me a "character 6 of....doesn't understand the delete command."
>
>
Here's the actual code that I'm using:
>
>
repeat with i from 1 to 20
>
>
--get the name of the selected record
>
set nameHolder to read x until tab
>
set nameList to nameList & nameHolder
>
>
--get the L value of the select record
>
set lHolder to (read x until tab)
>
>
--check to see if the value is the lMin or lMax
>
if lHolder > lMax then
>
set lMax to lHolder as number
>
set lMaxPos to i
>
end if
>
if lHolder < lMin then
>
set lMin to lHolder as real
>
set lMinPos to i
>
end if
>
>
--advance to the next record
>
read x until return
>
end repeat
>
>
The if statement is actually where I'm having the problem. Since I can't get
>
the value to be recognized as a number, it won't make the comparison.
>
>
Any ideas?
>
>
Thanks in advance,
>
>
-Bob