SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
1 
The Road to Damascas– A Conversion Experience: 
LS and @Formula to SSJS 
2014/03/17 –Matthew Fyleman
2 
Matthew Fyleman 
21 Years as a Notes/Domino Developer 
Mostly Working on: 
Xpages conversions 
Product development 
Who Am I?
3 
Based on My Experiences 
Converting LotusScript and @Formula to SSJS 
Tools that can help –particularly regular expressions 
What is this Talk About?
4 
When should you convert existing code? 
Conversion Options 
NotesAgent.run() with parameter doc 
Search and Replace 
Dedicated Tools 
Search and Replace 
Preparation 
Introduction to Regular Expressions 
Examples and Demonstration 
Tips and Traps 
Dedicated Tools 
Questions 
What am I talking about?
5 
Never! 
When should you convert existing code?
6 
What is the problem? 
It is always going to be slow 
GIGO 
You will introduce new bugs 
Re-developing will be quicker, cheaper and you will end up with a better result 
But if you really must ... 
When should you convert existing code?
7 
What are your options? 
NotesAgent.run() 
Quick and Dirty 
Agent must run independently 
Only use when agents are available and time is critical 
Search and Replace 
LotusScript -> JavaScript (and Java) 
Less useful for @Formula 
Dedicated Tools 
@Formula 
Conversion Options
8 
Search and Replace is most useful for LS conversion 
Syntactically similar 
Easiest if you do a little refactoring first 
Option Declare 
doc.field(0) -> doc.getItemValue(“Field“)(0) 
Camel Case Notes Objects 
Make Sure Method calls are consistently named 
Best to Avoid All-In-One-Go 
Function or Sub at a Time 
Variable with one purpose in one location may have a different use elsewhere 
Converting LotusScript to SSJS -Preparation
9 
Regular Expressions are your new BFF 
Sophisticated Pattern Matching 
Elements from search can be carried through to replace 
The Search and Replace built in to DDE can use Regular Expressions 
Useful outside LS conversion (e.g. Validation) 
See Planet Lotus -http://planetlotus.org/profiles/ross-swick_97733 
Regular Expressions
10 
Tidy up first –Option Declare, remove clustering e.g.: 
Dim xas Integer,yas Integer,zas Integer 
We want to match any variable name in the pattern: 
Dim <varname> As <Any valid type> 
Fairly simple: 
Dim[ ]+[A-Za-z0-9_]+[ ]+As[ ]+(Integer|String|Boolean|Double|Variant) 
But how do we replace? 
Modify the search: 
Dim[ ]+([w]*)[ ]+As[ ]+String 
Use this for replace 
var1 = “”; 
Starting Simple –Dim Statements
11 
For Notes Objects, Things are simpler 
Dim <varname> As Notes<rest of object name> 
-Ignore ... As New NotesSessionfor now 
Also, initialising in SSJS, = null is ok: 
var<varname>:Notes<rest of object name> = null; 
So our terms are: 
Search: 
Dim[ ]+([w]*)[ ]+As[ ]+(Notes[w]*) 
Replace: 
var1:2 = null; 
Starting Simple –Dim Statements (2)
12 
For the most part, simple S & R (but order is important): 
End If to} 
[ ]*Thento) { 
Else[ ]+If[ ]*to } else if ( 
If[ ]* to if ( 
But what about: 
If (x = 10) Then 
Use Search: If[ ]+([w()[].<>" ]*)=([w()[].<> "]*)[ ]+Then 
Use Replace: if (1==2) { 
NB: Works but not optimal! 
Other comparison operators not a problem 
A bit more complex –If Statements
13 
The problem: 
Session object is global in ssjs: ‘session’ 
In LS it is created: 
Dim sessAs New NotesSession 
Need to find all LS session objects, and replace with session 
How do you get a list of session object names? 
! –session objects 
You need a coffee!
14 
Java String Object has regexsearch and replace 
String source = “Dim x As String”; 
String result = source.replaceAll(“Dim[ ]+([w]*)[ ]+As[ ]+String”, “var$1 = “”;”); 
Pattern and Matcher objects make this even more powerful 
Pattern p = Pattern.compile(pattern); 
Matcher m = p.matcher(this.source); 
intstartPos= 0; 
while (m.find(startPos)) { 
if (!itemList.contains(m.group(1))) { 
itemList.add(m.group(1)); 
} 
startPos= m.end() + 1; 
} 
Adding Java
15 
Similar Issue to Session 
Need to find all document object names, and replace field handling methods 
Will probably need to handle dot notation 
Arrgghh! 
How do you search for dot notation? 
<doc name>.([^GetItemValue])([0-9]+) 
Still hard work! 
Field Handling
16 
There are other types than string! 
Always review and test converted code thoroughly 
Date handling is a pain 
Script libraries can help here –Java? 
Watch out for User interaction and particularly dialogues 
Work out your strategies in advance! 
Search and Replace –Tips and Traps
17 
In some respects @Formula -> SSJS is easier than LS -> SSJS 
@Formula JavaScript Wrappers help a lot 
Mostly just ‘;’ to ‘,’, and converting lists to arrays 
Some constructions are obvious: 
@SetField(“Field”, Value); 
Goes to: 
doc.replaceItemValue(“Field”, Value); 
Or 
S: @SetField([ ]*([w”]*)[ ]*,[ ]*([w”]*)[ ]*); 
R: doc.replaceItemValue(1, 2); 
But there are some issues ... 
Converting Formula 
@
18 
No direct equivalent in SSJS for *+, *= *>= etc. when applied to Lists 
Need to plan for this 
Java Class/Library to provide direct substitute 
Unfortunately, Java does not permit operator overloading, so has to be a set of methods 
Converting Formula –List Processing 
@!
19 
@If(@Contains(_WFData_neu;_Key);""; 
@Do( 
@Set("_Sachgebiet_Zuordnung";@DbLookup("NOTES":"NOCACHE";"":_ADM$StructureDB;"Workflows";"WFArbeitsanweisung";"Sachgebietzuordnung")); 
@If(_Sachgebiet_Zuordnung = "" | !@Contains(_Sachgebiet_Zuordnung;_Key2);@Do( 
@Prompt([Ok];"Hinweis";"In der System Struktur VBM wurde für das aktuelle Sachgebiet kein Workflow definiert. Das Dokument wird zum ehemaligen Kompetenzträger zurückgegeben, damit dieser ein neues Sachgebiet auswählen kann."); 
@Set("_Kompetenzträger";Bearbeiter1); 
@Set("_tmpintern";5) 
); 
@Do( 
@Prompt([Ok];"Hinweis";"In der System Struktur VBM wurde für das aktuelle Sachgebiet ein neues Sachgebiet konfiguriert. Das Dokument wird zum Kompetenzträger zurückgegeben, damit dieser das neue Sachgebiet auswählen kann."); 
@Set("_neues_Sachgebiet";@Left(@Right(_Sachgebiet_Zuordnung;_key2);"||")); 
@Set("_Elements";@Elements(@Explode(@Left(@Left(@Right(_WFData_neu;"||Sachgebiet#");"||"); _neues_Sachgebiet) + _neues_Sachgebiet; "$" ))); 
@Set("_KompetenzträgerData";@Explode(@Left(@Right(_WFData_neu;"||Kompetenzträger#");"||"); "$")); 
@Set("_Kompetenzträger";@Subset(@Subset(_KompetenzträgerData;_Elements);-1)); 
@Set("_tmpintern";6) 
) 
) 
) 
); 
Converting Formula -@If, @Do and @While 
@!!!
20 
Search and Replace can be used for @Formula -> SSJS ... 
... but it can only take you so far 
A dedicated parser can go further 
Only real alternative to manual translation for complex statements 
Time consuming to create 
Still not a silver bullet 
Parsers
21 
Espresso -http://www.ultrapico.com/Expresso.htm 
Good for learning regex, and serious regexdev 
Free! 
PowerGREP 
Sophisticated regexfile search 
Where regexstarted (UNIX grep)! 
Expensive 
Dedicated Tools
22 
We4IT –www.we4it.com 
OpenNTF–www.openntf.org 
RegexQuick Reference 
http://www.night-ray.com/regex.pdf 
Loads of websites for all aspects of regexdevelopment 
Mastering Regular Expressions –Jeffrey E.F. Friedl– O’Reilly Publishing 
Resources and Information
23 
Questions?
24 
matthew.fyleman@we4it.com

Weitere ähnliche Inhalte

Was ist angesagt?

LinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: IntroLinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: IntroAdam Crabtree
 
What I Love About Ruby
What I Love About RubyWhat I Love About Ruby
What I Love About RubyKeith Bennett
 
Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)Tomer Gabel
 
Java best practices
Java best practicesJava best practices
Java best practicesRay Toal
 
Scala overview
Scala overviewScala overview
Scala overviewdogstar
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesDragos Ionita
 
Javascript built in String Functions
Javascript built in String FunctionsJavascript built in String Functions
Javascript built in String FunctionsAvanitrambadiya
 
Javascript basics
Javascript basicsJavascript basics
Javascript basicsSolv AS
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellBryan O'Sullivan
 
purely_functional_play_framework_application
purely_functional_play_framework_applicationpurely_functional_play_framework_application
purely_functional_play_framework_applicationNaoki Aoyama
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript BootcampAndreCharland
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3Jeremy Coates
 
Querydsl fin jug - june 2012
Querydsl   fin jug - june 2012Querydsl   fin jug - june 2012
Querydsl fin jug - june 2012Timo Westkämper
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 Sumant Tambe
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkEduardo Gonzalez
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5Vance Lucas
 

Was ist angesagt? (19)

LinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: IntroLinkedIn TBC JavaScript 100: Intro
LinkedIn TBC JavaScript 100: Intro
 
What I Love About Ruby
What I Love About RubyWhat I Love About Ruby
What I Love About Ruby
 
Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)Scala Refactoring for Fun and Profit (Japanese subtitles)
Scala Refactoring for Fun and Profit (Japanese subtitles)
 
Java best practices
Java best practicesJava best practices
Java best practices
 
Scala overview
Scala overviewScala overview
Scala overview
 
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 JavaScript - Chapter 9 - TypeConversion and Regular Expressions  JavaScript - Chapter 9 - TypeConversion and Regular Expressions
JavaScript - Chapter 9 - TypeConversion and Regular Expressions
 
Powerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best PracticesPowerful JavaScript Tips and Best Practices
Powerful JavaScript Tips and Best Practices
 
Javascript built in String Functions
Javascript built in String FunctionsJavascript built in String Functions
Javascript built in String Functions
 
Javascript basics
Javascript basicsJavascript basics
Javascript basics
 
The JavaScript Programming Language
The JavaScript Programming LanguageThe JavaScript Programming Language
The JavaScript Programming Language
 
DEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World HaskellDEFUN 2008 - Real World Haskell
DEFUN 2008 - Real World Haskell
 
purely_functional_play_framework_application
purely_functional_play_framework_applicationpurely_functional_play_framework_application
purely_functional_play_framework_application
 
Ajax and JavaScript Bootcamp
Ajax and JavaScript BootcampAjax and JavaScript Bootcamp
Ajax and JavaScript Bootcamp
 
What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3What's new, what's hot in PHP 5.3
What's new, what's hot in PHP 5.3
 
Querydsl fin jug - june 2012
Querydsl   fin jug - june 2012Querydsl   fin jug - june 2012
Querydsl fin jug - june 2012
 
C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012 C++11 Idioms @ Silicon Valley Code Camp 2012
C++11 Idioms @ Silicon Valley Code Camp 2012
 
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and SparkScala Matsuri 2016: Japanese Text Mining with Scala and Spark
Scala Matsuri 2016: Japanese Text Mining with Scala and Spark
 
Building Data Mapper PHP5
Building Data Mapper PHP5Building Data Mapper PHP5
Building Data Mapper PHP5
 
Querydsl overview 2014
Querydsl overview 2014Querydsl overview 2014
Querydsl overview 2014
 

Ähnlich wie Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs

Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Jonathan Felch
 
Modern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsModern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsMike North
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactionstepsum
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeRick Copeland
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side JavascriptJulie Iskander
 
DataWeave 2.0 Language Fundamentals
DataWeave 2.0 Language FundamentalsDataWeave 2.0 Language Fundamentals
DataWeave 2.0 Language FundamentalsJoshua Erney
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescriptDavid Furber
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Michael Renner
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Nilesh Jayanandana
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmersAlexander Varwijk
 
SPCA2013 - SharePoint Nightmares - Coding Patterns and Practices
SPCA2013 - SharePoint Nightmares - Coding Patterns and PracticesSPCA2013 - SharePoint Nightmares - Coding Patterns and Practices
SPCA2013 - SharePoint Nightmares - Coding Patterns and PracticesNCCOMMS
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 
name name2 n2
name name2 n2name name2 n2
name name2 n2callroom
 
name name2 n
name name2 nname name2 n
name name2 ncallroom
 

Ähnlich wie Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs (20)

Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
 
Modern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.jsModern, Scalable, Ambitious apps with Ember.js
Modern, Scalable, Ambitious apps with Ember.js
 
Oracle Objects And Transactions
Oracle Objects And TransactionsOracle Objects And Transactions
Oracle Objects And Transactions
 
Allura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForgeAllura - an Open Source MongoDB Based Document Oriented SourceForge
Allura - an Open Source MongoDB Based Document Oriented SourceForge
 
Introduction to Client-Side Javascript
Introduction to Client-Side JavascriptIntroduction to Client-Side Javascript
Introduction to Client-Side Javascript
 
DataWeave 2.0 Language Fundamentals
DataWeave 2.0 Language FundamentalsDataWeave 2.0 Language Fundamentals
DataWeave 2.0 Language Fundamentals
 
Real life-coffeescript
Real life-coffeescriptReal life-coffeescript
Real life-coffeescript
 
Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014Postgres Vienna DB Meetup 2014
Postgres Vienna DB Meetup 2014
 
Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6Introduction to Ecmascript - ES6
Introduction to Ecmascript - ES6
 
Drupaljam xl 2019 presentation multilingualism makes better programmers
Drupaljam xl 2019 presentation   multilingualism makes better programmersDrupaljam xl 2019 presentation   multilingualism makes better programmers
Drupaljam xl 2019 presentation multilingualism makes better programmers
 
SPCA2013 - SharePoint Nightmares - Coding Patterns and Practices
SPCA2013 - SharePoint Nightmares - Coding Patterns and PracticesSPCA2013 - SharePoint Nightmares - Coding Patterns and Practices
SPCA2013 - SharePoint Nightmares - Coding Patterns and Practices
 
lab4_php
lab4_phplab4_php
lab4_php
 
lab4_php
lab4_phplab4_php
lab4_php
 
ppt7
ppt7ppt7
ppt7
 
ppt2
ppt2ppt2
ppt2
 
name name2 n
name name2 nname name2 n
name name2 n
 
name name2 n2
name name2 n2name name2 n2
name name2 n2
 
test ppt
test ppttest ppt
test ppt
 
name name2 n
name name2 nname name2 n
name name2 n
 
ppt21
ppt21ppt21
ppt21
 

Mehr von ICS User Group

Domino Security Present and Future ConnectED Review - ICS.UG 2016
Domino Security Present and Future ConnectED Review - ICS.UG 2016Domino Security Present and Future ConnectED Review - ICS.UG 2016
Domino Security Present and Future ConnectED Review - ICS.UG 2016ICS User Group
 
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016ICS User Group
 
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016ICS User Group
 
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016ICS User Group
 
Private Cloud Storage - ICS.UG 2016
Private Cloud Storage - ICS.UG 2016Private Cloud Storage - ICS.UG 2016
Private Cloud Storage - ICS.UG 2016ICS User Group
 
Die mobile Herausforderung meistern! - ICS.UG 2016
Die mobile Herausforderung meistern! - ICS.UG 2016Die mobile Herausforderung meistern! - ICS.UG 2016
Die mobile Herausforderung meistern! - ICS.UG 2016ICS User Group
 
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016ICS User Group
 
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016ICS User Group
 
OpenNTF - From Donation to Contribution - ICS.UG 2016
OpenNTF - From Donation to Contribution - ICS.UG 2016OpenNTF - From Donation to Contribution - ICS.UG 2016
OpenNTF - From Donation to Contribution - ICS.UG 2016ICS User Group
 
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...ICS User Group
 
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016ICS User Group
 
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016ICS User Group
 
Die Zukunft spricht Domino! - ICS.UG 2016
Die Zukunft spricht Domino! - ICS.UG 2016Die Zukunft spricht Domino! - ICS.UG 2016
Die Zukunft spricht Domino! - ICS.UG 2016ICS User Group
 
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016ICS User Group
 
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016ICS User Group
 
IBM Digital Experience Overview - ICS.UG 2016
IBM Digital Experience Overview - ICS.UG 2016IBM Digital Experience Overview - ICS.UG 2016
IBM Digital Experience Overview - ICS.UG 2016ICS User Group
 
Watson - Bitte-helfen-Sie - ICS.UG 2016
Watson - Bitte-helfen-Sie - ICS.UG 2016Watson - Bitte-helfen-Sie - ICS.UG 2016
Watson - Bitte-helfen-Sie - ICS.UG 2016ICS User Group
 
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016ICS User Group
 
Beyond XPages ICS.UG 2015
Beyond XPages  ICS.UG 2015Beyond XPages  ICS.UG 2015
Beyond XPages ICS.UG 2015ICS User Group
 
ATLUG comes to you ICS.UG 2015
ATLUG comes to you ICS.UG 2015ATLUG comes to you ICS.UG 2015
ATLUG comes to you ICS.UG 2015ICS User Group
 

Mehr von ICS User Group (20)

Domino Security Present and Future ConnectED Review - ICS.UG 2016
Domino Security Present and Future ConnectED Review - ICS.UG 2016Domino Security Present and Future ConnectED Review - ICS.UG 2016
Domino Security Present and Future ConnectED Review - ICS.UG 2016
 
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
Moving DNUG Usergroup von on-premise in die IBM ConnectionsCloud - ICS.UG 2016
 
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
IBM Notes Traveler & IBM Mobile Connect What's new?, What's next? - ICS.UG 2016
 
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
Warum IBM mit Watson den Büroalltag revolutioniert - ICS.UG 2016
 
Private Cloud Storage - ICS.UG 2016
Private Cloud Storage - ICS.UG 2016Private Cloud Storage - ICS.UG 2016
Private Cloud Storage - ICS.UG 2016
 
Die mobile Herausforderung meistern! - ICS.UG 2016
Die mobile Herausforderung meistern! - ICS.UG 2016Die mobile Herausforderung meistern! - ICS.UG 2016
Die mobile Herausforderung meistern! - ICS.UG 2016
 
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - Verse (&Toscana) - ICS.UG 2016
 
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
Cloud Update 2016 IBM Collaboration Solutions - ConnectionsCloud - ICS.UG 2016
 
OpenNTF - From Donation to Contribution - ICS.UG 2016
OpenNTF - From Donation to Contribution - ICS.UG 2016OpenNTF - From Donation to Contribution - ICS.UG 2016
OpenNTF - From Donation to Contribution - ICS.UG 2016
 
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
Virtual, Faster, Better! How to Virtualize the Rich Client and Browser Plugin...
 
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
Find your data - using GraphDB capabilities in XPages applications - ICS.UG 2016
 
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
XPages on IBM Bluemix: The Do's and Dont's - ICS.UG 2016
 
Die Zukunft spricht Domino! - ICS.UG 2016
Die Zukunft spricht Domino! - ICS.UG 2016Die Zukunft spricht Domino! - ICS.UG 2016
Die Zukunft spricht Domino! - ICS.UG 2016
 
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
Smashdocs - Dokumente gemeinsam schreiben - ICS.UG 2016
 
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
Smashdocs - Collaborative authoring & reviewing - ICS.UG 2016
 
IBM Digital Experience Overview - ICS.UG 2016
IBM Digital Experience Overview - ICS.UG 2016IBM Digital Experience Overview - ICS.UG 2016
IBM Digital Experience Overview - ICS.UG 2016
 
Watson - Bitte-helfen-Sie - ICS.UG 2016
Watson - Bitte-helfen-Sie - ICS.UG 2016Watson - Bitte-helfen-Sie - ICS.UG 2016
Watson - Bitte-helfen-Sie - ICS.UG 2016
 
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
Planung / Terminierung eines Außendienstes mit XPages - ICS.UG 2016
 
Beyond XPages ICS.UG 2015
Beyond XPages  ICS.UG 2015Beyond XPages  ICS.UG 2015
Beyond XPages ICS.UG 2015
 
ATLUG comes to you ICS.UG 2015
ATLUG comes to you ICS.UG 2015ATLUG comes to you ICS.UG 2015
ATLUG comes to you ICS.UG 2015
 

Kürzlich hochgeladen

Mathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptxMathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptxMoumonDas2
 
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Hasting Chen
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfhenrik385807
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Delhi Call girls
 
George Lever - eCommerce Day Chile 2024
George Lever -  eCommerce Day Chile 2024George Lever -  eCommerce Day Chile 2024
George Lever - eCommerce Day Chile 2024eCommerce Institute
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceDelhi Call girls
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝soniya singh
 
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )Pooja Nehwal
 
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkataanamikaraghav4
 
