SlideShare a Scribd company logo
Everything you ever
wanted to know about
Lotuscript
Bill Buchan
hadsl
Thursday, 22 March 12
Who am I?
• Bill Buchan, CEO of hadsl - one of the
sponsors of this show
• Come visit the booth - we don’t bite
• Dual PCLP in v3, v4, v5, v6, v7, v8, and v8.5
• Enterprise-level consultant on Domino
since 1995
Thursday, 22 March 12
Agenda
• What is LotusScript? Where is it going?
• LotusScript Basics
• LotusScript Advanced
• Web Services
Thursday, 22 March 12
What is LotusScript
• LotusScript is:
• A p-code partially compiled, partially
interpreted language
• Syntactically identical toVisual Basic 3
• In most Notes Applications.
Thursday, 22 March 12
What is LotusScript
• LotusScript
• is old. It was introduced with Notes v4,
and was first implemented in Ami Pro
• Supports Object Orientated techniques
• Is fast, scalable, robust
• Is Multi-Platform
Thursday, 22 March 12
Where is it going?
• Number of LotusSphere 2012 sessions that
mentioned LotusScript: one
• No language modifications since Notes v4.6
• (Every version has had class extensions
to support some new version features)
• Its fair to say that it is not considered a
priority for Lotus
Thursday, 22 March 12
So why are we here?
• I wanted to give you a single session that
covered everything I knew about
LotusScript
• We still have to maintain applications
Thursday, 22 March 12
Agenda
• What is LotusScript? Where is it going?
• LotusScript Basics
• LotusScript Advanced
• Web Services
Thursday, 22 March 12
Basics: How to code
• Code for maintenance.
• You will change this code.This code will
run for 10+ years. Unchanged.
• Log everything.
• If the users find out before you, you’ve
lost.
• Good log information means faster
debugging
Thursday, 22 March 12
Basics: How to code
• Bugs cost money.The closer to production,
the more expensive they are. More testing
and debugging and logging costs less
• Isolate business logic from display logic.
Your look and feel WILL change
• Simplicity is cheap
Thursday, 22 March 12
Basics: Option Declare
• You should use ‘Option Declare’ when
possible.Why?
• Not using Option declare, and not
declaring your variables in advance,
makes every variable aVARIANT
• Variants move all errors to run-time
• Variants are slower to use.
Thursday, 22 March 12
Basics: lsi_info
• LSI_Info was a student intern project, and is
a global variable created and maintained by
the LotusScript environment
• It contains lots of ‘interesting’ values
• Superseded by getThreadInfo
• Its not thread-safe. Heavily loaded servers
may crash if its accessed.
Thursday, 22 March 12
Basics: lsi_info
• lsi_info(10) gives the calling class
• lsi_info(11) gives the calling function.
• So we can write a pretty cool error
handler..
Thursday, 22 March 12
Function RaiseError()
Dim thisType As String Dim es as String
thisType = Typename(Me)
' Not a class, use the calling module instead
If (thisType = "") Then thisType = Getthreadinfo(11)
es = thisType & "::" & Getthreadinfo(10) & ": "
If (Err = 0) Then
es = es + "Manually raised an error"
Else
es = es + "Run time error: (" + Trim(Str(Err)) + ") "
+ _
Error$ + " at line: "+ Trim(Str(Erl)) End If
Print es
end function
' calling code...
ExitFunction:
exit function
errorhandler:
Call RaiseError()
resume exitFunction
end function
Thursday, 22 March 12
Basics. NotesSession
• This piece of code:
dim s as new NotesSession
• Doesn’t actually create anything. It just
references the same global NotesSession
object, built in advance
• No performance hit for declaring it
(But that doesn’t excuse bad code!)
Thursday, 22 March 12
Basics:AdminP
• AdminP documents have
special fields for ReplicaID
• Stored as Notes Date/
Time fields
	 Dim dt As New NotesDateTime(targetDatabase.ReplicaID)
	 Call doc.replaceItemValue("ProxyReplicaID", dt)
