Lassoscript syntax has evolved a lot in Lasso 9, but 8.5 syntax is still compatible, if you respect a few rules. The aim of this page is to list the best practices to use when writing Lasso 8.5 code so that it can be run without changes under the new lasso 9 server.
Here is a compilation of all beta testers on the L9 beta mailing list. It's not about deprecated tags, only syntax issues.
Although Lasso 9 can understand the old colon syntax, in some cases it could get confused and output an error. De-colonize your code, now!
field('this')
// instead of
field:'this'
field('price')+'$'
// instead of
field('this')'$'
Session_Start( -Name='cbs', -Expires='120'); //will fail
//instead use :
Session_Start( -Name='cbs', -Expires= 120 );
Avoid using expressions to create local variables names like :
local('menu_'$lang)
//instead use a map like
var('map') = ('menu_en' = 'button', 'menu_fr' = 'bouton')
Please note that this limitation only applies to LOCAL( ) variables, you still can do this with VAR( ) variables.
protect;
handle();
/handle;
.... Then Rest of Code ....
/protect;
There is no solution here, the code has to be upgraded
In Lasso 8.5 you could create an array using
var('test') = (:) ;
In Lasso 9 , this shortcut will create a staticarray type, which cannot grow dynamically
This one can be tricky... If you are using the code below in 8.5 to check for either a field with an empty string or a field with a null value, it will only check for an empty string in 9:
if(field('someField') !='');
To get this to work in both 8.5 and 9, you should explicitly cast the field to a string prior to comparing it. This will leave an empty string as is and convert the null into an empty string. Better syntax :
if(string(field('someField')) != '');
When a reverse lookup doesn't find anything, LP8 returns the IP address while L9 returns null.
array(1,2,3)->join;
This kind of shortcut used to perform an addition integers in an array , in L9 it doesn't anymore. This will output 123 as expected from a concatenation method.
define_tag('x');
return(params->find('-a')->size > 0);
/define_tag;
In LP8 you could search the built-in "params" map when inside a define_tag block by passing the name of the param with its hyphen. In L9, you'll have to remove the hyphen : params->find('-a') for this code to work
This one does not seem to have a workaround : { ... } is the main building block in L9, and this particular syntax in L8 will throw an error.
array(1,2,3)->foreach({
params->first *= 2;
return(true);
})&;
Author: Dominick Guiliano
Created: 12 Feb 2010
Last Modified: 16 Mar 2011
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft