CAS 6


Scripting String Interpolation for object values

CAS Scripting introduces a new root level "cseval" method simplifying writing complex string concatenation expressions. The method will take the "ToString" value of any evaluated object.

Until now, it was required to use the ToString method of each compatible object before adding or concatenating text to a CharString.

name ← CharString.New 'Application'  
date ← DateStamp.New 0  
list ← StringList.New 'one' 'two' 'three'  
  
out ← CharString.New'' 
out.Add 'The User ' 
out.Add name 
out.Add ' was added on ' 
out.Add date.ToString '' 
out.Add ' with three items; ' 
out.Add list.ToString ','  
out.Show''  

image

This now be accomplished with cseval. Any object placed between braces will be interpolated for the final result of ToString ''.

name ← CharString.New 'Application'       
date ← DateStamp.New 0       
list ← StringList.New 'one' 'two' 'three'    
num ← Numeric.New 123
out ← CharString.New cseval 'The User {name}{num} was added on {date} with three items; {list}.'      
out.Show''

image