Loading Stack Files Into Memory

In my applications I like to verify that all stack files exist on disk when the application launches. If any of the required stack files are missing then I alert the user and quit the application.

Most developers are familiar with using

go [invisible] stack "/path/to/stack"

to load a stack file into memory. But ‘go stack’ actually opens the stack on screen and triggers the [pre]openStack and [pre]openCard messages. You don’t want either to happen if you are just validating stack file existence and loading into memory. Although you can hide the stack and lock messages there is a way that requires less lines of code.

The best way to verify that a stack file exists on disk and load it into memory without triggering any messages or showing it on screen is to do this:

put there is a stack "/path/to/stack" into theStackFileIsLoaded

By checking for the existence of the stack file on disk, Revolution will load the stack into memory. if theStackFileIsLoaded = false then you know the stack file doesn’t exist.

On a somewhat related note check out the Knowing Which Stacks Are In Memory lesson. It has a function that lists all stacks that are currently loaded in memory.

Share

One thought on “Loading Stack Files Into Memory

Leave a Reply

Your email address will not be published. Required fields are marked *