StepTalk tools

From GNUstepWiki
Jump to navigation Jump to search

Script executor

The StepTalk Shell

!! StepTalk Shell

StepTalk shell is a handy tool for interactive scripting with GNUstep objects. The real name of the tool is stshell.

Important notice: The stshell tool is not built by default by StepTalk, because it requires extra library called libreadline.

After launching the stshell it will greet you by:

Welcome to the StepTalk shell.
StepTalk > _

First steps with the shell

Try following examples, line by line

1 + 1.
NSDate date.
(NSHost hostWithName:'www.gnustep.org') addresses

Tab Completion

StepTalk Shell can do TAB completion of variable names, class names and selectors. Press <TAB> where indicated:

NSFileMa<TAB> defa<TAB>Ma<TAB> curr<TAB>Di<TAB>P<TAB>

Getting Help

Problem Example
Get a class of an object 'aString' class
List methods that an object can respond to
(superclass methods are not included)
'aString' methodNames
List class methods NSString methodNames
List instace methods NSString instanceMethodNames
Find a selector Runtime selectorsContainingString: 'init'
Find implementors Runtime implementorsOfSelector: #compare:

AppKit

To use AppKit clases, execute the shell by:

$ stshell -env AppKit

or load the module at the runtime:

> Environment loadModule:'AppKit'

How to get a filename using the Open panel?

NSOpenPanel openPanel runModal ; filename

Create a Workspace object for further experiments

Workspace := NSWorkspace sharedWorkspace

Launch an application:

Workspace launchApplication:'Ink'

Open a file

Workspace openFile:'file name'

or

Workspace openFile:(NSOpenPanel openPanel runModal ; filename)

Unix Shell Equivalents

For Unix commands equivalets, refer to the Unix.txt file in the Shell source directory.


See also: StepTalk