Thursday, 22 March 12
Basics:AdminP
Thursday, 22 March 12
Basics: Performance
• A crude agent profile mechanism was
introduced in Notes 7
• You enable it from the agent/web service
properties pane:
Thursday, 22 March 12
Basics: Performance
Thursday, 22 March 12
Basics: Lists
• A list is a
collection
of values,
which has
a fixed
lookup
value
dim Surnames list as String
Surnames(“Bill”) = “Buchan”
Surnames(“Paul”) = “Mooney”
Surnames(“Chris”) = “Coates”
Print “Bill’s surname is: “ + Surnames(“Bill”)
if (isElement(Surnames(“Charlie”))) then
Print “Charlies Surname is: “ + Surnames(“Charlie”)
else
Print “I can’t find a surname for Charlie”
end if
forall thisName in Surnames
Print listtag(thisName) + “ “ + thisName
end forall
erase Surnames(“Buchan”)
Thursday, 22 March 12
Basics: Lists
• So lists can collect together similar values
in an ordered way
• Lists have no real overhead
• Lists can contain millions of items
• Lists are very fast
Thursday, 22 March 12
Basics: Lists
• You cannot read and write Lists directly
from Documents
• Convert into a array first, and store as a
multi-value
• You have to iterate a list to see how many
items it contains
• Lists can only store values of the same type
Thursday, 22 March 12
Agenda
• What is LotusScript? Where is it going?
• LotusScript Basics
• LotusScript Advanced
• Web Services
Thursday, 22 March 12
Advanced: Classes
• LotusScript allows you to define classes:
• Classes allow you to bundle variables and
code together in reusable objects
• Classes can inherit from other classes (but
not the ‘notes*’ classes)
• Classes can help build complex systems
quickly and easily
Thursday, 22 March 12
Advanced: Classes
• Example class: define ‘Person’
class Person
public personName as NotesName
public UNID as String ‘ UNID to doc in NAB
sub new(doc as NotesDocument)
set personName = new NotesName( _
doc.getItemValue(“FullName”)(0) )
set UNID = doc.UniversalID
end sub
end class
Thursday, 22 March 12
Advanced: Classes
dim P as new Person(personDoc)
print “Person: “ + P.personName.Common + _
has document ID: “ + P.UNID
• Example class: Using ‘Person’ class
Thursday, 22 March 12
• Create another class that encapsulates
‘Person’
class People
public people list as Person
public count as long
sub new(nabView as NotesView)
dim doc as NotesDocument
set doc = nabView.getFirstDocument()
while not doc is nothing
dim P as new Person(doc)
set people(P.personName.Abbreviated) = P
count = count + 1
set doc = nabView.getNextDocument(doc)
wend
end sub
end class
Thursday, 22 March 12
Advanced: Classes
• Using ‘People’
dim folks as new People(nabView)
forall thisPerson in folks.people
print “Person: “ + thisPerson.personName.Common + _
has document ID: “ + thisPerson.UNID
end forall
Thursday, 22 March 12
Advanced: Classes
• Lets add logging functionality to these
classes by creating a new ‘layer’.
Class log
sub new()
end sub
public sub logMsg(msg as String)
print msg
end sub
end class
Thursday, 22 March 12
class Person as log
public personName as NotesName
public UNID as String ‘ UNID to doc in NAB
sub new(doc as NotesDocument)
set personName = new NotesName( _
doc.getItemValue(“FullName”)(0) )
set UNID = doc.UniversalID
logMsg(“created new person: “ + P.personName.Common)
end sub
end class
• We can ‘inherit’ ALL functionality from ‘log’
by creating ‘Person’ as a subclass of log.
Advanced: Classes
Thursday, 22 March 12
Advanced: Classes
• You can only ‘inherit’ from one class at a
time (other languages have mechanisms for
more)
• Every class you inherit from gets to run its
constructor in the sequence you defined
inheritance
• This allows you to quickly segment large
problems and delegate work
Thursday, 22 March 12
Advanced: Calling C-API
• Not all Lotus Notes API calls are defined in
LotusScript. Sometimes you want to
execute these.
• You can define ANY library/DLL function in
LotusScript and call it
• Its dangerous...
Thursday, 22 March 12
• You have to define EXACTLY the function
using the correct sized primitive variable
types (such as integer, etc)
• If you get any part of it wrong, you will
crash the client. Badly.
• Its Platform-specific. So you have to rewrite
this for every single platform you support
Advanced: Calling C-API
Thursday, 22 March 12
• Example:	

