• 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: Write to file??
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Write to file??


  • Subject: Re: Write to file??
  • From: Paul Skinner <email@hidden>
  • Date: Thu, 1 Aug 2002 10:37:58 -0400

On Wednesday, July 31, 2002, at 01:41 PM, John Delacour wrote:

> At 3:32 pm -0400 30/7/02, Steve Suranie wrote:
>
>> I have a script which at the end writes data to a log file. When I
>> run the script on my G4......
>>
>> set thisDate to current date
>> set logPath to the folder "_logs" of the folder "Merion Image
>> Archive" of the disk "Cumulus" as string
>>
>> set thisMonth to the month of thisDate as string
>>
>> if thisMonth = "January" then
>> set thisMonth to "01"
>> else if thisMonth = "February" then
>> set thisMonth to "02"
>> else if thisMonth = "March" then
>> set thisMonth to "03"
>> else if thisMonth = "April" then
>
>
> ... yawn
>
>
> If you're running OS X, then you can do this:
>
> -----
> set junk to POSIX path of "doc:junk.txt"
> -- a file to be created in volume 'doc'
> --
> set pl to "perl -e '@t = localtime;"
> set pl to pl & "printf qq(d-d-d),"
> set pl to pl & "$t[5]-100,$t[4],$t[3];'"
> set vText to "Today\\047s date is " & (do shell script pl)
> --
> set pl to " perl -e ' "
> set pl to pl & " $f = qq(" & junk & "); "
> set pl to pl & " open F, qq(>$f) ; "
> set pl to pl & " print F qq(" & vText & "); "
> set pl to pl & " close F; "
> set pl to pl & " ' "
> --
> do shell script pl
> do shell script "open " & junk
> -----
>
> Now that shell scripting is possible, it makes little sense to
> continue using the verbose and unwieldy syntax of AppleScript,
> JD

And concise and obtuse is better?

I prefer to write AS that is concise and readable then wrap it up in a
handler to do all this kind of stuff naturally.

WriteData(logData)
-->alias "darkstar:Users:paulskin:Desktop:020801102112"

--
Paul Skinner
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: get default browser?
  • Next by Date: Re: Today's Question - poke a character in a string
  • Previous by thread: Re: get default browser?
  • Next by thread: Re: Write to file??
  • Index(es):
    • Date
    • Thread