Suppose you want DirectoryView to display the contents of a file directory. To do this, it needs a script that does the following:
Adding a pool dictionary
This script uses information in the pool dictionary CfsConstants of the Smalltalk class CfsFileDescriptor. So the script can use the information, change the definition for the DirectoryView class as follows:
AbtAppBldrView subclass: #DirectoryView instanceVariableNames: '' classVariableNames: '' poolDictionaries: 'CfsConstants'
Adding the script
Next, add the script:
messagePattern "comment" | temporaries | statements
getFilesFromDir: aDir to: aCollection "Instance, public - Get file names from the specified directory and list the names in the list box. Mode information comes the CfsConstants pool dictionary. 'slash' defines a \ for OS/2 and Windows. For UNIX, 'slash' defines a /." | dd entry slash | aCollection removeAll: aCollection. (aDir == nil or: [aDir isEmpty]) ifTrue: [^self]. dd := CfsDirectoryDescriptor opendir: aDir pattern: '*.*' mode: FREG | FDIR | FSPECIAL. (dd isCfsError) ifTrue: [^self]. entry := dd readdir. slash := CfsDirectoryDescriptor pathSeparator asString. [entry == nil] whileFalse: [ aCollection add: (aDir,slash,(entry dName)). entry := dd readdir.]. (self subpartNamed: 'Multiple Select List1') items: aCollection.
If Undefined or a similar phrase is shown, ensure that you've typed in the code given above.
You can copy code from this help panel to the clipboard by selecting Copy from the Edit menu of the browser window. Then paste it into the Script Editor by selecting Paste from the pop-up menu of the lower pane. (After you delete all text except for the script, pop up the menu and select Save.)
Go to Example: Connect the script to see what connections you make to the script to run DirectoryView.