Open Script: The Future of OWS

By

November 26, 2008

The original version of Open Web Studio 2.0 was released with the standard ListX Script syntax as the default. While the language is flexible and easily used in many applications - it has grown beyond its initial intention. Due to the level of complexity and new functionality of tags and formatters within the solutions that our community has developed, it has become obvious that a more intuitive and user friendly language must be created.

The new language will fullfill the following expectations:

  • Consistent - the structure, similar to the existing ListX
  • Friendly - Wiki Style, also to maintain consistency with the original script language
  • Logical - Top Down, Left to Right parsing to eliminate developer confusion
  • Structured - Easily Nested to eliminate the need for escaping
  • Intuitive - taking flexibility and understanding into consideration, the language must by familiar to all developers and non developers with relatively easy to learn syntax.

With just a few modifications to the existing logic, and some deep thought on the processes - the new language is well underway. The language will follow the expectations, and enhance the usability of the language by making intelligent suggestions within the IDE easy to implement. Without further summary it is best to understand the new syntax structure simply by looking at how it will be used:

General


All syntax elements within the language will be surrounded with square brackets, eliminating the need to know when a square bracket or curly brace should be employed. Additionally the language is now split into two types of tokens (as it was before), values and methods. Values are defined as anything that is being retrieved from a collection. Methods refer to the different types of methodology like If Conditions, Subqueries, Coalesce and others.

Values


Instead of using the original, somewhat dislexic language model for the tokens, we now will identify the collection first, followed by the name or key to use to fetch from within the collection. When a type cast is required, as provided withi the most recent ListX syntax (:number), the as method is to be employed.

ListX:   [test,Querystring]
Open:   [Querystring.test]

ListX:   [test,Querystring:number]
Open:   [Querystring.test.as(number)]
 
ListX:   [myColumn]
Open: [myColumn]
 
ListX:   [myColumn,:number]
Open:   [myColumn.as(number)]
 

Formatting


Formatters provided for ListX will still work universally with Open, the main difference however is that no explicit FORMAT or $ tag will be required. Additionally, many users have found that they use the COALESCE tag at all times since it provides the ability to execute multiple formatters against the value. This will be the default capability provided by the format method. Finally, the as method can be used both before and after the format.

ListX: [FORMAT,test,Querystring,{ENCODEHTML}]
Open: [Querystring.test.format({ENCODEHTML})]
 
ListX: [FORMAT,test,Querystring:number,{left:3}]
Open: [Querystring.test.as(number).format({left:3})]
 

With type casting AFTER the formatter:

Open: [Querystring.test.format({left:3}).as(number)]

For Multiple formatters:

Open: [Querystring.test.format({left:6},{upper},{encodehtml})]

For Multiple formatters with Type Casting:

Open: [Querystring.test.format({left:6},{upper},{encodehtml}).as(number)]

Methods


Due to the previous sections it should be pretty self evident how the other method tokens will be handled. They will follow the same standard structure present within the as method and format method. However, methods can be far more advanced and often require some amount of nested logic. If Condition logic can be a bit obvious for this syntax. When the method is meant to branch like an if condition, the method must be named. The start of the method will contain the method name, and the function call will be the Name that the developer chooses for the code block. To end the method code block, the developer simply places the method followed by its name and .end.

Conditions

ListX: {IIF,"[test,querystring]=1","This is the True Part","This is the False Part"}
Open:
[if.Test( [querystring.test]=1 )]
 
  This is the True Part
[else.Test]
  This is the False Part
[if.Test.end]
 
 

Obviously, this extends the basic functionality, now it supports more than just True and False, and easily provides the ability to embed logic without escaping the syntax.
Open:

[if.myTest( [querystring.test]=1 )]
  This is the True Part 1
[else.if.myTest( [querystring.test]=2 )]
 
  This is the True Part 2
 
[else.if.myTest( [querystring.test]=2 )]
  This is the True Part 3
 
[else.myTest]
  This is the False Part
[if.myTest.end]
 

You could also use the functionality present in Case based condition logic
Open:
[select.a( [querystring.test] )]
  [case.a( 1 )]
  This is the True Part 1
  [
case.a( 2 )]
  This is the True Part 2
  [
case.a( 3 )]
  This is the True Part 3
  [else.a]
  This is the False Part
[select.a.end]

Subquery


ListX: {SUBQUERY, Name="myTest", Query="Select * from Lists" , Header="<ul>", Footer="</ul>", Format="<li>Item:\[EntryID\]</li>"}
Open:
[query.myQ("Select * from Lists")]
   [header]
      <ul>
 
   [header.end]
   [detail]
        <li>Item:[EntryID]</li>
 
   [detail.end]
 
   [footer]
     </ul>
 
   [footer.end]
 
[query.myQ.end]

Or abbreviated:
Open:

[query.myQ("Select * from Lists")]
 
<ul>
 
   [detail]
        <li>Item:[EntryID]</li>
   [detail.end]
 
</ul>
 
[query.myQ.end]
 
 

COALESCE

ListX:
[COALESCE,frmName,Form,Name,Querystring]
Open:
[coalesce([Form.frmName],[Querystring.Name])]
 

 

ListX:
[COALESCE,frmName,Form,Name,Querystring,{left:6},{encodehtml}]
Open:
[coalesce([Form.frmName],[Querystring.Name]).format({left:6},{encodehtml})]

Open:
[coalesce([Form.frmName],[Querystring.Name]).format({left:6},{encodehtml}).as(number)]

 
 

 

Average (1 Ratings):
 
Want to help out?
 
 

New York, NY • Baltimore, MD • Vienna, VA • St. Louis, MO • Seattle, WA • info@openwebstudio.com

Bookmark & Share Bookmark and Share