博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
10 advanced LotusScript tips2
阅读量:6242 次
发布时间:2019-06-22

本文共 3739 字,大约阅读时间需要 12 分钟。

 

 

There are two types of binding: early binding and late binding.

Early binding is set by the compiler and works well because it uses type checking, works quickly and is easy to use. An example of early binding might be:

 

Late binding is set at runtime. It is very flexible, but doesn't use type checking. Unfortunately, the performance isn't as good as early binding and you might run into some runtime errors.

 

 

 

When you're coding for performance, always remember that expensive operations include opening Lotus Notes databases, and views and documents with lots of fields. So, when you're collecting data, remember to cache views wherever possible and use NotesViewEntry instead of opening documents.

As an example, let's say you have a Lotus Notes database with 100,000 documents in it. This would take seven hours to actually open every document in the Lotus Notes database, if you don't code for performance and use views. If you do code for performance, it will only take you 60 minutes to open these using NotesView and only 12 minutes if you use NotesViewEntry!

 

 

It's good practice to use LotusScript lists and classes because classes bind complex data and operations. Lists can look these up quickly in memory. For a quick example, here's how we might extend our Person class:

 

 

 

Class inheritance allows us to "Extend" classes to add functionality. For example:

 

 

 

 

 

 

 

 

 

You can use the LSI_INFO() command to get some runtime information. Be aware though that this information is superceded by the GetThreadInfo command.

If you use GetThreadInfo(11), that will return you the calling class. If you use GetThreadInfo(10), that will return you the function name. And these are just the beginning.

Through error trapping, we can track where we came from. We don't have to pass lists of parameters to error trapping code. It also prevents coding errors through using the copy and paste method.

Here is an example of this in use, preceded by the calling code:

 
Function RaiseError()Dim thisType As StringDim es as StringthisType = Typename(Me)' Not a class, use the calling module insteadIf (thisType = "") Then thisType = Getthreadinfo(11)es = thisType & "::" & Getthreadinfo(10) & ": "If (Err = 0) Thenes = es + "Manually raised an error"Elsees = es + "Run time error: (" + Trim(Str(Err)) + ") " + _Error$ + " at line: "+ Trim(Str(Erl))End IfPrint esend function

 

 

By using the execute command, you can run LotusScript from a string. Doing this accommodates version/platform differences at runtime. Here's an example:

 

 

 

By using the OpenNTF "OpenLog" solution, you can make simple LotusScript library additions to your code, provide "called from," "error," and "line number" functionality. Our system now works on error trap and displays all objects in memory.

 

 

By mixing Java and LotusScript together, you can really get the most out of each scripting language. The trick is to use each language to its strengths. For example, Java is good for Web service, network I/O, and multithreaded operations. LotusScript is the traditional Lotus Notes development language and works in the user interface.

Mixing the two languages together is easy -- just call an agent, passing a Lotus Notes document.

You should also know that this works both ways, as you can call Java from LotusScript. This is called LS2J. An example is below:

 
Option PublicUse "xlib"Uselsx "*javacon"Sub InitializeDim mySession As JavaSessionDim myClass As JavaClass, calculator As JavaObject, a,b,c As IntegerSet mySession = New JavaSession()Set myClass = mySession.GetClass("calculator")Set calculator = myClass.CreateObject()a = 10b = 5c = calculator.mul(a,b)MessageBox "a * b = " & cEnd Sub

TUTORIAL: 30 LOTUSSCRIPT TIPS
Home:
Part 1:
Part 2:
Part 3: 10 advanced LotusScript tips
Part 4:

转载地址:http://bupia.baihongyu.com/

你可能感兴趣的文章
《AngularJS深度剖析与最佳实践》简介
查看>>
Android----------WindowManager
查看>>
通过DAC来连接SQL Server
查看>>
Oracle11G 卸载步骤
查看>>
Mars说光场(3)— 光场采集
查看>>
kettle与各数据库建立链接的链接字符串
查看>>
Android--调用系统照相机拍照与摄像
查看>>
【OpenCV学习】利用HandVu进行手部动作识别分析
查看>>
Ubuntu下安装配置JDK1.7
查看>>
AngularJS快速入门指南15:API
查看>>
安装惠普M1136打印机一直处于“新设备已连接”状态怎么办?
查看>>
android88 录音机
查看>>
美国诚实签经验(最全集合)
查看>>
HttpContext.Current:异步模式下的疑似陷阱之源
查看>>
《Java与模式》- 创建型模式
查看>>
[Android]使用Kotlin开发Android(二)
查看>>
php将对象数组转成普通数组
查看>>
org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_7
查看>>
Python 中的 if __name__ == '__main__' 该如何理解(1)
查看>>
Qt之对话框设计——利用QPalette改变控件颜色
查看>>