Presentation on Engagement in Book Clubs
Presentation on Engagement in Book ClubsPresentation on Engagement in Book Clubs
Presentation on Engagement in Book Clubssamaasim06
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Pooja Nehwal
 
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara ServicesVVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara ServicesPooja Nehwal
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Vipesco
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfhenrik385807
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...henrik385807
 
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024eCommerce Institute
 
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStrSaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStrsaastr
 
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night EnjoyCall Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night EnjoyPooja Nehwal
 
Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AITatiana Gurgel
 
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptxMohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptxmohammadalnahdi22
 

Kürzlich hochgeladen (20)

Mathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptxMathematics of Finance Presentation.pptx
Mathematics of Finance Presentation.pptx
 
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
Re-membering the Bard: Revisiting The Compleat Wrks of Wllm Shkspr (Abridged)...
 
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdfCTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
CTAC 2024 Valencia - Henrik Hanke - Reduce to the max - slideshare.pdf
 
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
Night 7k Call Girls Noida Sector 128 Call Me: 8448380779
 
George Lever - eCommerce Day Chile 2024
George Lever -  eCommerce Day Chile 2024George Lever -  eCommerce Day Chile 2024
George Lever - eCommerce Day Chile 2024
 
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort ServiceBDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
BDSM⚡Call Girls in Sector 93 Noida Escorts >༒8448380779 Escort Service
 
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
Call Girls in Sarojini Nagar Market Delhi 💯 Call Us 🔝8264348440🔝
 
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
WhatsApp 📞 9892124323 ✅Call Girls In Juhu ( Mumbai )
 
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls KolkataRussian Call Girls in Kolkata Vaishnavi 🤌  8250192130 🚀 Vip Call Girls Kolkata
Russian Call Girls in Kolkata Vaishnavi 🤌 8250192130 🚀 Vip Call Girls Kolkata
 
