Re: newbie tries to define variables
Re: newbie tries to define variables
- Subject: Re: newbie tries to define variables
- From: "Arthur J. Knapp" <email@hidden>
- Date: Wed, 02 Oct 2002 12:46:46 -0400
>
Date: Wed, 02 Oct 2002 09:51:43 -0500
>
Subject: newbie tries to define variables
>
From: Rick Norman <email@hidden>
>
What I'm trying to achieve with the following is to be able to drop multiple
>
folders onto an applet and have each one processed using parts of the name
>
of the folder. The folders are named in this manner "02personsnameaddress",
>
"03personsnameaddress" and so on. What is wrong here is that if I drop these
>
two folders onto this applet "theName" will match "03personsnameaddress",
>
"recNum" will match "03personsnameaddress", "theFolder" will match
>
"03personsnameaddress" but "a_folder" will match "02personsnameaddress". How
>
do I have all these variables identify with the same folder?
>
on open theFolder
Well, first, theFolder is not "a folder", it is a list of folders.
Actually, it is a list of aliases of whatever is dropped onto it.
>
set old_delimiters to AppleScript's text item delimiters
>
set AppleScript's text item delimiters to ":"
>
set n_items to the number of text items in (theFolder as string)
>
set theName to text item (n_items - 1) in (theFolder as string)
>
set AppleScript's text item delimiters to old_delimiters
>
set recNum to text 1 thru 2 of theName as integer
>
repeat with a_folder in theFolder
>
display dialog "theName" & "-" & theName
>
display dialog "recNum" & "-" & recNum
>
display dialog "theFolder" & "-" & theFolder
>
display dialog "a_folder" & "-" & a_folder
I'm not certain what your ultimate goal is here, but maybe this will help:
on open listOfAliases --> { alias "...", alias "...", etc... }
set tids to text item delimiters
set text item delimiters to ":"
repeat with oneItem in listOfAliases --> alias "MacHD:Fold:etc..."
set itemPath to oneItem as string --> "MacHD:Fold:etc..."
set pathParts to text items of itemPath --> { "MacHD", etc }
if (item -1 of pathParts = "") then --> folder
set itemType to "Folder"
set itemName to item -2 of pathParts
else
set itemType to "File"
set itemName to item -1 of pathParts
end if
set recNum to text 1 thru 2 of itemName
set infoText to itemType & " '" & itemName & "' :" & return
set infoText to infoText & " recNum : " & recNum & return
display dialog (infoText) --> once for each item dropped
end repeat
set text item delimiters to tids
end open
{ Arthur J. Knapp, of <
http://www.STELLARViSIONs.com>
a r t h u r @ s t e l l a r v i s i o n s . c o m
}
_______________________________________________
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.