compiling a script

tflath I was just wondering what happens when you compile a script. Are the commands just translated into shorter codes? How is it all put together? And how does the interpreter read the file?
AGI1122 Well I beleive it turns the compiled code into an assembly like languages. Other than that I don't know much about what happens after you compile it.
Brian_Provinciano In AGI, it is bascily just converted into shorter codes, but not SCI. SCI is very very complicated. It uses a virtual machine which acts just like a PC, or any other computer.

This code...
      = gScore + gScore addScore
      (if(> addScore 0)
Is compiled into this code...
       lsl 15
       lap 1
       sal 15
       lsp 1
       ldi 0
       bnt code_05B0
       pushi 131
       pushi 0
       lofsa $0184
       send 4
Which in binary is...
8B 0F
87 01
A3 0F
8F 01
34 00 00
30 0A 00
38 83 00
39 00
72 D6 FB
4B 04

I doesn't really matter though, that the compiled code is complicated since the langauge I use it easy. The compiler takes care of the hard stuff.

The scripts are object oriented, split into segments. The scripts have references in the vocabs. The interpreter basicly loads the first instance of script.000 and executes it's play() method. From there, it calls other classes, etc. There's more to it than I can simply explain here. I suggest checking out the FreeSCI docs at
tflath Thanks for the help on that. Just a few more things. Once the script is compiled, does the interpreter execute it line for line? Also, is there a practical purpose for having an interpreter? Wouldn't it make more sense to compile the script so it could be run by itself? Thanks
Brian_Provinciano Good questions! :)

The intepreter does execute code line by line, but jumps from class to instance to method to procedures and all over the place, so it could execute 1000 lines of code between one line and another if the line makes a call.

Though it executes line by line, that's not how the programmer sees it. I suppose everything executes line by line no matter how object/event oriented it is. From a programmer's view, code it executed on events. As the programmer, you enter the code executed when the an object is initialzed in the init() method, the code you want to be continually executed in the doit() method, the code that will handle input in the handleEvent() method, etc.

The reason they compiled to scripts rather than actual code is portability. They wrote interpreters to execute the scripts for many platforms. Thanks to Sierra and FreeSCI, if you make a game with SCI Studio, it will be able to run under MS-DOS, Windows, MacOS, Amiga, AtariST, Linux, Solaris, BSD, the handheld iPaq, and more! You as the game developer will only need to compile it once in SCI Studio, and will be able to use it on all of those platforms with the appropriate interpreter.