Skip to content

Core Application Files

Brian Spencer edited this page Jun 3, 2017 · 10 revisions

A Levure application employs at least four core files when it is running: three LiveCode stacks and a YAML text file named app.yml. Each core stack has a file name that you see in your application project folder and a stack name that is used when the stack is open in your application.

File Name Stack Name
standalone.livecode LevureStandalone
levure.livecodescript LevureFramework
app.livecodescript app
app.yml

Let's look at each of these core files:

LevureStandalone

LevureStandalone is the stack name of the standalone.livecode stack file you run to start your application. The standalone file can be either standalone.livecode in development or a standalone executable built from standalone.livecode.

The purpose of LevureStandalone is to load the LevureFramework stack as a behavior. This is why you must always start a Levure application with the standalone. Once LevureFramework is loaded it takes over and handles the application startup from there.

If you like, you can rename LevureStandalone to something else. For example, you could rename it to MyAppStandalone where MyApp is the name of your application.

LevureFramework

The LevureFramework script-only stack has the primary framework functionality. When you start an application with the standalone, LevureFramework is opened as a behavior of LevureStandalone and is put into the message path as a global library with start using. You interact with LevureFramework handlers and functions through the Levure API.

When LevureFramework is first loaded it manages the startup of your application by performing a series of actions:

  1. Load the contents of the app.yml file into an array so its configuration settings are accessible to the framework.

  2. Load app.livecodescript which has the stack name app in memory.

  3. Load any externals specified in app.yml.

  4. Load any helpers specified in app.yml whose preload property is true. Any helper included with the framework is preloaded.

  5. Create application data folders as specified in app.yml.

  6. Dispatch PreloadApplication to the app stack.

  7. Load remaining application assets as specified in app.yml. Extensions, libraries, backscripts, frontscripts are loaded into memory. UI stacks are added to list of stackFiles of the app stack.

  8. Dispatch InitializeApplication to app stack.

  9. Dispatch OpenApplication to app stack.

app

The purpose of the app script-only stack is to allow you to control the startup and shutdown operations for your application. The app stack receives messages from LevureFramework during application startup and shutdown.

During startup, LevureFramework sends app a series of messages. Each message is sent at a different stage of the startup, enabling you to control the timing of your application initialization operations.

PreloadApplication

The PreloadApplication handler in app is where you perform operations that need to happen before your application stacks specified in app.yml are loaded.

InitializeApplication

The InitializeApplication handler in app is where you perform initialization operations that need to happen before your UI stack is opened. At this point all your application stacks specified in app.yml, except for your UI components, are loaded.

OpenApplication

The OpenApplication handler in app is where you open your visible UI stack. Startup and initialization is finished.

PreShutdownApplication

LevureFramework sends app the PreShutdownApplication message before the application shuts down. The PreShutdownApplication handler in app is where you perform any cleanup operations before shutdown.

app.yml

The app.yml file is a YAML text file where you specify all the configuration settings for your application. This file sits alongside the standalone.livecode and app.livecodescript stack files in your app folder. To modify this file for your application, you will use the text editor of your choice.

LevureFramework reads the settings in app.yml into an array when your application first starts up. LevureFramework then uses these settings when loading your application as well as when packaging your application for distribution.

In app.yml you specify your application UI stacks, libraries, helpers, backscripts, and frontscripts to be loaded. You can also specify any extensions and externals to be used and define settings for building and packaging your application distributions.

You can also add your own arbitrary custom settings to the app.yml file. Any settings you add will be available via the levureAppGet() function.


NEXT: Adding to an Application

Clone this wiki locally