• 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: Hungry app
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Hungry app


  • Subject: Re: Hungry app
  • From: "koenig.yvan" <email@hidden>
  • Date: Tue, 08 Jan 2013 13:03:54 +0100


Le 08/01/2013 à 12:00, Shane Stanley <email@hidden> a écrit :

…

You shouldn't call scripting additions within "tell app..." blocks, and all you're using it for is to get a file's name. You could do this instead:

on run
my startWeb()
global myPath, gMyPosixPath, gMyName
set myPath to (path to me)
set gMyPosixPath to POSIX path of myPath
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
set gMyName to text item -1 of gMyPosixPath
set AppleScript's text item delimiters to "."
set gMyName to first text item of gMyName
set AppleScript's text item delimiters to saveTID
my assureMeLoginItem()
do shell script "defaults write " & prefsDomain & space & myNameKey & space & the quoted form of gMyName
end run

My preference would be to declare the globals outside the run handler, along with the properties, but that's probably a simple matter of taste.

Cheers,

Hello

The new script works OK if the script is saved  … as script.
If it’s saved as an application, it fails because gMyPosixPath ends with a slash.

I checked that with :

on run
global myPath, gMyPosixPath, gMyName
set myPath to (path to me)
set gMyPosixPath to POSIX path of myPath
set saveTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {"/"}
if gMyPosixPath ends with "/" then
set gMyName to text item -2 of gMyPosixPath
else
set gMyName to text item -1 of gMyPosixPath
end if
set AppleScript's text item delimiters to saveTID
display dialog gMyName
end run


Yvan KOENIG (VALLAURIS, France) mardi 8 janvier 2013 13:03:23


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Hungry app
      • From: Shane Stanley <email@hidden>
References: 
 >Hungry app (From: Jörgen Stahle <email@hidden>)
 >Re: Hungry app (From: Jörgen Stahle <email@hidden>)
 >Re: Hungry app (From: Axel Luttgens <email@hidden>)
 >Re: Hungry app (From: Shane Stanley <email@hidden>)
 >Re: Hungry app (From: Axel Luttgens <email@hidden>)
 >Re: Hungry app (From: Shane Stanley <email@hidden>)
 >Re: Hungry app (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Hungry app
  • Next by Date: Re: Hungry app
  • Previous by thread: Re: Hungry app
  • Next by thread: Re: Hungry app
  • Index(es):
    • Date
    • Thread