RE: [Newbie Q] How to implement toggle switch?
RE: [Newbie Q] How to implement toggle switch?
- Subject: RE: [Newbie Q] How to implement toggle switch?
- From: email@hidden
- Date: Fri, 7 Jun 2002 04:05:57 EDT
Based on the code you posted (shown at bottom), it would seem an appropriate
time to teach yourself about (a) handlers (called subroutines or functions or
libraries in other programming languages), and possibly (b) recursion.
A handler is a reusable snipped of code that resides at the bottom of the
AppleScript in it's own block, and is called as needed, being passed
information and returning information.
Examples:
----------------+----------------+----------------+----------------+
-- HANDLER b IsFolder (reference using "my IsFolder(variable_fullpath)"
-- Purpose: Determines if the current file is a folder (returns boolean)
-- Expected Input: String or alias of path&filename
-- Returns Output: Boolean, TRUE or FALSE
-- Calls NO other handlers
----------------+----------------+----------------+----------------+
local ValueForReturn -- boolean, Is path pointing at a folder?
-- local IAmAFolder -- boolean, value from file record's folder attribute
local TheRecordContents -- record, the complete contents of the file record
-- local LocalCopyOfFullItemPathAndName
-- string, a local copy of the FullItemPathAndName coerced into string
on IsFolder(FullItemPathAndName)
set TheRecordContents to (get info for (FullItemPathAndName)) as list
-- item 7 in the list will be TRUE if it is a folder, FALSE if it is not
(boolean)
set ValueForReturn to (item 7 of (TheRecordContents)) as boolean
-- returns true or false as boolean, whether the item passed in is a
folder.
return ValueForReturn as boolean
end IsFolder
Another Example:
----------------+----------------+----------------+----------------+
-- HANDLER b PassInfoToDVD (reference using "my PassInfoToDVD(Path)" )
-- NOTE: I HAVE NOT TESTED THIS CODE FOR VALIDITY; MAY NOT RUN.
-- Purpose: Plays DVD at location PathNow
-- Expected Input: Alias of path&filename
-- Returns Output: NONE
-- Calls NO other handlers
----------------+----------------+----------------+----------------+
PassInfoToDVD(PathNow)
tell application "DVD Player"
open VIDEO_TS of (PathNow)
set viewer visibility to true
set title to [variable of title]
play dvd
set LengthNow to length of title
repeat until (time remaining = 0)
end repeat
stop dvd
end tell
end PassInfoToDVD
Hope that helps you. Can't do anything about the other questions, as I've
never scripted the DVD Player under OS X, and don't use AS Studio.
=-= Marc Glasgow
In a message dated 6/7/02 1:33:13 AM,
email@hidden writes:
>
tell application "DVD Player"
>
open VIDEO_TS of (PathNow)
>
set viewer visibility to true
>
set title to [variable of title]
>
play dvd
>
set LengthNow to title length
>
repeat until remaining time = (LengthNow - LengthNow)
>
end repeat
>
stop dvd
>
end tell
>
>
(* going to the next title*)
>
>
set PathNow to "[another certain path]" as alias
>
tell application "DVD Player"
>
open VIDEO_TS of (PathNow)
>
set title to [next variable of title]
>
play dvd
>
set LengthNow to title length
>
repeat until remaining time = (LengthNow - LengthNow)
>
end repeat
>
stop dvd
>
(* and so on *)
_______________________________________________
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.