Community

SCI Programming => SCI Syntax Help => Topic started by: Nostalgic on April 17, 2007, 02:21:17 PM

Title: Public Instances
Post by: Nostalgic on April 17, 2007, 02:21:17 PM
I have a question of clarification.

The tutorial for SCI Studio says that procedures that are made public are available to all scripts.

There's also said to be a public modifier for instances but the tutorial says that this does not allow global access for instances. Rather, it says you would have to store the address of the instance in a global variable.

I'm curious then: what is the purpose of declaring an instance public?
Title: Re: Public Instances
Post by: lskovlun on April 17, 2007, 03:27:09 PM
Public instances are stored in something called an export table inside the script. This makes it possible for other scripts to retrieve a pointer to it by calling the ScriptID kernel function with a script number and export index as arguments. in addition, Sierra's own SCI compiler was able to generate ScriptID calls automatically. It is the lack of the latter feature that makes it necessary (or at least strongly recommended) to use a global variable. I reckon the processing time required by ScriptID was another reason "back in the day".
Title: Re: Public Instances
Post by: Nostalgic on April 17, 2007, 04:26:08 PM
Thank you. This information is very helpful. It's also information I highly doubt I would have come up with on my own, so I really appreciate it.