Presentation on Engagement in Book Clubs
Presentation on Engagement in Book ClubsPresentation on Engagement in Book Clubs
Presentation on Engagement in Book Clubs
 
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
Navi Mumbai Call Girls Service Pooja 9892124323 Real Russian Girls Looking Mo...
 
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara ServicesVVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
VVIP Call Girls Nalasopara : 9892124323, Call Girls in Nalasopara Services
 
Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510Thirunelveli call girls Tamil escorts 7877702510
Thirunelveli call girls Tamil escorts 7877702510
 
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdfOpen Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
Open Source Strategy in Logistics 2015_Henrik Hankedvz-d-nl-log-conference.pdf
 
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
CTAC 2024 Valencia - Sven Zoelle - Most Crucial Invest to Digitalisation_slid...
 
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
Andrés Ramírez Gossler, Facundo Schinnea - eCommerce Day Chile 2024
 
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStrSaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
SaaStr Workshop Wednesday w: Jason Lemkin, SaaStr
 
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night EnjoyCall Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
Call Girl Number in Khar Mumbai📲 9892124323 💞 Full Night Enjoy
 
Microsoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AIMicrosoft Copilot AI for Everyone - created by AI
Microsoft Copilot AI for Everyone - created by AI
 
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptxMohammad_Alnahdi_Oral_Presentation_Assignment.pptx
Mohammad_Alnahdi_Oral_Presentation_Assignment.pptx
 

