RE: Word length - resolved
RE: Word length - resolved
- Subject: RE: Word length - resolved
- From: "Ruby Madraswala" <email@hidden>
- Date: Thu, 7 Oct 2004 13:01:02 -0400
- Thread-topic: Word length
I don't know if this is the correct way to solve this problem. I changed the
if, else, end if
to
try, on error end tell. And it worked.
Ruby
-----Original Message-----
From: Ruby Madraswala
Sent: Thursday, October 07, 2004 9:27 AM
To: AppleScript AppleScript Users
Subject: RE: Word length
Thanks
set staple_code to (text returned of user_stuff) as string
worked.
But now I am having problem with the second part of the script.
Set outfile to staplefolder & stfile
set newfile to staplefolder & staple_code
Display dialog newfile (path and filename displayed is correct (or looks correct))
If file newfile exists then (this fails, it goes to "not found" statement.)
Set stapletext to read file newfile from 1
Write staple_code & return & stapletext & return to outfile
Else
Write staple_code & " not found" & return to outfile
End if
Thanks again
Ruby
-----Original Message-----
From: applescript-users-bounces+rubym=email@hidden [mailto:applescript-users-bounces+rubym=email@hidden] On Behalf Of Graff
Sent: Wednesday, October 06, 2004 5:03 PM
To: AppleScript AppleScript Users
Subject: Re: Word length
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:
----
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