F-Script Execution Context Overview

 

Introduction

The F-Script Execution Context plug-in executes services that are implemented in the F-Script language. The plug-in uses its own copy of F-Script, and each service is executed in its own instance of the F-Script interpreter.

Although F-Script provides an almost full bridge to the Cocoa frameworks, the plug-in still provides three custom Bellhop-specific classes that you can invoke from your F-Script services. These classes are provided to parallel those in the Ruby and Python plug-ins. The three classes are Pasteboard, Panel and Finder. Each class provides a set methods that you can invoke from your F-Script services to manipulate pasteboard data, interact with users and manipulate files and folders.

The custom Bellhop classes are automatically available to your F-Script services. You can access them without having to import or include them into your scripts.

 

Basic Syntax

F-Script services must contain a run block at the top level of the F-Script environment. The name of this block should be runService and it should take a single string argument that specifies the name of the pasteboard instance responsible for a service transaction. The listing below shows the basic structure of an F-Script service.

runService := [ :aPasteboard | " * Put your custom F-Script code here in the runService block. * It will automatically be invoked when a user selects the * service from the menu." ]

The aPasteboard argument will be a string that specifies the unique pasteboard name for the service transaction, and is automatically passed to the block by Bellhop.

You are not required to explicitly load any Bellhop classes into your scripts; they are automatically loaded when the F-Script environment is initialized. You can also message almost any Cocoa class or object if you wish. For example, your services can make use of the Foundation framework classes such as NSString, NSArray, etc. F-Script also provides access to QuickTime, CoreData, plus many more Mac OS X technologies.

For a more detailed F-Script example, see the Example section of this document.

 

Bellhop-specific F-Script Classes

As metioned above, the Bellhop F-Script plug-in provides three custom classes that provide a similar API as those defined in the Ruby and Python plug-ins. Although all of the functionality provided by these classes can be directly accessed via the Cocoa frameworks, they are provided to allow you to write services with a similar structure as those in the Ruby and Python plug-ins.

The three custom classes that you can use in your services are Pasteboard, Panel and Finder. The Pasteboard class provides class methods that allow you to interact with the system pasteboard, which is used to pass data between the requesting application and your service. You can also use the Pasteboard class to write data to the standard clipboard. The Panel class provides class methods that display user interface panels to users. There are panels to display alerts, prompt panels that allow your services to accept user input, and file selection and save panels. The Finder class has class methods that allow you to do basic file manipulation, such as copy, move and delete files, as well as ask the Finder to open files, urls and applications.

For a complete description of the various modules, see the Reference section of this document.