Talk About Network

Google




Programming > Applescript > Re: no brainer
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 8 Topic 1500 of 1697
Post > Topic >>

Re: no brainer

by J. Stewart <cfnzrpu@[EMAIL PROTECTED] > Aug 29, 2007 at 05:43 PM

On 2007-08-29 17:01:00 -0400, Joshua Whalen <joshuafwhalen@[EMAIL PROTECTED]
> said:

>    that's me---No brains! I should know how to do this, I've done it
> before, but it's one of those weeks when you feel like someone took out
> your brain, dipped it in maple syrup, and then let it harden for a few
> days before sticking it back in your head.
> 
> Here goes:
> 
> the script code below is supposed to read in a file containing data
> formatted like this:
> 
> Tuesday, August 28, 2007 1:14:00 PM; clash; 638.566666666667
> Tuesday, August 28, 2007 1:18:00 PM; Frida_Hyvonen; 31.1
> Tuesday, August 28, 2007 1:20:00 PM; bjork; 183.716666666667
> Tuesday, August 28, 2007 1:22:00 PM; reggae; 121.833333333333
> 
> and first create a list in which each line is one list item. then, it's
> supposed to take each line of that list, and treat that as a list in
> which each field of the above is a seperate item. So when I run the
> code, I get this error:
> 
> "can't get every text item of 1"
> now I know this is something easy. I've looked in the manuals, both the
> language guide and the excellent o'reilly books, but I'm playing with
> syrup-damaged brain here today folks, and I'm sure anyone over 40 (like
> me) who's ever had a week of solid all-nighters thrown on his back knows
> what I mean, so could some kind soul help me out?
> 
> keep in mind, this is "problem-solving" code here. It's a subset of a
> larger app, and a few lines are here for debugging or checking to see if
> some data is being gotten correctly (the number dialog, for example)
> 
> Thanks in advance!
> 
> Time to go wash my brain.
> 
> Now where did I leave the peppermint soap?
> 
> Joshua
> 
> the problem  script is here:
> 
> global thecount
> set text item delimiters to (ASCII character 10)
> read file "ibook:Users:joshua:Desktop:ShowTextTest.txt"
> 
> set MyJabberwocky to every text item of the result
> 
> count every text item of MyJabberwocky
> set thecount to the result
> display dialog thecount as number
> 
> repeat with i from 1 to the count of MyJabberwocky
>    set text item delimiters to " ;  "
> 
>    set MyStuff to every text item of i
> 
>    --choose from list MyStuff
>    get item 1 of MyStuff
>    set Mydate to the result
>    get item 2 of MyStuff
>    set myShow to the result
>    get item 3 of MyStuff
>    set myRun to the result
> end repeat
> 
> 
> choose from list MyJabberwocky
> display dialog the result as text

Is this something like what you are looking for? Run it with the event 
log turned on in your script editor.

--> script <--
set MyJabberwocky to (every paragraph of (read file 
"ibook:Users:joshua:Desktop:ShowTextTest.txt"))
repeat with aLine in MyJabberwocky
	set {oldDelims, my text item delimiters} to {my text item delimiters,
{";"}}
	set MyStuff to every text item of (contents of aLine)
	set my text item delimiters to oldDelims
	set {Mydate, myShow, myRun} to {item 1 of MyStuff, item 2 of MyStuff, 
item 3 of MyStuff}
	log "Mydate = " & Mydate & return & "MyShow = " & myShow & return & 
"MyRun = " & myRun & return & return
end repeat
--> Script end <--
-- 
Use ROT-13 for email address
 




 8 Posts in Topic:
no brainer
Joshua Whalen <joshuaf  2007-08-29 17:01:00 
Re: no brainer
J. Stewart <cfnzrpu@[E  2007-08-29 17:43:05 
Re: no brainer
Joshua Whalen <joshuaf  2007-08-29 22:53:54 
Private Message
   2007-08-29 20:24:17 
Private Message
   2007-08-30 13:07:23 
Re: no brainer
J. Stewart <cfnzrpu@[E  2007-08-30 04:33:45 
Re: no brainer
Joshua Whalen <joshuaf  2007-08-30 13:06:22 
Re: no brainer
Joshua Whalen <joshuaf  2007-08-30 13:04:39 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
localhost-V2008-12-19 Mon Jan 5 17:42:43 PST 2009.