Difference between revisions of "SCI Programming Language/Files"
Line 19: | Line 19: | ||
</div><br /> | </div><br /> | ||
− | <div align="center"><span style="font-size: 22pt"> | + | <div align="center"><span style="font-size: 22pt">Files </span><br /> |
''Author: [[Jeff Stephenson]]''</div> | ''Author: [[Jeff Stephenson]]''</div> | ||
| | ||
+ | Source files for the script compiler traditionally have the extension .sc. Header (include) files traditionally have the extension .sh. Message editor header files traditionally have the extension .shm. Source files may have any filename; two examples are banner.sc and castle.sc. The two output files from the compilation will have the names number.scr and number.hep where number is the script# (defined below) of the module. Following are other files (besides the source file and any user-defined header files) which are involved in a compilation. | ||
+ | |||
+ | classdef | ||
+ | This file contains the information about the structure of the classes which have been defined in the application. It is read automatically by the compiler and is rewritten by the compiler after a successful compilation in order to keep it up to date. | ||
+ | |||
+ | selector | ||
+ | This file contains definitions of selectors which are used in object-oriented programming. It is automatically included in a compile and, like classdef, is rewritten after a successful compile. Any symbol in a properties or methods statement or in the selector position in a send to an object is assumed to be a selector and is assigned a selector number included in selector. | ||
+ | |||
+ | system.sh | ||
+ | This contains the definitions for interfacing with the various system classes and procedures. It also contains the system global variable definitions and defines for keycodes, script numbers, etc. It is automatically included in all compiles. | ||
+ | |||
+ | kernel.sh | ||
+ | This contains the definitions for interfacing with the kernel. | ||
+ | |||
+ | game.sh | ||
+ | This is the game-specific header file. It contains global variables, procedure declarations, and definitions for an individual game. It is automatically included in the compile after system.sh. | ||
+ | |||
+ | classes.txt | ||
+ | This is a text file produced by the compiler that is used by a BRIEF macro to browse the SCI class system. | ||
+ | |||
+ | offsets.txt | ||
+ | This is a text file that contains a list of class-selector pairs for frequently used properties. It is used by the compiler to produce 994.voc. | ||
+ | |||
+ | 994.voc | ||
+ | For each class-selector pair in offsets.txt, the compiler writes an entry to this file containing the offset of that property in an SCI object. With this information, the interpreter can access a frequently used property without going through the message-passing mechanism. It is generated by the compiler when the -0 command line parameter is used. | ||
+ | |||
+ | 996.voc | ||
+ | This is the class table. It specifies the number of the script files that contain each class. | ||
+ | |||
+ | 997.voc | ||
+ | This file contains the names of selectors. It is only used by the debugger and in printing error messages. | ||
+ | |||
+ | |||
+ | Page 25 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | $$$sc.lck | ||
+ | This read-only file serves as a semaphore, indicating that a compile is occurring in the current directory. This prevents two compiles from trying to do the same task concurrently (updating the same classdef, for instance). $$$sc.lck is created at the beginning of a compile and deleted at the end. | ||
+ | |||
+ | The following two SCI commands deal with source code organization: | ||
+ | |||
+ | script# | ||
+ | The script# command sets the script number of the output file. | ||
+ | |||
+ | (script# 4) | ||
+ | |||
+ | sets the output file names to 4.scr and 4.hep, regardless of the actual name of the | ||
+ | source file. | ||
+ | |||
+ | include | ||
+ | |||
+ | This includes a header file in the current source file at the current position. | ||
+ | |||
+ | (include "/sc/foo.sh") or (include /sc/foo.sh) | ||
+ | |||
+ | includes the file /sc/foo.sh. Include files may be nested as deeply as desired. | ||
+ | |||
+ | |||
+ | When compiling or including a file, the compiler first looks in the current directory. If it fails to find it there, it next looks for the file in the directories specified in the environment variable sinclude. This variable is just like the DOS path variable. The search directories are separated by semicolons. To set the compiler to look for include files in f:/games/scilsystem and c:/include if it doesn't find them in the current directory, add the line: | ||
+ | |||
+ | set sinclude=f:/games/sci/system;c:/include | ||
+ | |||
+ | to your autoexec.bat file. | ||
+ | |||
+ | |||
+ | Page 26 | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | Compiling SCI Code | ||
+ | |||
+ | The SCI compiler is invoked with the command: | ||
+ | |||
+ | sc filel [file2] [file3] [options] | ||
+ | |||
+ | Any number of file specifications may be entered on the command line, and a file specification may include wild-card names. | ||
+ | |||
+ | Options | ||
+ | |||
+ | -a | ||
+ | Abort compile if the file is already locked. | ||
+ | |||
+ | -d | ||
+ | Include debugging information so that the debugger can display source code. | ||
+ | |||
+ | -D<str> | ||
+ | Create a command line define which has the same result as using the define statement in a source file (except that spaces and some other characters are not permitted). | ||
+ | |||
+ | -g<num> Define maximum number of global or local variables. The default is 750. | ||
+ | |||
+ | -I | ||
+ | Generate an assembly language code listing for the file with the original source interspersed. This is useful when using the built-in debugger of SCI. When compiling filename.sc, the list file is named filename.sl. | ||
+ | |||
+ | -n | ||
+ | Turns off "auto-naming" of objects. As described in the appendix on object-oriented programming, each object has a name property which is used to represent the object textually. Unless the property is explicitly set, the compiler will generate the value for this property automatically, using the object's symbol string for the name. The object names, however, take up space. While they are useful (almost vital) for debugging, if you're running out of memory in a room, it might help to compile with the -n option to leave the names out. | ||
+ | |||
+ | -O | ||
+ | Use offset.txt to generate 994.voc. | ||
+ | |||
+ | -oout-dir | ||
+ | Set the directory for the output files to out-dir. | ||
+ | |||
+ | -s | ||
+ | Display a message when a forward referenced selector is used. | ||
+ | |||
+ | -v | ||
+ | Do not lock the class database. | ||
+ | |||
+ | -w | ||
+ | Output words high-byte first (for the Macintosh). | ||
+ | |||
+ | -z | ||
+ | Turn off optimization. Not a particularly useful option except for those of us who must maintain the compiler. | ||
+ | |||
+ | |||
+ | Page 27 | ||
Revision as of 21:36, 24 May 2016
Source files for the script compiler traditionally have the extension .sc. Header (include) files traditionally have the extension .sh. Message editor header files traditionally have the extension .shm. Source files may have any filename; two examples are banner.sc and castle.sc. The two output files from the compilation will have the names number.scr and number.hep where number is the script# (defined below) of the module. Following are other files (besides the source file and any user-defined header files) which are involved in a compilation.
classdef This file contains the information about the structure of the classes which have been defined in the application. It is read automatically by the compiler and is rewritten by the compiler after a successful compilation in order to keep it up to date.
selector This file contains definitions of selectors which are used in object-oriented programming. It is automatically included in a compile and, like classdef, is rewritten after a successful compile. Any symbol in a properties or methods statement or in the selector position in a send to an object is assumed to be a selector and is assigned a selector number included in selector.
system.sh This contains the definitions for interfacing with the various system classes and procedures. It also contains the system global variable definitions and defines for keycodes, script numbers, etc. It is automatically included in all compiles.
kernel.sh This contains the definitions for interfacing with the kernel.
game.sh This is the game-specific header file. It contains global variables, procedure declarations, and definitions for an individual game. It is automatically included in the compile after system.sh.
classes.txt This is a text file produced by the compiler that is used by a BRIEF macro to browse the SCI class system.
offsets.txt This is a text file that contains a list of class-selector pairs for frequently used properties. It is used by the compiler to produce 994.voc.
994.voc For each class-selector pair in offsets.txt, the compiler writes an entry to this file containing the offset of that property in an SCI object. With this information, the interpreter can access a frequently used property without going through the message-passing mechanism. It is generated by the compiler when the -0 command line parameter is used.
996.voc This is the class table. It specifies the number of the script files that contain each class.
997.voc This file contains the names of selectors. It is only used by the debugger and in printing error messages.
Page 25
$$$sc.lck This read-only file serves as a semaphore, indicating that a compile is occurring in the current directory. This prevents two compiles from trying to do the same task concurrently (updating the same classdef, for instance). $$$sc.lck is created at the beginning of a compile and deleted at the end.
The following two SCI commands deal with source code organization:
script# The script# command sets the script number of the output file.
(script# 4)
sets the output file names to 4.scr and 4.hep, regardless of the actual name of the source file.
include
This includes a header file in the current source file at the current position.
(include "/sc/foo.sh") or (include /sc/foo.sh)
includes the file /sc/foo.sh. Include files may be nested as deeply as desired.
When compiling or including a file, the compiler first looks in the current directory. If it fails to find it there, it next looks for the file in the directories specified in the environment variable sinclude. This variable is just like the DOS path variable. The search directories are separated by semicolons. To set the compiler to look for include files in f:/games/scilsystem and c:/include if it doesn't find them in the current directory, add the line:
set sinclude=f:/games/sci/system;c:/include
to your autoexec.bat file.
Page 26
Compiling SCI Code
The SCI compiler is invoked with the command:
sc filel [file2] [file3] [options]
Any number of file specifications may be entered on the command line, and a file specification may include wild-card names.
Options
-a Abort compile if the file is already locked.
-d Include debugging information so that the debugger can display source code.
-D<str> Create a command line define which has the same result as using the define statement in a source file (except that spaces and some other characters are not permitted).
-g<num> Define maximum number of global or local variables. The default is 750.
-I Generate an assembly language code listing for the file with the original source interspersed. This is useful when using the built-in debugger of SCI. When compiling filename.sc, the list file is named filename.sl.
-n Turns off "auto-naming" of objects. As described in the appendix on object-oriented programming, each object has a name property which is used to represent the object textually. Unless the property is explicitly set, the compiler will generate the value for this property automatically, using the object's symbol string for the name. The object names, however, take up space. While they are useful (almost vital) for debugging, if you're running out of memory in a room, it might help to compile with the -n option to leave the names out.
-O Use offset.txt to generate 994.voc.
-oout-dir Set the directory for the output files to out-dir.
-s Display a message when a forward referenced selector is used.
-v Do not lock the class database.
-w Output words high-byte first (for the Macintosh).
-z Turn off optimization. Not a particularly useful option except for those of us who must maintain the compiler.
Page 27
- Notes
< Previous: Table of ContentsNext: Files >