BlitzMax Extended  0.8.17
Pushing Blitz to the Max.
Functions | Variables
blitz_app.h File Reference

Runtime environment setup and basic application flow functions. More...

#include "_common.h"

Go to the source code of this file.

Functions

void bbEnd ()
 Exits the application.
void bbOnEnd (void(*callback)())
 Registers a callback function to be executed before exiting the application.
BBStringbbReadStdin ()
 Reads a string from the standard input stream.
void bbWriteStdout (const BBString *str)
 Writes a string to the standard output stream.
void bbWriteStderr (const BBString *str)
 Writes a string to the standard error stream.
void bbDelay (BBInt millisecs)
 Delays the application's execution for a given time.
BBInt bbMilliSecs ()
 Gives the number of milliseconds since startup.
BBBool bbIsMainThread ()
 Checks if the current thread is the main one.

Variables

BB_BEGIN_DECLS BBStringbbAppDir
 Contains the absolute path to the executable file's directory.
BBStringbbAppFile
 Contains the absolute path to the executable file.
BBStringbbAppTitle
 Contains the application's title.
BBStringbbLaunchDir
 Contains the directory from which the application was launched.
BBArraybbAppArgs
 Contains the application's arguments.

Detailed Description

Runtime environment setup and basic application flow functions.

Author:
Mark Sibly
Fabian Niemann

Function Documentation

void bbDelay ( BBInt  millisecs)

Delays the application's execution for a given time.

The execution is suspended for at least the given amount of milliseconds. A millisecond is one thousandth of a second. Therefore a delay of 1000 milliseconds would halt execution for (nearly) 1 second.

Note:
If you pass a negative value as a parameter, this function does nothing.
Parameters:
millisecsThe number of milliseconds that the execution should be delayed.
void bbEnd ( )

Exits the application.

Ending the application's execution with this is considered a normal termination, meaning a termination without an error.

On execution all callbacks registered with bbOnEnd are executed in reverse order of their registration. Then after a low-level clean-up, control is returned to the operating system.

BBBool bbIsMainThread ( )

Checks if the current thread is the main one.

Some functionality only works if executed in the main thread. Using this function you can make sure that everything is alright.

Return values:
BBTRUEif called from the current main thread
BBFALSEif called from any other thread
BBInt bbMilliSecs ( )

Gives the number of milliseconds since startup.

The number of milliseconds since the system was turned on is often used to spice up pseudo-random numbers, for example in games.

Returns:
The number of milliseconds since the system's startup
void bbOnEnd ( void(*)()  callback)

Registers a callback function to be executed before exiting the application.

All functions are called in reverse order of their registration. At least 32 callbacks are supported by the system.

Parameters:
callbackThe function to be called on exiting the application
BBString* bbReadStdin ( )

Reads a string from the standard input stream.

This reads as many characters as are needed until a linebreak appears.

Note:
Usually the stdin stream comes from keyboard input
Returns:
The line of text that the user did input
void bbWriteStderr ( const BBString str)

Writes a string to the standard error stream.

After writing the message to the standard error stream (stderr), that stream is immediately flushed. That means the results are handed to the system right away, without waiting for the internal buffer to be filled.

Note:
Usually the stderr stream is the console
Parameters:
strThe message to be written to the standard error stream
void bbWriteStdout ( const BBString str)

Writes a string to the standard output stream.

After writing the message to the standard output stream (stdout), that stream is immediately flushed. That means the results are handed to the system right away, without waiting for the internal buffer to be filled.

Note:
Usually the stdio stream is the console.
Parameters:
strThe message to be written to the standard output stream.

Variable Documentation

BBArray* bbAppArgs

Contains the application's arguments.

All command line arguments passed to the application are stored in this global array as strings.

Note:
If you change the values, consider that other parts of the code might depend on it. If you are unsure, simply copy them.
BB_BEGIN_DECLS BBString* bbAppDir

Contains the absolute path to the executable file's directory.

The path value is automatically filled in at startup.

See also:
bbAppFile
BBString* bbAppFile

Contains the absolute path to the executable file.

The path value is automatically filled in at startup.

See also:
bbAppDir
BBString* bbAppTitle

Contains the application's title.

This global string variable has the default value "BlitzMax Application". It can be changed to the name of the application and is used in a number of ways throughout BlitzMax. One of which is the title of the application's main window. But third-party code might depend on it, so try not to make it too long or there could be problems when displaying it.

BBString* bbLaunchDir

Contains the directory from which the application was launched.

The path value is automatically filled in at startup.