NSFGetServerLatency
• Find out how many milliseconds it takes to
ping a Domino server.
• Defined as:
Advanced: Calling C-API
STATUS LNPUBLIC NSFGetServerLatency(
char far *ServerName,
DWORD Timeout,
DWORD far *retClientToServerMS,
DWORD far *retServerToClientMS,
WORD far *ServerVersion);
Thursday, 22 March 12
• We can define this in LotusScript using:
Advanced: Calling C-API
' This is a constant for our windows-based
' Library file:
Const LIB_W32 = "nnotes.dll"
' Declare our function for windows
Declare Function W32_NSFGetServerLatency _
Lib LIB_W32 Alias {NSFGetServerLatency} (_
Byval ServerName As Lmbcs String, _
Byval Timeout As Long, _
retClientToServerMS As Long, _
retServerToClientMS As Long, _
ServerVersion As Integer) As Integer
Thursday, 22 March 12
• And we can use this (on a 32-bit windows
client or server at least) by:
Advanced: Calling C-API
' A function to get network latency time...
Public Function getServerLatency (strServer As String) As Long
Dim nnServer As New NotesName(strServer)
Dim ToServer As Long, fromServer As Long
Dim ver As Integer
Dim timeout As Long
timeout = 1000 ' 1000ms == 1 second
Call W32_NSFGetServerLatency(nnServer.Canonical,_
timeout, toServer, fromServer, ver)
' Return both directional latencies added together
getServerLatency = fromServer + ToServer
End Function
Thursday, 22 March 12
• C-API can get to functionality that would
be impossible to implement in LotusScript
alone
• It requires FAR more testing than anything
else - use it as a last resort
• Good reference: http://www.ls2capi.com
Advanced: Calling C-API
Thursday, 22 March 12
Advanced: Execute
• ‘Evaluate’ in LotusScript allows you to evaluate
@Formula language:
myString = Evaluate(|@Unique|)
• Execute allows you to execute LotusScript
code
• You can write code that writes code
Thursday, 22 March 12
Advanced: Execute
Dim executeString as String
executeString = |
print “Hello world”
dim s as new NotesSession
dim db as NotesDatabase
set db = s.currentDatabase
print “Current Database name is: “ + db.Title
|
execute (executeString)
• Example
Thursday, 22 March 12
Advanced: Execute
• I use it to dynamically calculate C-API
function signatures
• http://www.hadsl.com/HADSL.nsf/
Documents/LS2CAPI+-+Calling+Notes
+C-API+from+LotusScript
• It can also be used for evil...
Thursday, 22 March 12
Advanced:TriggerHappy
• Imagine we wish to profile ALL our agents
in ALL our databases,ALL the time.
• We could monitor each database to see
when a profile document with form name
$BEProfileR7 is saved
• Save it in a central database...
Thursday, 22 March 12
Advanced:TriggerHappy
• Damien Katz (now of CouchDb, ex-Iris)
wrote a server addin called ‘TriggerHappy’,
available on OpenNtf.
• It allows you to define lotusscript which
gets executed on ANY database event at a
server level.
• RunningWithScissors++
Thursday, 22 March 12
Advanced:TriggerHappy
• Its detailed (with some code) on my blog
at:
• http://www.billbuchan.com/imported-20091119232548/2010/2/2/
universal-agent-profiling-in-domino.html
• We ran it in our TEST environment for
months without issue
• It also tracked Web services as well as
LotusScript and Domino agents
Thursday, 22 March 12
Agenda
• What is LotusScript? Where is it going?
• LotusScript Basics
• LotusScript Advanced
• Web Services
Thursday, 22 March 12
Web Services: Introduction
• Web services are a language and platform
independent way of wiring applications
together
• Fundamentally they’re usually web service
http calls passing back and forth XML
encoded information
Thursday, 22 March 12
• Lotus Domino 7 (now out of support!)
provided a simple lotusscript based Web
services provider
• Lotus Domino nd8 provides a consumer
and a provider
Web Services: Introduction
Thursday, 22 March 12
Web Services:
Experience
• They’re fast. 10+ calls per second. Much
faster than I expected
• But if you want performance, implement
xPages REST based web service
providers - 5x faster
• Reliable
• Look and feel like an agent
Thursday, 22 March 12
Web Services: Example
• A single function that returns a single string
Thursday, 22 March 12
Web Services:Testing
• Download SoapUi from http://
www.soapui.org
Thursday, 22 March 12
Web Services:Authentication
• Two general types of Domino
Authentication:
• Session based - uses cookies back and
forth
• Username and Password based -
username and password is sent with each
transaction
Thursday, 22 March 12
• Client Example:
• We use Flex as a client
• It automatically inherits cookies from the
web page its launched from
• Launch it from an Authenticated page
• Keep the session active by pinging every
10 minutes
Web Services:Authentication
Thursday, 22 March 12
• Server Example:
• We use a windows-based service to
perform work
• We encrypt a username/password pair in
the registry, and use username/password
authentication
• It wakens up every 5 minutes and calls
home
Web Services:Authentication
Thursday, 22 March 12
Web Services: Complex
• You can pass back simple types. Or classes.
• Lotuscript limitation - you cannot return an
array
• So how can I return an array?
Thursday, 22 March 12
• Define a class which contains an Array
Web Services: Complex
Thursday, 22 March 12
SoapUI says...
Thursday, 22 March 12
Web Services:Thoughts
• Web service clients are not under your
control
• Decide how complicated your client can
handle
• More granular == more likely to change
• Choose wisely
Thursday, 22 March 12
Resources
• The LS to C-API programming manual
• http://www.ls2capi
• Calling C-API from LotusScript resource:
• http://www.hadsl.com/HADSL.nsf/Documents/LS2CAPI+-+Calling
+Notes+C-API+from+LotusScript
• Steve McConnell, Code Complete 2 (MS
Press, 2004).
• http://www.amazon.com/gp/product/0735619670
Thursday, 22 March 12
The End?
• This presentation, like all my others, is
available at
• http://www.hadsl.com
Thursday, 22 March 12

More Related Content

What's hot

RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
John Dalsgaard
 
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
GeeksLab Odessa
 
RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkJohn Dalsgaard
 
A powerful web application server (intravision IBM Connect 2013 Update) Febru...
A powerful web application server (intravision IBM Connect 2013 Update) Febru...A powerful web application server (intravision IBM Connect 2013 Update) Febru...
A powerful web application server (intravision IBM Connect 2013 Update) Febru...
Per Henrik Lausten
 