Icsug conf 14_dev03_xpages-roadtodamascas-lotus-script-and-formula-to-ssjs

  • 1. 1 The Road to Damascas– A Conversion Experience: LS and @Formula to SSJS 2014/03/17 –Matthew Fyleman
  • 2. 2 Matthew Fyleman 21 Years as a Notes/Domino Developer Mostly Working on: Xpages conversions Product development Who Am I?
  • 3. 3 Based on My Experiences Converting LotusScript and @Formula to SSJS Tools that can help –particularly regular expressions What is this Talk About?
  • 4. 4 When should you convert existing code? Conversion Options NotesAgent.run() with parameter doc Search and Replace Dedicated Tools Search and Replace Preparation Introduction to Regular Expressions Examples and Demonstration Tips and Traps Dedicated Tools Questions What am I talking about?
  • 5. 5 Never! When should you convert existing code?
  • 6. 6 What is the problem? It is always going to be slow GIGO You will introduce new bugs Re-developing will be quicker, cheaper and you will end up with a better result But if you really must ... When should you convert existing code?
  • 7. 7 What are your options? NotesAgent.run() Quick and Dirty Agent must run independently Only use when agents are available and time is critical Search and Replace LotusScript -> JavaScript (and Java) Less useful for @Formula Dedicated Tools @Formula Conversion Options
  • 8. 8 Search and Replace is most useful for LS conversion Syntactically similar Easiest if you do a little refactoring first Option Declare doc.field(0) -> doc.getItemValue(“Field“)(0) Camel Case Notes Objects Make Sure Method calls are consistently named Best to Avoid All-In-One-Go Function or Sub at a Time Variable with one purpose in one location may have a different use elsewhere Converting LotusScript to SSJS -Preparation
  • 9. 9 Regular Expressions are your new BFF Sophisticated Pattern Matching Elements from search can be carried through to replace The Search and Replace built in to DDE can use Regular Expressions Useful outside LS conversion (e.g. Validation) See Planet Lotus -http://planetlotus.org/profiles/ross-swick_97733 Regular Expressions
  • 10. 10 Tidy up first –Option Declare, remove clustering e.g.: Dim xas Integer,yas Integer,zas Integer We want to match any variable name in the pattern: Dim <varname> As <Any valid type> Fairly simple: Dim[ ]+[A-Za-z0-9_]+[ ]+As[ ]+(Integer|String|Boolean|Double|Variant) But how do we replace? Modify the search: Dim[ ]+([w]*)[ ]+As[ ]+String Use this for replace var1 = “”; Starting Simple –Dim Statements
  • 11. 11 For Notes Objects, Things are simpler Dim <varname> As Notes<rest of object name> -Ignore ... As New NotesSessionfor now Also, initialising in SSJS, = null is ok: var<varname>:Notes<rest of object name> = null; So our terms are: Search: Dim[ ]+([w]*)[ ]+As[ ]+(Notes[w]*) Replace: var1:2 = null; Starting Simple –Dim Statements (2)
  • 12. 12 For the most part, simple S & R (but order is important): End If to} [ ]*Thento) { Else[ ]+If[ ]*to } else if ( If[ ]* to if ( But what about: If (x = 10) Then Use Search: If[ ]+([w()[].<>" ]*)=([w()[].<> "]*)[ ]+Then Use Replace: if (1==2) { NB: Works but not optimal! Other comparison operators not a problem A bit more complex –If Statements
  • 13. 13 The problem: Session object is global in ssjs: ‘session’ In LS it is created: Dim sessAs New NotesSession Need to find all LS session objects, and replace with session How do you get a list of session object names? ! –session objects You need a coffee!
  • 14. 14 Java String Object has regexsearch and replace String source = “Dim x As String”; String result = source.replaceAll(“Dim[ ]+([w]*)[ ]+As[ ]+String”, “var$1 = “”;”); Pattern and Matcher objects make this even more powerful Pattern p = Pattern.compile(pattern); Matcher m = p.matcher(this.source); intstartPos= 0; while (m.find(startPos)) { if (!itemList.contains(m.group(1))) { itemList.add(m.group(1)); } startPos= m.end() + 1; } Adding Java
  • 15. 15 Similar Issue to Session Need to find all document object names, and replace field handling methods Will probably need to handle dot notation Arrgghh! How do you search for dot notation? <doc name>.([^GetItemValue])([0-9]+) Still hard work! Field Handling
  • 16. 16 There are other types than string! Always review and test converted code thoroughly Date handling is a pain Script libraries can help here –Java? Watch out for User interaction and particularly dialogues Work out your strategies in advance! Search and Replace –Tips and Traps
  • 17. 17 In some respects @Formula -> SSJS is easier than LS -> SSJS @Formula JavaScript Wrappers help a lot Mostly just ‘;’ to ‘,’, and converting lists to arrays Some constructions are obvious: @SetField(“Field”, Value); Goes to: doc.replaceItemValue(“Field”, Value); Or S: @SetField([ ]*([w”]*)[ ]*,[ ]*([w”]*)[ ]*); R: doc.replaceItemValue(1, 2); But there are some issues ... Converting Formula @
  • 18. 18 No direct equivalent in SSJS for *+, *= *>= etc. when applied to Lists Need to plan for this Java Class/Library to provide direct substitute Unfortunately, Java does not permit operator overloading, so has to be a set of methods Converting Formula –List Processing @!
  • 19. 19 @If(@Contains(_WFData_neu;_Key);""; @Do( @Set("_Sachgebiet_Zuordnung";@DbLookup("NOTES":"NOCACHE";"":_ADM$StructureDB;"Workflows";"WFArbeitsanweisung";"Sachgebietzuordnung")); @If(_Sachgebiet_Zuordnung = "" | !@Contains(_Sachgebiet_Zuordnung;_Key2);@Do( @Prompt([Ok];"Hinweis";"In der System Struktur VBM wurde für das aktuelle Sachgebiet kein Workflow definiert. Das Dokument wird zum ehemaligen Kompetenzträger zurückgegeben, damit dieser ein neues Sachgebiet auswählen kann."); @Set("_Kompetenzträger";Bearbeiter1); @Set("_tmpintern";5) ); @Do( @Prompt([Ok];"Hinweis";"In der System Struktur VBM wurde für das aktuelle Sachgebiet ein neues Sachgebiet konfiguriert. Das Dokument wird zum Kompetenzträger zurückgegeben, damit dieser das neue Sachgebiet auswählen kann."); @Set("_neues_Sachgebiet";@Left(@Right(_Sachgebiet_Zuordnung;_key2);"||")); @Set("_Elements";@Elements(@Explode(@Left(@Left(@Right(_WFData_neu;"||Sachgebiet#");"||"); _neues_Sachgebiet) + _neues_Sachgebiet; "$" ))); @Set("_KompetenzträgerData";@Explode(@Left(@Right(_WFData_neu;"||Kompetenzträger#");"||"); "$")); @Set("_Kompetenzträger";@Subset(@Subset(_KompetenzträgerData;_Elements);-1)); @Set("_tmpintern";6) ) ) ) ); Converting Formula -@If, @Do and @While @!!!
  • 20. 20 Search and Replace can be used for @Formula -> SSJS ... ... but it can only take you so far A dedicated parser can go further Only real alternative to manual translation for complex statements Time consuming to create Still not a silver bullet Parsers
  • 21. 21 Espresso -http://www.ultrapico.com/Expresso.htm Good for learning regex, and serious regexdev Free! PowerGREP Sophisticated regexfile search Where regexstarted (UNIX grep)! Expensive Dedicated Tools
  • 22. 22 We4IT –www.we4it.com OpenNTF–www.openntf.org RegexQuick Reference http://www.night-ray.com/regex.pdf Loads of websites for all aspects of regexdevelopment Mastering Regular Expressions –Jeffrey E.F. Friedl– O’Reilly Publishing Resources and Information