This is an example of a very basic MaxObject   show all code in a single pagee

Structure of a typical MaxObject:

click on the image to jump to code

This is the code for each section    click here to display it in a single page 

 1 - HTML Header for the page

Depending by the header you choose your dynamic web page will behave very differently.

By writing you own header and adding a library of your choice you can change substantially the way the interpreter will behave.
In effects all the difference between DBMax and DBFree is in the library they use.

Libraries are precompiled collections of Xbase code that permit to share code between pages.

Please notice that DBFree doesn't offer the capability of writing your own library as opposite of some version of DBMax.

This is the HTML header to be placed on top of your web page.

It contains the most common HTML statements.

 2 - DBFree header of your choice

Notice the last line: its purpouse is to insert an HTML comment in the final page, visible to browser (while in code view) and useful for debugging.

 

This is the core of DBFree: the header.
3 - basic code for managing webVars

WebVars are stored in a special array of strings (where strings are recorded in pairs in the format name=value) named aVars.

The code here shows how to print on page the content of the array using a FOR..NEXT loop.
The loop has no other practical purpouses and cab be eliminated after debugging.

A MaxObject would be useless without WebVars, that is parameters passed via URL or through a web form (that is the preferred method).
4 - basic code for database connection

This section has nothing special: it is common to any MaxScript page that needs to read and write to a database.

This code shows how to create a table on-the-fly, and should be substituted by your own code.

Here you will connect to your databases
5 - First group of actions
In this sample there are no visible results and the actual code to be executed is demanded to User Defined Functions (located in section 8 at the bottom of page) First set of actions to perform in the background.

 

6 - HTML code for the page

This is the normal HTML content of the page, always visible no matter what action you selected.
In this case it display useful information about the dynamic page and can be removed after debugging.
Body of the page
7 - Second group of actions

Usually you will have a default action (when VAR_ACTION is empty) and one or more action corresponding to different values.

There is no limit to how many branches this tree may have.
Just put the more common action on top to speed up the evaluation.

Only the branch matching the condition is executed: all the rest of the code is ignored, so a MaxObject can count thousands of lines of code without affecting performances.

This is the core of the MaxObject: the tree of the action to be performed.
8 - rest of HTML code
This is the bottom of page, with the HTML code to close the body and eventually some javascript that necessitates to be placed here.
9 - User Defined Functions
and all of your Userd Defined Functions.

UDFs are always read by the interpreter, so if they are expecially heavy can slow down the page a bit.
So avoid to put here UDFs that you don't use.