memcached Distributed Cache
memcached Distributed Cachememcached Distributed Cache
memcached Distributed Cache
Aniruddha Chakrabarti
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
prathap kumar
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
Ruslan Shevchenko
 
EXPath: the packaging system and the webapp framework
EXPath: the packaging system and the webapp frameworkEXPath: the packaging system and the webapp framework
EXPath: the packaging system and the webapp frameworkFlorent Georges
 
Developing CouchApps
Developing CouchAppsDeveloping CouchApps
Developing CouchAppswesthoff
 
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
John Dalsgaard
 
ActiveRecord 2.3
ActiveRecord 2.3ActiveRecord 2.3
ActiveRecord 2.3
Reuven Lerner
 

What's hot (11)

RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
RESTful services on IBM Domino/XWork (SUTOL 11 Nov. 2015 in Prague)
 
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
Java/Scala Lab 2016. Григорий Кравцов: Реализация и тестирование DAO слоя с н...
 
RESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWorkRESTful services on IBM Domino/XWork
RESTful services on IBM Domino/XWork
 
A powerful web application server (intravision IBM Connect 2013 Update) Febru...
A powerful web application server (intravision IBM Connect 2013 Update) Febru...A powerful web application server (intravision IBM Connect 2013 Update) Febru...
A powerful web application server (intravision IBM Connect 2013 Update) Febru...
 
memcached Distributed Cache
memcached Distributed Cachememcached Distributed Cache
memcached Distributed Cache
 
Web services tutorial
Web services tutorialWeb services tutorial
Web services tutorial
 
Few simple-type-tricks in scala
Few simple-type-tricks in scalaFew simple-type-tricks in scala
Few simple-type-tricks in scala
 
EXPath: the packaging system and the webapp framework
EXPath: the packaging system and the webapp frameworkEXPath: the packaging system and the webapp framework
EXPath: the packaging system and the webapp framework
 
Developing CouchApps
Developing CouchAppsDeveloping CouchApps
Developing CouchApps
 
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
MVC and IBM XPages - from #DanNotes in Korsør (DK) 28 November 2013
 
ActiveRecord 2.3
ActiveRecord 2.3ActiveRecord 2.3
ActiveRecord 2.3
 

Similar to Everything you ever wanted to know about lotus script

visualbasic.ppt
visualbasic.pptvisualbasic.ppt
visualbasic.ppt
NIDHINDASS1
 
Dev buchan leveraging
Dev buchan leveragingDev buchan leveraging
Dev buchan leveragingBill Buchan
 
Rapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsRapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on Rails
Simobo
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
David Keener
 
Fields, entities, lists, oh my!
Fields, entities, lists, oh my!Fields, entities, lists, oh my!
Fields, entities, lists, oh my!
Phase2
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP TestingRan Mizrahi
 
Node Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsNode Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.js
Chetan Desai
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
Mahmoud Samir Fayed
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue Kid
Matthew Johnson
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Manuel Bernhardt
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181
Mahmoud Samir Fayed
 
node.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornnode.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicorn
bcantrill
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to Lotuscript
Bill Buchan
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
christkv
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
Mahmoud Samir Fayed
 
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript TipsLotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Bill Buchan
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systemsBill Buchan
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
Oliver Busse
 
When to use Node? Lessons learned
When to use Node? Lessons learnedWhen to use Node? Lessons learned
When to use Node? Lessons learned
beatlevic
 

Similar to Everything you ever wanted to know about lotus script (20)

visualbasic.ppt
visualbasic.pptvisualbasic.ppt
visualbasic.ppt
 
Dev buchan leveraging
Dev buchan leveragingDev buchan leveraging
Dev buchan leveraging
 
Rapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on RailsRapid Application Development using Ruby on Rails
Rapid Application Development using Ruby on Rails
 
Rails Tips and Best Practices
Rails Tips and Best PracticesRails Tips and Best Practices
Rails Tips and Best Practices
 
Fields, entities, lists, oh my!
Fields, entities, lists, oh my!Fields, entities, lists, oh my!
Fields, entities, lists, oh my!
 
Bp301
Bp301Bp301
Bp301
 
Intro to PHP Testing
Intro to PHP TestingIntro to PHP Testing
Intro to PHP Testing
 
Node Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.jsNode Summit 2016: Building your DevOps for Node.js
Node Summit 2016: Building your DevOps for Node.js
 
The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185The Ring programming language version 1.5.4 book - Part 180 of 185
The Ring programming language version 1.5.4 book - Part 180 of 185
 
PowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue KidPowerShell - Be A Cool Blue Kid
PowerShell - Be A Cool Blue Kid
 
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVMVoxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
 
The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181The Ring programming language version 1.5.2 book - Part 176 of 181
The Ring programming language version 1.5.2 book - Part 176 of 181
 
node.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornnode.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicorn
 
12 Step Guide to Lotuscript
12 Step Guide to Lotuscript12 Step Guide to Lotuscript
12 Step Guide to Lotuscript
 
Mongodb intro
Mongodb introMongodb intro
Mongodb intro
 
