Re: Word length
Re: Word length
- Subject: Re: Word length
- From: Andrew Oliver <email@hidden>
- Date: Wed, 06 Oct 2004 14:19:51 -0700
On 10/6/04 2:03 PM, "Graff" <email@hidden> wrote:
> I take that back. Now that I look at it there is extra stuff in there.
> I didn't see it until I used a different program to view the text.
>
> It's definitely a unicode issue. You can fix it by coercing the text
> to a string. Here's the fixed script:
Actually, in this case it's better to get the COUNT of the characters in the
text rather than the length of it.
Coercing to string may work - in fact, probably will most of the time - but
the first time you get some non-ascii input you're going to break:
So, instead of:
> set lencnt to length of staple_code
use:
> set lencnt to count (characters of staple_code)
Andrew
:)
> ----
> set button_name to "OK"
> set user_stuff to display dialog ¬
> "Enter Number:" default answer ¬
> " " buttons {"Exit", "OK"} default button "OK"
> set button_name to button returned of user_stuff
> set style_no to text returned of user_stuff
>
> -- changed next line so that the file is created on the current user's
> desktop
> set fname to (path to desktop as string) & style_no & ".tem"
> set file_ref to open for access file fname with write permission
>
> set button_name to "OK"
> set code_list to {}
> repeat until button_name is "Exit"
> set user_stuff to display dialog ¬
> "Enter Code:" & code_list default answer ¬
> " " buttons {"Exit", "OK"} default button "OK"
> set button_name to button returned of user_stuff
>
> if button_name is "OK" then
>
> -- the fix: get the text and coerce it to a string
> set staple_code to (text returned of user_stuff) as string
>
> set eof_value to get eof file_ref
> write staple_code & return to file_ref starting at (eof_value + 1)
> set lencnt to length of staple_code
> display dialog staple_code
> end if
> end repeat
> close access file_ref
> ----
>
> - Ken
>
> On Oct 6, 2004, at 4:37 PM, Graff wrote:
>
>> This script seems to work just fine for me. I changed it a little so
>> that it would write the file to my desktop. It creates a file and
>> then puts the numbers in it just fine.
>>
>> If you are having problems with the program maybe you are attempting
>> to create the file where you don't have permissions?
>>
>> Here's my modified version:
>
> <snip>
>
>>
>> On Oct 6, 2004, at 4:16 PM, Ruby Madraswala wrote:
>>
>>> set button_name to "OK"
>>> set user_stuff to display dialog ¬
>>> "Enter Number:" default answer ¬
>>> " " buttons {"Exit", "OK"} default button "OK"
>>> set button_name to button returned of user_stuff
>>> set style_no to text returned of user_stuff
>>>
>>> set fname to "HD:" & style_no & ".tem"
>>> set file_ref to open for access file fname with write permission
>>>
>>> set button_name to "OK"
>>> set code_list to {}
>>> repeat until button_name is "Exit"
>>> set user_stuff to display dialog ¬
>>> "Enter Code:" & code_list default answer ¬
>>> " " buttons {"Exit", "OK"} default button "OK"
>>> set button_name to button returned of user_stuff
>>>
>>> if button_name is "OK" then
>>> set staple_code to text returned of user_stuff
>>> set eof_value to get eof file_ref
>>> write staple_code & return to file_ref starting at (eof_value + 1)
>>> set lencnt to length of staple_code
>>> display dialog staple_code
>>> end if
>>> end repeat
>>> close access file_ref
>
> <snip>
>
>>> On Oct 6, 2004, at 2:17 PM, Ruby Madraswala wrote:
>>>
>>>> I have a script which work fine on OS 9.Now I want to use the same
>>>> script on OS 10.
>>>>
>>>> The script
>>>> - prompts user to enter words
>>>> - creates a list of entered words.
>>>> - Reads the list and matches with filename and copies the content of
>>>> the file in a new file.
>>>>
>>>> In OS 9 the length of word is 4 and for the same word the length in
>>>> OS
>>>> 10.3.5 is 9. It seems like it is padding with spaces which is not
>>>> visible. any reason Why? And how can I resolve this.
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Applescript-users mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden