Lasso programming language
Encyclopedia
Lasso Professional combines an interpreted
Interpreter (computing)
In computer science, an interpreter normally means a computer program that executes, i.e. performs, instructions written in a programming language...

 programming language
Programming language
A programming language is an artificial language designed to communicate instructions to a machine, particularly a computer. Programming languages can be used to create programs that control the behavior of a machine and/or to express algorithms precisely....

 and server
Server (computing)
In the context of client-server architecture, a server is a computer program running to serve the requests of other programs, the "clients". Thus, the "server" performs some computational task on behalf of "clients"...

 for developing internet
Internet
The Internet is a global system of interconnected computer networks that use the standard Internet protocol suite to serve billions of users worldwide...

 applications
Application software
Application software, also known as an application or an "app", is computer software designed to help the user to perform specific tasks. Examples include enterprise software, accounting software, office suites, graphics software and media players. Many application programs deal principally with...

 which use web browser
Web browser
A web browser is a software application for retrieving, presenting, and traversing information resources on the World Wide Web. An information resource is identified by a Uniform Resource Identifier and may be a web page, image, video, or other piece of content...

s for the client user interface to connect to HTTP and database
Database
A database is an organized collection of data for one or more purposes, usually in digital form. The data are typically organized to model relevant aspects of reality , in a way that supports processes requiring this information...

 servers. Lasso is developed by LassoSoft Inc.

Explanation

Lasso provides administration management over Lasso (via its internal users and groups) to control explicit access permissions-based to data sources and language features to improve security and data integrity in a multi-author web application development environment. Lasso Server provides access to MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

 and many other databases via JDBC, ODBC, and FileMaker Pro. Lasso Server runs on Mac OS X
Mac OS X
Mac OS X is a series of Unix-based operating systems and graphical user interfaces developed, marketed, and sold by Apple Inc. Since 2002, has been included with all new Macintosh computer systems...

, Windows 2000
Windows 2000
Windows 2000 is a line of operating systems produced by Microsoft for use on personal computers, business desktops, laptops, and servers. Windows 2000 was released to manufacturing on 15 December 1999 and launched to retail on 17 February 2000. It is the successor to Windows NT 4.0, and is the...

, Windows 2003 and Red Hat Linux
Red Hat Linux
Red Hat Linux, assembled by the company Red Hat, was a popular Linux based operating system until its discontinuation in 2004.Red Hat Linux 1.0 was released on November 3, 1994...

.

Lasso's language, Lasso Dynamic Markup Language (LDML), can be written in a square bracket tag format which resembles HTML
HTML
HyperText Markup Language is the predominant markup language for web pages. HTML elements are the basic building-blocks of webpages....

, or in a LassoScript format similar to many other scripting languages such as PHP
PHP
PHP is a general-purpose server-side scripting language originally designed for web development to produce dynamic web pages. For this purpose, PHP code is embedded into the HTML source document and interpreted by a web server with a PHP processor module, which generates the web page document...

, Perl
Perl
Perl is a high-level, general-purpose, interpreted, dynamic programming language. Perl was originally developed by Larry Wall in 1987 as a general-purpose Unix scripting language to make report processing easier. Since then, it has undergone many changes and revisions and become widely popular...

, and Python
Python (programming language)
Python is a general-purpose, high-level programming language whose design philosophy emphasizes code readability. Python claims to "[combine] remarkable power with very clear syntax", and its standard library is large and comprehensive...

. LDML can be written with procedural or object-oriented
Object-oriented programming
Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...

 techniques and structures, and supports many data types including arrays (indexed lists) and maps (name referenced lists).

Lasso is an extendable language. It currently includes the ImageMagick
ImageMagick
ImageMagick is an open source software suite for displaying, converting, and editing raster image files. It can read and write over 100 image file formats. ImageMagick is licensed under the Apache 2.0 license.- Features and capabilities:...

 suite of image manipulation tools, the ability to generate PDF documents and process and send email. Lasso also includes broad support for industry standards such as XML
XML
Extensible Markup Language is a set of rules for encoding documents in machine-readable form. It is defined in the XML 1.0 Specification produced by the W3C, and several other related specifications, all gratis open standards....

, SOAP
SOAP
SOAP, originally defined as Simple Object Access Protocol, is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks...

, WSDL
Web Services Description Language
The Web Services Description Language is an XML-based language that is used for describing the functionality offered by a Web service. A WSDL description of a web service provides a machine-readable description of how the service can be called, what parameters it expects and what data structures...

, JSON
JSON
JSON , or JavaScript Object Notation, is a lightweight text-based open standard designed for human-readable data interchange. It is derived from the JavaScript scripting language for representing simple data structures and associative arrays, called objects...

, Java EE, and Java Beans. Lasso can be extended by writing custom routines which can be used and reused as custom tags or create new functionality via Java
Java (programming language)
Java is a programming language originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language derives much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities...

 or C
C (programming language)
C is a general-purpose computer programming language developed between 1969 and 1973 by Dennis Ritchie at the Bell Telephone Laboratories for use with the Unix operating system....

 programming languages to suit many needs.

Data source abstraction

