Super Function
From FusionWiki
| Super Function | |
|---|---|
| General Information | |
| Author: | James St. Jean |
| Release Date: | 2006 |
| Status: | Released |
| Last updated: | 2006 |
| Version: | 1.1 |
| Build: | All |
| Developer-only: | No |
| Website: | Author Website |
| Download: | Direct Download |
| Runtime Versions | |
| HWA: | Yes |
| Flash: | No |
| Java: | No |
| Java Mobile: | No |
| Vitalize!: | No |
| Unicode: | No |
Super Function is an extension for Multimedia Fusion 2 written by James St. Jean. Super Function makes it easy to use loops, functions, and global functions in one convenient object. Super Function also exposes convenience functions for expression processing.
Contents |
Features
- Named loops with specified start, stop, and step values. They can count up or down, and can be nested.
- Named Local function calls on the same frame via a single Super Function object instance. Meaning, an object can call local functions on itself. Functions can be nested.
- Named Global function calls to any other named Super Function object, such as inside a sub-application. In theory, global functions can be nested however because they fire out of sequence this should be used with care.
- Expression processing - An alternative to MMF expressions with different capabilities.
- If conditions – If an expression is true do one thing, else another. Useful for computing the target of a function call based on some state in the game.
Expression Parser
This section refers to Super Function's expression processing syntax and capabilities, rather the MMF expressions of the object.
Expressions can use integers, floats, or strings. Integers are assumed when there is no decimal point. To use floats, just include the decimal point. So for example, the expression 1/3 results in the integer 0, while 1.0/3 results in 0.3333. When expressions return TRUE, a value of 1 is returned. For FALSE, 0 is returned. All string values must be included in single quotes. So if you want your expression to return any text, even a single character, it must be included in single quotes. Often this requires placing single quotes within the double quotes of strings within the MMF Expression editor.
A sample IF expression that wanted to use the LIKE function to compare a string variable to see if it contains the name 'Bob' would look like this in the MMF Editor:
IF Expression( "SF", " '"+Edittext$( "NameString" )+"' LIKE 'Bob'", "'The person is Bob'", "'The person is not Bob'")
Note very carefully the locations of the single and double quotes, this is very important if you want to use strings within Super Function Expressions. In this example, it is critical to include the single quote before and after the insertion of the NameString MMF string contents, so the alphanumeric contents of that variable will be processed as a string.
When the contents of a variable in MMF are to be used as a string as shown above with NameString, it is important to consider if the data in that variable may itself contain a single quote character. This occurs with words like can't, wouldn't, and certain names and other common text. If this text were to be surrounded by single quote characters, a syntax error would result as Super Function could not parse it correctly - for example, 'can't' cannot be parsed correctly. Any time a string itself contains a single quote, the quote needs to be repeated as a sequence of two single quotes in order for it to be parsed properly. The string about would have to be 'can''t'. To make this easy, a helper expression is provided with Super Function called Quote(). This will take any input text string and process any single quotes into the appropriate double-quote character, for later feeding into Expression or IF Expression. It can also simplify your MMF expressions, because it will automatically put the leading and trailing single quotes onto your string as well. So using the Quote expression, the example above would now look like:
IF Expression( "SF", Quote( "SF", Edittext$( "NameString" ))+" LIKE 'Bob' , "'The person is Bob'", "'The person is not Bob'")
This new version will now always properly handle names that may contain single quotes. Quote() should be used whenever there is a chance the text may contain a single quote - pretty much any time text is being taken from an MMF input box, string, etc. It will also make your code easier to read.
Refer to Super Function's included documentation for a full list of supported binary operators, functions, and other expression tokens.
Usage
Each instance of Super Function can call its own loops and local functions, to an arbitrary level of nesting. A Super Function object can also call a global function of any other Super Function object. To do this, the target object must define a global function (On Global Function “XXX”) and the caller must invoke that function by specifying the target object and function name.
The object does not provide a function passing structure. With built in MMF2 global data, and multiple other options to share data, this was left off to keep the object interface as simple as possible.
| 1 |
