• 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: can't make { . . . } into an item [error message] michelle's code again
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: can't make { . . . } into an item [error message] michelle's code again


  • Subject: Re: can't make { . . . } into an item [error message] michelle's code again
  • From: monk <email@hidden>
  • Date: Mon, 16 Jul 2001 07:42:11 -0400

-- 7/14/01 07:50 pm: email@hidden said:

> First of all, you have to decide upon the formatting of the source file.
> Are items separated by a space, by a tab, by a return, by a marker?
> Let's assume that it's a return for the following script.
>
ok michelle - i studied and got to run this, the source file will be
required to be a text file, and {return, space} will be fine for now

> This script will remove an item from the text and write back to the same
> file. It does not handle adding the removed item to another file.
>
i changed the output file, so that the sourcefile is not overwritten, when i
built the code into it wrote in order (non-arbitrary) each item on a single
line to an output file

curious, (you probably know) this line in the try is a culprit in clearing
all items out of the source file:

set eof of sourcefile to 0

when i got things working here, i did not see repeated arbitrary item
selection, and building a new list excluding that item, i think it assigned
no.s 1 - eof to all items though - which will be useful when i learn how to
select them with 'some'

i see the concept list members are getting at, counting items and assigning
random no.s, i'll keep tweaking things, maybe the random no. needs to be
selected randomly?

h 'monk' elmer
--
| , , , , , , , , , , , |
http://www.assemblage.org
| |

> --Michelle
>
> set sourcefile to choose file
> open for access sourcefile with write permission
> set sourcelist to read sourcefile using delimiter return
>
> try
> set listlength to count (sourcelist)
> set randomnumber to random number from 1 to listlength
> if randomnumber is 1 then
> set outputlist to the rest of sourcelist
> else if randomnumber is listlength then
> set outputlist to items 1 through -2 of sourcelist
> else
> set outputlist to items 1 through (randomnumber - 1) of sourcelist ,
> & items (randomnumber + 1) through -1 of sourcelist
> end if
> set {tid, text item delimiters} to {text item delimiters, return}
> set outputtext to outputlist as text
> set text item delimiters to ""
> set eof of sourcefile to 0
> write outputtext to sourcefile
> on error
> set text item delimiters to ""
> close access sourcefile
> end try
>
> try
> close access sourcefile
> end try
>
>
>
> ----------------------------------------------------------------------
> | Michelle Steiner | We're not human beings having a spiritual |
> | | experience. We're spiritual beings |
> | email@hidden | having a human experience. |
> ----------------------------------------------------------------------
> _______________________________________________
> applescript-users mailing list
> email@hidden
> http://www.lists.apple.com/mailman/listinfo/applescript-users

h 'monk' elmer
--
| , , , , , , , , , , , |
http://www.assemblage.org
| |


References: 
 >Re: can't make { . . . } into an item [error message] (From: Michelle Steiner <email@hidden>)

  • Prev by Date: Re: FM insert Picture
  • Next by Date: Re: can't make { . . . } into an item [error message] deivy's original again
  • Previous by thread: Re: can't make { . . . } into an item [error message] michelle's solution
  • Next by thread: Re: can't make { . . . } into an item [error message]
  • Index(es):
    • Date
    • Thread