RE: Getting path of application and use it it in an property
RE: Getting path of application and use it it in an property
- Subject: RE: Getting path of application and use it it in an property
- From: "Michael G O'Leary" <email@hidden>
- Date: Fri, 7 Jun 2002 14:14:43 -0500
>
>Message: 6
>
>Date: Thu, 06 Jun 2002 16:23:04 +0200
>
>Subject: Getting path of application and use it it in an property
>
>From: Bjorn Van Blanckenberg <email@hidden>
>
>To: posting Applescript <email@hidden>
>
>
>
>property folderOne : ("volume1:folder1:folder2")
>
>tell application "Finder" to set folderDBase to container of (application
file id "Macf") as string
>
>Return folderDBase -> gives "Macintosh HD:Applications:Tools Database:"
>
>
>
>
>
>but my handler doesn't recognize the FolderDBase
>
>
>
>I don't want to use this line
>
>property folderTwo : ("volume2:folder1:folder2")
>
> -> it's where the application is but it's different on other computer
>
> and I have to input the path on every computer
>
>
>
>It would be nice if I don't have to input it on every computer
>
>
>
>Something in the form of this
>
>property folderTwo : (folderDbase but whitout the last :)
>
>
>
>It's difficult to explain sorry
[I think you want the path without your app name into a property. This
requires an initial
double click/run on each machine to set the property.]
This works for me (if I understood your question correctly)
--OS 9.2.1 AS 1.6 (plain vanilla AS)
property pInstallRun : 0
property pLocation : ""
on run
set pInstallRun to pInstallRun + 1
if pInstallRun > 2 then -- To protect against overflow of variable
"pInstallRun"
set pInstallRun to 2
end if
if pInstallRun = 1 then -- Do just once, during the Installation run
set theWholePath to (path to frontmost application) as string
set pLocation to pathName(theWholePath)
else
display dialog "My path location is: " & return & pLocation
end if
end run
--
=============================================================================
-- pathName -- extracts the path name from a file alias.
--
=============================================================================
on pathName(fileName)
set fileName to fileName as string
set savedDelim to text item delimiters of AppleScript
set text item delimiters of AppleScript to {":"}
set thePath to (reverse of rest of reverse of every text item of
fileName) as string
set text item delimiters of AppleScript to savedDelim
return thePath & ":" -- Append a final colon.
end pathName
_______________________________________________
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.