SMX

From Wikipedia, the free encyclopedia

For the airport in Santa Maria, California coded SMX, see Santa Maria Public Airport

SMX is a macro processing language originally shipped with the Internet Factory's Commerce Builder software. This was a relatively popular web server in the early days of the internet, due to the ease with which a developer could produce an e-commerce website.

Rather than re-implement websites in more popular languages, like Perl or PHP, a small group of SMX fans decided to re-implement the language itself as an Apache module.

SMX was designed to embed macros in HTML/XML pages.

A good example of a macro is %counter(). This embeds a simple incremental counter on an HTML page. To include the results of a SQL query on a page, you can simply type %sql(,,%col(1)
)
in the middle of an XHTML page.

Owing to the high-level nature of the language, SMX can greatly reduce the programming effort required to build dynamic or database-driven web sites.


Contents

Unlike many programming languages, SMX syntax is simple and consistent. All functions begin with a % sign, followed by the name of the function, followed either a single % sign or a parenthetical list of arguments.

Arguments can be quoted using double-quotes. Backslashes can be used to escape commas and double-quotes. A single quote at the beginning of an argument turns off interpretation of code in that argument (similar to LISP).

Everything that isn't code, is, by default, output. To change this behavior, use the %nil or %null macros.

Here is a Hello World code example:

%expand%
Hello World!

Using variables to create output

%expand%
%set(name,World)
Hello %name%!

%expand%
%if(%form(expr)
    ,

Result is: %expr(%form(expr))

)
Simple math expression:

%expand%
%counter(hits) hits


%expand%
%if(%not(%exists(/tmp/gbook.sq3))
        ,%sql(sqlite:/tmp/gbook.sq3,create table guests (name text, comment text))
)
%if(%and(%form(name),%form(comment))
    ,%sql(sqlite:/tmp/gbook.sq3,"insert into guests (name, comment) values (%sqlq(%form(name)),%sqlq(%form(comment)))")
)
%sql(sqlite:/tmp/gbook.sq3,select * from  guests
        ,

%html-quote(%col(name)) said %html-quote(%col(comment))


)


Name:
Comment:

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.