The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212The Ring programming language version 1.10 book - Part 7 of 212
The Ring programming language version 1.10 book - Part 7 of 212
 
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript TipsLotusphere 2007 AD505 DevBlast 30 LotusScript Tips
Lotusphere 2007 AD505 DevBlast 30 LotusScript Tips
 
Lotuscript for large systems
Lotuscript for large systemsLotuscript for large systems
Lotuscript for large systems
 
Utilizing the open ntf domino api
Utilizing the open ntf domino apiUtilizing the open ntf domino api
Utilizing the open ntf domino api
 
When to use Node? Lessons learned
When to use Node? Lessons learnedWhen to use Node? Lessons learned
When to use Node? Lessons learned
 

More from Bill Buchan

Dummies guide to WISPS
Dummies guide to WISPSDummies guide to WISPS
Dummies guide to WISPS
Bill Buchan
 
WISP for Dummies
WISP for DummiesWISP for Dummies
WISP for Dummies
Bill Buchan
 
WISP Worst Practices
WISP Worst PracticesWISP Worst Practices
WISP Worst Practices
Bill Buchan
 
Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014
Bill Buchan
 
Dev buchan best practices
Dev buchan best practicesDev buchan best practices
Dev buchan best practicesBill Buchan
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiBill Buchan
 
Dev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designDev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designBill Buchan
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tipsBill Buchan
 
Entwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptEntwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptBill Buchan
 
Entwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopEntwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopBill Buchan
 
Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101Bill Buchan
 
Reporting on your domino environment v1
Reporting on your domino environment v1Reporting on your domino environment v1
Reporting on your domino environment v1
Bill Buchan
 
Admin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adAdmin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-ad
Bill Buchan
 
Softsphere 08 web services bootcamp
Softsphere 08 web services bootcampSoftsphere 08 web services bootcamp
Softsphere 08 web services bootcamp
Bill Buchan
 
Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013
Bill Buchan
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 Commandments
Bill Buchan
 
Lotusphere 2008 Worst practices
Lotusphere 2008 Worst practicesLotusphere 2008 Worst practices
Lotusphere 2008 Worst practices
Bill Buchan
 
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services BootcampLotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Bill Buchan
 

More from Bill Buchan (20)

Dummies guide to WISPS
Dummies guide to WISPSDummies guide to WISPS
Dummies guide to WISPS
 
WISP for Dummies
WISP for DummiesWISP for Dummies
WISP for Dummies
 
WISP Worst Practices
WISP Worst PracticesWISP Worst Practices
WISP Worst Practices
 
Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014Marykirk raft race presentation night 2014
Marykirk raft race presentation night 2014
 
Dev buchan best practices
Dev buchan best practicesDev buchan best practices
Dev buchan best practices
 
Dev buchan leveraging the notes c api
Dev buchan leveraging the notes c apiDev buchan leveraging the notes c api
Dev buchan leveraging the notes c api
 
Dev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent designDev buchan everything you need to know about agent design
Dev buchan everything you need to know about agent design
 
Dev buchan 30 proven tips
Dev buchan 30 proven tipsDev buchan 30 proven tips
Dev buchan 30 proven tips
 
Entwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscriptEntwicker camp2007 calling-the-c-api-from-lotusscript
Entwicker camp2007 calling-the-c-api-from-lotusscript
 
Entwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshopEntwicker camp2007 blackberry-workshop
Entwicker camp2007 blackberry-workshop
 
Ad507
Ad507Ad507
Ad507
 
Ad505 dev blast
Ad505 dev blastAd505 dev blast
Ad505 dev blast
 
Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101Admin2012 buchan web_services-v101
Admin2012 buchan web_services-v101
 
Reporting on your domino environment v1
Reporting on your domino environment v1Reporting on your domino environment v1
Reporting on your domino environment v1
 
Admin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-adAdmin camp 2011-domino-sso-with-ad
Admin camp 2011-domino-sso-with-ad
 
Softsphere 08 web services bootcamp
Softsphere 08 web services bootcampSoftsphere 08 web services bootcamp
Softsphere 08 web services bootcamp
 
Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013Connections Lotusphere Worst Practices 2013
Connections Lotusphere Worst Practices 2013
 
Lotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 CommandmentsLotusphere 2009 The 11 Commandments
Lotusphere 2009 The 11 Commandments
 
Lotusphere 2008 Worst practices
Lotusphere 2008 Worst practicesLotusphere 2008 Worst practices
Lotusphere 2008 Worst practices
 
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services BootcampLotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
Lotusphere 2008 - Jumpstart 206 - Web Services Bootcamp
 

Recently uploaded

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
Elena Simperl
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
Product School
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
Thijs Feryn
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
Product School
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
Product School
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
Prayukth K V
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
g2nightmarescribd
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
RTTS
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 

Recently uploaded (20)

