• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Word length
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Word length


  • Subject: Re: Word length
  • From: Graff <email@hidden>
  • Date: Wed, 06 Oct 2004 17:03:09 -0400

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
  • Follow-Ups:
    • Re: Word length
      • From: Andrew Oliver <email@hidden>
References: 
 >RE: Word length (From: "Ruby Madraswala" <email@hidden>)
 >Re: Word length (From: Graff <email@hidden>)

  • Prev by Date: RE: Word length
  • Next by Date: Re: Word length
  • Previous by thread: Re: Word length
  • Next by thread: Re: Word length
  • Index(es):
    • Date
    • Thread