The Lasso language provides the ability to create dynamic web sites or applications with data source abstraction. The language allows programming in such a manner as to be independent of coding for a specific data source. This lets files, sites and applications created with the language be ported from data source to data source with minimal or no changes. This level of abstraction is achieved by the language being interpreted.

Data sources are configured within the Lasso administration system, setting permissions, connection parameters and other relevant settings. Aliases can be set for data sources, which allows for the abstraction.

Example 1 - Transitioning data sources

The data source for www.foo.com is the FileMaker
FileMaker
FileMaker Pro is a cross-platform relational database application from FileMaker Inc., formerly Claris, a subsidiary of Apple Inc. It integrates a database engine with a GUI-based interface, allowing users to modify the database by dragging new elements into layouts, screens, or forms...

 database foo_facts.

Within the Lasso administration system, the alias name info is created for the foo_facts database. Within given Lasso code, the call for data is made to 'info' using the Lasso data manipulation tags.

Lasso receives the call to 'info' as an instruction to retrieve data from the foo_facts database and generates a valid FileMaker
FileMaker
FileMaker Pro is a cross-platform relational database application from FileMaker Inc., formerly Claris, a subsidiary of Apple Inc. It integrates a database engine with a GUI-based interface, allowing users to modify the database by dragging new elements into layouts, screens, or forms...

 request. The data is returned and is presented to the end user per the developer's code. At a later date, the administrators of the www.foo.com website choose to switch a MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

 database.

To accommodate this transition, the Lasso administration system is modified by pointing the alias 'info' to the new MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

 database. If it is given that all of the Lasso programmed pages used the Lasso language exclusively (no proprietary tags or functions), then no further adjustments are required. Lasso now interprets calls to 'info' as requests for data from the MySQL
MySQL
MySQL officially, but also commonly "My Sequel") is a relational database management system that runs as a server providing multi-user access to a number of databases. It is named after developer Michael Widenius' daughter, My...

 database and casts the requests as MySQL statements.

Example 2 - Portability

Developers maintains local and remote copies of the same data source. The local data source is labeled dev_foo. The remote data source is labeled foo. In the Lasso administration system on both the local and remote servers the data source is known by the alias info. The developer calls the data source info within the code on the Lasso pages. The Lasso server interprets the call to info based on the settings with in the Lasso administration system. Pages created by the developer, therefore, can be moved between the local and remote servers without need for server-specific coding and the developer is able to maintain independent local and remote data sources, ensuring data fidelity and security.

Security

The Lasso language provides a multi-layer security approach. This allows setting security parameters via a broad range of factors.

These include:
  • Database Security
  • File Security
  • Access Security
  • Session Security


Please refer to the LassoSoft website for a further description of the Lasso security system.

Hello World

Here are three ways to say "Hello world!" on a Lasso page. The last one is of course the easiest.



['Hello world!']

Hello world!

Square brackets are reserved in Lasso, so you have to use html entities if you want to use square brackets on Lasso pages for other purposes than marking Lasso tags. Alternatively, you can print square brackets using Lasso itself or disable them by including [no_square_brackets] at the top of the file.

Inlines


// Find all records in a table
inline(
-database='db_name',
-table='table_name',
-findall
) => {
// Iterate through and process each row
rows => {
// Output each row to the current web request
content_body += '' + column('title') + ''
}
}


Inlines are the basic Lasso tool for database actions. Database commands can be issued as above, in Lasso's db-independent metalanguage, in which case the same search code works for MySQL, FileMaker Pro or for any other database backend with which Lasso can connect. This greatly enhances the portability of Lasso solutions.

If needed, a SQL
SQL
SQL is a programming language designed for managing data in relational database management systems ....

statement can of course be embedded in the inline when using a database server that supports SQL:


// Execute SQL statement
inline(
-database='db_name',
-sql = 'SELECT * FROM table_name'
)...


Note that in the above example, the dashes (-) before commands denote optional parameters — optional parameters can be specified in any order and can be generated dynamically (the last of any duplicate parameters take precedence). The inline command supports a large range of parameters allowing the developer to interact with databases that they may not have intimate knowledge of.

Developers can also create their own database connectors which allows for leveraging of the abstracted nature of the inline command.

99 Bottles of Beer

The next procedural example prints out the lyrics for the song "99 Bottles of Beer".


// Define a couple of useful methods

define br => '
'
define bottles(n::integer) => #n != 1 ? ' bottles' | ' bottle'

// Declare the local that will store the lyrics as a string

local(out = )

// Use Lasso query syntax to generate the lyric

with n in 99 to 1 by -1 do {

#out += #n + bottles(#n) + ' of beer on the wall, ' + br
#out += #n + bottles(#n) + ' of beer; ' + br
#n--
#out += 'Take one down, pass it around, ' + br
#out += #n + bottles(#n) + ' of beer on the wall. ' + (br * 2)
}

// Output result

#out


The next example uses an OOP approach to print out the lyrics when the object is represented as a string:



// Define type
define bottles_of_beer => type {

// Define internal data
data private bottles = 99

// Define private methods
private br => '
'
private s => .bottles != 1 ? 's' |

// Generate lyrics when object represented as a string
public asstring => {

local(out = )

// Use Lasso query syntax to generate the lyrics
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK