Home Back

Almost avoiding HTML

For example you can build a web page without even approaching HTML:
Consider this code, which represent a complete page (a single standalone file):
<!DOCTYPE html>
path := mspconfigvar("LIBDIR")            //-- tells where we keep our libraries 
set maxlib to ( path + "\free.lib")       //-- loads the basic DBFREE library 
web()                                     //-- tells DBFREE this page is for the webpreload("/common/header.h",cSeed,"XYZ","pagetitle","DBFree "+wordleft(filebone(pagefile())),".") 
               //-- loads a common HTML header to use with all pages

print( openPage(0) )                       //-- print the default HMTL tags for activating the web page

//-- welcome box
print( poster("/images/wallpaper.jpg") )   //-- opens a side-to-side frame with a background image to the page
   printh( "Hello world!",1,"white" )      //-- superimposes a large text to imnage
print( poster(0) )                         //-- closes the frame

//-- creating a menu using pushbuttons 
//   (the function accepts a link, a description an a number that is for the style and color)
print( button("http://dbfree.org","DBFree",6) )      
print( button("http://dbfree.org","DBFree",7) )
print( button("http://dbfree.org","DBFree",8) )

//-- a web form
print( formStart(cSelf) )                                   //-- this actually starts the form
   print( well() )                                          //-- opens a frame around the form
     print( getStr("EF_NAME","Your name?",1,"Mary") )       //-- creates an entryfield to get a string value
     print( getNum("EF_AGE","Your Age?",0, 44) )            //-- creates an entryfield to get a numeric value
     print( startRadio() )                                  //-- starts a group of radio buttons
         print( radiobutton("EF_GENDER","Male") )           //-- creates a radiobutton
         print( radiobutton("EF_GENDER","Female",1) )       //-- creates a radiobutton which is the default selection
     print( endRadio() )                                    //-- closes the group
     print( formSubmit() )                                  //-- paces a couple of buttons to submit or discard the form
   print( well(0) )                                         //-- closes the frame around the form
print( formEnd() )                                          //-- actually ends the form
print( closePage() )                                        //-- print the default HTML tags for closing the page
The result is this page:

Hello world!

DBFree DBFree DBFree

Programming styles

Did you spotted some HTML (except the first line) in the example above?
Under DBFree this kind of programming style is known as CGI-Style (a.k.a. Retro' mode), and is absolutely legitimate. There are no performance losses, you're not loading meta-layers: you're just using plain MaxScript togheter with a bunch of specialized functions.
For instance the print() function can be shortened to p(), making the code less wordy.

Another example

library := mspconfigvar("LIBDIR")+"\free.lib"
set maxlib to &library
   p( menuTitle("  My new App","/images/dbfreev4-ico.png") ) 
   p( menu(1) ) 
       p( menuitem("#","Home") ) 
       p( submenu("Submenu A") )  
           p( menuitem("#","Option A1") )        
           p( menuDivider() ) 
           p( menuitem("#","Option A2") )        
       p( submenu(0) )               
       p( submenu("Submenu B") )  
           p( menuitem("#","Option B1") )        
           p( menuitem("#","Option B2") )        
       p( submenu(0) )               
   p( menu(0) )   
p( menuBar(0) ) 
p( container(2))
? title("Hello World!")
? "Today is " + fulldate() + " and here time is " + time() 
? subtitle("This would be your page:")
? "Just add some text line by line"
p( btnpopup("http://dbapps.dbfree.org","Or use popup windows") )
? "Or an image:"
? image("/images/DBFree_full_application_scheme.jpg")
? "Maybe resized;"
? image("/images/DBFree_full_application_scheme.jpg",250)
p( container(0))
Gives you this result;

Hello World!

Today is Sunday 24 September 2017 and here time is 19:40:43

This would be your page:

Just add some text line by line

Or use popup windows
Or an image:
<img src="/images/DBFree_full_application_scheme.jpg" style="height:100%">
Maybe resized;
<img src="/images/DBFree_full_application_scheme.jpg" style="height:250px">

Literally build your interface in minutes

The powerful DBFree functions let you build a menu system and the user interface literally in minutes.
You don't even have to rember the exact syntax because DBFree itself can suggest the code for you, by using buildmenu() and buildform() functions.
Just create the pages and link them with something as simple as p( menuitem("/pages/page1.msp","Page 1") ).
Give your pages a consistent look and feel by using include() function togheter with a common template like in p( include("/common/banner.h").

Come to discover DBFree

Just take the Quick Start and have a look at the possibilities of DBFree.
Welcome at home!
Back to top