SMX (computer language)
This article may not meet the general notability guideline. Please help to establish notability by adding reliable, secondary sources about the topic. If notability cannot be established, the article is likely to be merged, redirected, or deleted. (June 2009) |
This article is missing citations or needs footnotes. Please help add inline citations to guard against copyright violations and factual inaccuracies. (May 2009) |
SMX (from Server Macro Expansion) is a macro processing language designed to embed macros in web pages. Originally shipped with the popular Internet Factory's Commerce Builder software, it has been ported as an Apache module.
Overview
SMX was designed to embed macros in HTML/XML pages. It originally shipped with the Internet Factory's Commerce Builder software, 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.
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(<dsn>,<query>,%col(1)<br />) 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.
Syntax
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.
Sample code
Hello World
Here is a Hello World code example:
%expand% Hello World!
Using variables to create output
%expand% %set(name,World) Hello %name%!
Forms Processing
%expand% %if(%form(expr) ,<p>Result is: %expr(%form(expr))</p> ) <form action="%client-url%" method=post> Simple math expression: <input name=expr> </form>
Page counter
%expand% %counter(hits) hits
Database guestbook
%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 ,<p>%html-quote(%col(name)) said %html-quote(%col(comment))<hr> <p> <form action="%client-url%" method=post> <br>Name: <input name=name> <br>Comment: <input name=comment> <br><input type=submit> </form> )
External links
- http://www.smxlang.org/ (open source implementation of SMX in C++)
- http://www.gjt.org/javadoc/org/opensmx/opensmx/ (open source implementation of SMX in Java)
- http://www.strom.com/pubwork/iwcb.html (review of the original commerce builder)
If you like SEOmastering Site, you can support it by - BTC: bc1qppjcl3c2cyjazy6lepmrv3fh6ke9mxs7zpfky0 , TRC20 and more...
- Pages with broken file links
- Articles with topics of unclear notability from June 2009
- Articles with invalid date parameter in template
- All articles with topics of unclear notability
- Articles with unsourced statements from May 2009
- All articles with unsourced statements
- Web development software
- Scripting languages
- Macro programming languages