When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...When stars align: studies in data quality, knowledge graphs, and machine lear...
When stars align: studies in data quality, knowledge graphs, and machine lear...
 
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
AI for Every Business: Unlocking Your Product's Universal Potential by VP of ...
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Accelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish CachingAccelerate your Kubernetes clusters with Varnish Caching
Accelerate your Kubernetes clusters with Varnish Caching
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...How world-class product teams are winning in the AI era by CEO and Founder, P...
How world-class product teams are winning in the AI era by CEO and Founder, P...
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
From Siloed Products to Connected Ecosystem: Building a Sustainable and Scala...
 
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 previewState of ICS and IoT Cyber Threat Landscape Report 2024 preview
State of ICS and IoT Cyber Threat Landscape Report 2024 preview
 
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdfFIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
FIDO Alliance Osaka Seminar: The WebAuthn API and Discoverable Credentials.pdf
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
Generating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using SmithyGenerating a custom Ruby SDK for your web service or Rails API using Smithy
Generating a custom Ruby SDK for your web service or Rails API using Smithy
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
JMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and GrafanaJMeter webinar - integration with InfluxDB and Grafana
JMeter webinar - integration with InfluxDB and Grafana
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 

Everything you ever wanted to know about lotus script

  • 1. Everything you ever wanted to know about Lotuscript Bill Buchan hadsl Thursday, 22 March 12
  • 2. Who am I? • Bill Buchan, CEO of hadsl - one of the sponsors of this show • Come visit the booth - we don’t bite • Dual PCLP in v3, v4, v5, v6, v7, v8, and v8.5 • Enterprise-level consultant on Domino since 1995 Thursday, 22 March 12
  • 3. Agenda • What is LotusScript? Where is it going? • LotusScript Basics • LotusScript Advanced • Web Services Thursday, 22 March 12
  • 4. What is LotusScript • LotusScript is: • A p-code partially compiled, partially interpreted language • Syntactically identical toVisual Basic 3 • In most Notes Applications. Thursday, 22 March 12
  • 5. What is LotusScript • LotusScript • is old. It was introduced with Notes v4, and was first implemented in Ami Pro • Supports Object Orientated techniques • Is fast, scalable, robust • Is Multi-Platform Thursday, 22 March 12
  • 6. Where is it going? • Number of LotusSphere 2012 sessions that mentioned LotusScript: one • No language modifications since Notes v4.6 • (Every version has had class extensions to support some new version features) • Its fair to say that it is not considered a priority for Lotus Thursday, 22 March 12
  • 7. So why are we here? • I wanted to give you a single session that covered everything I knew about LotusScript • We still have to maintain applications Thursday, 22 March 12
  • 8. Agenda • What is LotusScript? Where is it going? • LotusScript Basics • LotusScript Advanced • Web Services Thursday, 22 March 12
  • 9. Basics: How to code • Code for maintenance. • You will change this code.This code will run for 10+ years. Unchanged. • Log everything. • If the users find out before you, you’ve lost. • Good log information means faster debugging Thursday, 22 March 12
  • 10. Basics: How to code • Bugs cost money.The closer to production, the more expensive they are. More testing and debugging and logging costs less • Isolate business logic from display logic. Your look and feel WILL change • Simplicity is cheap Thursday, 22 March 12
  • 11. Basics: Option Declare • You should use ‘Option Declare’ when possible.Why? • Not using Option declare, and not declaring your variables in advance, makes every variable aVARIANT • Variants move all errors to run-time • Variants are slower to use. Thursday, 22 March 12
  • 12. Basics: lsi_info • LSI_Info was a student intern project, and is a global variable created and maintained by the LotusScript environment • It contains lots of ‘interesting’ values • Superseded by getThreadInfo • Its not thread-safe. Heavily loaded servers may crash if its accessed. Thursday, 22 March 12
  • 13. Basics: lsi_info • lsi_info(10) gives the calling class • lsi_info(11) gives the calling function. • So we can write a pretty cool error handler.. Thursday, 22 March 12
  • 14. Function RaiseError() Dim thisType As String Dim es as String thisType = Typename(Me) ' Not a class, use the calling module instead If (thisType = "") Then thisType = Getthreadinfo(11) es = thisType & "::" & Getthreadinfo(10) & ": " If (Err = 0) Then es = es + "Manually raised an error" Else es = es + "Run time error: (" + Trim(Str(Err)) + ") " + _ Error$ + " at line: "+ Trim(Str(Erl)) End If Print es end function ' calling code... ExitFunction: exit function errorhandler: Call RaiseError() resume exitFunction end function Thursday, 22 March 12
  • 15. Basics. NotesSession • This piece of code: dim s as new NotesSession • Doesn’t actually create anything. It just references the same global NotesSession object, built in advance • No performance hit for declaring it (But that doesn’t excuse bad code!) Thursday, 22 March 12
  • 16. Basics:AdminP • AdminP documents have special fields for ReplicaID • Stored as Notes Date/ Time fields Dim dt As New NotesDateTime(targetDatabase.ReplicaID) Call doc.replaceItemValue("ProxyReplicaID", dt) Thursday, 22 March 12
  • 18. Basics: Performance • A crude agent profile mechanism was introduced in Notes 7 • You enable it from the agent/web service properties pane: Thursday, 22 March 12
  • 20. Basics: Lists • A list is a collection of values, which has a fixed lookup value dim Surnames list as String Surnames(“Bill”) = “Buchan” Surnames(“Paul”) = “Mooney” Surnames(“Chris”) = “Coates” Print “Bill’s surname is: “ + Surnames(“Bill”) if (isElement(Surnames(“Charlie”))) then Print “Charlies Surname is: “ + Surnames(“Charlie”) else Print “I can’t find a surname for Charlie” end if forall thisName in Surnames Print listtag(thisName) + “ “ + thisName end forall erase Surnames(“Buchan”) Thursday, 22 March 12
  • 21. Basics: Lists • So lists can collect together similar values in an ordered way • Lists have no real overhead • Lists can contain millions of items • Lists are very fast Thursday, 22 March 12
  • 22. Basics: Lists • You cannot read and write Lists directly from Documents • Convert into a array first, and store as a multi-value • You have to iterate a list to see how many items it contains • Lists can only store values of the same type Thursday, 22 March 12
  • 23. Agenda • What is LotusScript? Where is it going? • LotusScript Basics • LotusScript Advanced • Web Services Thursday, 22 March 12
  • 24. Advanced: Classes • LotusScript allows you to define classes: • Classes allow you to bundle variables and code together in reusable objects • Classes can inherit from other classes (but not the ‘notes*’ classes) • Classes can help build complex systems quickly and easily Thursday, 22 March 12
  • 25. Advanced: Classes • Example class: define ‘Person’ class Person public personName as NotesName public UNID as String ‘ UNID to doc in NAB sub new(doc as NotesDocument) set personName = new NotesName( _ doc.getItemValue(“FullName”)(0) ) set UNID = doc.UniversalID end sub end class Thursday, 22 March 12
  • 26. Advanced: Classes dim P as new Person(personDoc) print “Person: “ + P.personName.Common + _ has document ID: “ + P.UNID • Example class: Using ‘Person’ class Thursday, 22 March 12
  • 27. • Create another class that encapsulates ‘Person’ class People public people list as Person public count as long sub new(nabView as NotesView) dim doc as NotesDocument set doc = nabView.getFirstDocument() while not doc is nothing dim P as new Person(doc) set people(P.personName.Abbreviated) = P count = count + 1 set doc = nabView.getNextDocument(doc) wend end sub end class Thursday, 22 March 12
  • 28. Advanced: Classes • Using ‘People’ dim folks as new People(nabView) forall thisPerson in folks.people print “Person: “ + thisPerson.personName.Common + _ has document ID: “ + thisPerson.UNID end forall Thursday, 22 March 12
  • 29. Advanced: Classes • Lets add logging functionality to these classes by creating a new ‘layer’. Class log sub new() end sub public sub logMsg(msg as String) print msg end sub end class Thursday, 22 March 12
  • 30. class Person as log public personName as NotesName public UNID as String ‘ UNID to doc in NAB sub new(doc as NotesDocument) set personName = new NotesName( _ doc.getItemValue(“FullName”)(0) ) set UNID = doc.UniversalID logMsg(“created new person: “ + P.personName.Common) end sub end class • We can ‘inherit’ ALL functionality from ‘log’ by creating ‘Person’ as a subclass of log. Advanced: Classes Thursday, 22 March 12
  • 31. Advanced: Classes • You can only ‘inherit’ from one class at a time (other languages have mechanisms for more) • Every class you inherit from gets to run its constructor in the sequence you defined inheritance • This allows you to quickly segment large problems and delegate work Thursday, 22 March 12
  • 32. Advanced: Calling C-API • Not all Lotus Notes API calls are defined in LotusScript. Sometimes you want to execute these. • You can define ANY library/DLL function in LotusScript and call it • Its dangerous... Thursday, 22 March 12
  • 33. • You have to define EXACTLY the function using the correct sized primitive variable types (such as integer, etc) • If you get any part of it wrong, you will crash the client. Badly. • Its Platform-specific. So you have to rewrite this for every single platform you support Advanced: Calling C-API Thursday, 22 March 12
  • 34. • Example: NSFGetServerLatency • Find out how many milliseconds it takes to ping a Domino server. • Defined as: Advanced: Calling C-API STATUS LNPUBLIC NSFGetServerLatency( char far *ServerName, DWORD Timeout, DWORD far *retClientToServerMS, DWORD far *retServerToClientMS, WORD far *ServerVersion); Thursday, 22 March 12
  • 35. • We can define this in LotusScript using: Advanced: Calling C-API ' This is a constant for our windows-based ' Library file: Const LIB_W32 = "nnotes.dll" ' Declare our function for windows Declare Function W32_NSFGetServerLatency _ Lib LIB_W32 Alias {NSFGetServerLatency} (_ Byval ServerName As Lmbcs String, _ Byval Timeout As Long, _ retClientToServerMS As Long, _ retServerToClientMS As Long, _ ServerVersion As Integer) As Integer Thursday, 22 March 12
  • 36. • And we can use this (on a 32-bit windows client or server at least) by: Advanced: Calling C-API ' A function to get network latency time... Public Function getServerLatency (strServer As String) As Long Dim nnServer As New NotesName(strServer) Dim ToServer As Long, fromServer As Long Dim ver As Integer Dim timeout As Long timeout = 1000 ' 1000ms == 1 second Call W32_NSFGetServerLatency(nnServer.Canonical,_ timeout, toServer, fromServer, ver) ' Return both directional latencies added together getServerLatency = fromServer + ToServer End Function Thursday, 22 March 12
  • 37. • C-API can get to functionality that would be impossible to implement in LotusScript alone • It requires FAR more testing than anything else - use it as a last resort • Good reference: http://www.ls2capi.com Advanced: Calling C-API Thursday, 22 March 12
  • 38. Advanced: Execute • ‘Evaluate’ in LotusScript allows you to evaluate @Formula language: myString = Evaluate(|@Unique|) • Execute allows you to execute LotusScript code • You can write code that writes code Thursday, 22 March 12
  • 39. Advanced: Execute Dim executeString as String executeString = | print “Hello world” dim s as new NotesSession dim db as NotesDatabase set db = s.currentDatabase print “Current Database name is: “ + db.Title | execute (executeString) • Example Thursday, 22 March 12
  • 40. Advanced: Execute • I use it to dynamically calculate C-API function signatures • http://www.hadsl.com/HADSL.nsf/ Documents/LS2CAPI+-+Calling+Notes +C-API+from+LotusScript • It can also be used for evil... Thursday, 22 March 12
  • 41. Advanced:TriggerHappy • Imagine we wish to profile ALL our agents in ALL our databases,ALL the time. • We could monitor each database to see when a profile document with form name $BEProfileR7 is saved • Save it in a central database... Thursday, 22 March 12
  • 42. Advanced:TriggerHappy • Damien Katz (now of CouchDb, ex-Iris) wrote a server addin called ‘TriggerHappy’, available on OpenNtf. • It allows you to define lotusscript which gets executed on ANY database event at a server level. • RunningWithScissors++ Thursday, 22 March 12
  • 43. Advanced:TriggerHappy • Its detailed (with some code) on my blog at: • http://www.billbuchan.com/imported-20091119232548/2010/2/2/ universal-agent-profiling-in-domino.html • We ran it in our TEST environment for months without issue • It also tracked Web services as well as LotusScript and Domino agents Thursday, 22 March 12
  • 44. Agenda • What is LotusScript? Where is it going? • LotusScript Basics • LotusScript Advanced • Web Services Thursday, 22 March 12
  • 45. Web Services: Introduction • Web services are a language and platform independent way of wiring applications together • Fundamentally they’re usually web service http calls passing back and forth XML encoded information Thursday, 22 March 12
  • 46. • Lotus Domino 7 (now out of support!) provided a simple lotusscript based Web services provider • Lotus Domino nd8 provides a consumer and a provider Web Services: Introduction Thursday, 22 March 12
  • 47. Web Services: Experience • They’re fast. 10+ calls per second. Much faster than I expected • But if you want performance, implement xPages REST based web service providers - 5x faster • Reliable • Look and feel like an agent Thursday, 22 March 12
  • 48. Web Services: Example • A single function that returns a single string Thursday, 22 March 12
  • 49. Web Services:Testing • Download SoapUi from http:// www.soapui.org Thursday, 22 March 12
  • 50. Web Services:Authentication • Two general types of Domino Authentication: • Session based - uses cookies back and forth • Username and Password based - username and password is sent with each transaction Thursday, 22 March 12
  • 51. • Client Example: • We use Flex as a client • It automatically inherits cookies from the web page its launched from • Launch it from an Authenticated page • Keep the session active by pinging every 10 minutes Web Services:Authentication Thursday, 22 March 12
  • 52. • Server Example: • We use a windows-based service to perform work • We encrypt a username/password pair in the registry, and use username/password authentication • It wakens up every 5 minutes and calls home Web Services:Authentication Thursday, 22 March 12
  • 53. Web Services: Complex • You can pass back simple types. Or classes. • Lotuscript limitation - you cannot return an array • So how can I return an array? Thursday, 22 March 12
  • 54. • Define a class which contains an Array Web Services: Complex Thursday, 22 March 12
  • 56. Web Services:Thoughts • Web service clients are not under your control • Decide how complicated your client can handle • More granular == more likely to change • Choose wisely Thursday, 22 March 12
  • 57. Resources • The LS to C-API programming manual • http://www.ls2capi • Calling C-API from LotusScript resource: • http://www.hadsl.com/HADSL.nsf/Documents/LS2CAPI+-+Calling +Notes+C-API+from+LotusScript • Steve McConnell, Code Complete 2 (MS Press, 2004). • http://www.amazon.com/gp/product/0735619670 Thursday, 22 March 12
  • 58. The End? • This presentation, like all my others, is available at • http://www.hadsl.com Thursday, 22 March 12