Lotus Notes常用方法

类别:编程语言 点击:0 评论:0 推荐:

将日期转换成星期几 

REM "This formula assumes there is default text in the field called Date.";
REM "Otherwise it gives the "Incorrect data type..." error.";

M := @Text(@Weekday(Date));
N := "1" : "2" : "3" : "4" : "5" : "6" : "7";
Days := "Sunday" : "Monday" : "Tuesday" : "Wednesday" : "Thursday" : "Friday" : "Saturday";
DayName := @Replace(M; N; Days);
@Text(Date) + " (" + DayName + ")"

如何计算一个日期在一年中是第几个星期

Some applications require the computation of the week number in a month in which a given date falls. For example, Sunday 02 May 1999 is in the second week while Saturday 01 May 1999 is in the first week.

This formula computes the week number of date value GivenDate:

WeekNumber := @Integer( (@Day(GivenDate) - @WeekDay(GivenDate)+13) /7 )

计算两个日期之间的月数

Date1 := "07/22/99";
Date2 := "12/22/98";
Mnth :=((@Year(@TextToTime(Date2)) - @Year(@TextToTime(Date1))) * 12) + @Month(@TextToTime(Date2)) - @Month(@TextToTime(Date1));
@Abs(Mnth)

如何把数据转换成电话号码格式

phone := @Trim(Field Name);phonestripped :=
@Trim(@Implode(@Explode(@LowerCase(phone); "et- ()./+"); ""));
@If(@Length(phonestripped) = 10; "(" + @Left(phonestripped; 3) + ") " +
@Right(@Left(phonestripped; 6); 3) + "-" + @Right(phonestripped; 4);
phone

将两位的年代转换为四位的年代

a:=[1/1/99];
@Prompt([ok];"date";@Text(a;"D2") +"/"+@Text(@Year(a)))

另外一种方法是:

@Text(;"D2") +"/"+@Text(@Year())

有时候大家希望修改新邮件来时的提示声音,可以这样做:

1. 在 notes.ini 文件中增加一行
NewMailTune= ***

比如:NewMailTune=c:\coolsound.wav

2. 保存 notes.ini.
3. 重新启动 Notes 就可以发现新邮件来时的提示声音改为 coolsound 的效果了

如何在程序中限制谁可以运行代理

REM "====================================";
REM "Restricts who can run this agent to those in at least one of the specified role(s). Note that 'Enforce a consistent ACL' must be enabled for @UserRoles to work locally.";
_roles := "[Admin]";

REM "====================================";
_allowedToRunAgents := (_roles = @UserRoles);
@If(_allowedToRunAgents; ""; @Return(@Prompt([OK]; "Launch Agent"; "You are not authorized to run agents on this database. Contact your database administrator if you need to run system agents on this database.")));

REM "The normal agent code follows...";

如何用公式运行 Dos 命令:@Command([Execute]; "C:\\COMMAND.COM"; "/C DEL C:\\TEST.TXT")

如何计算两个日期之间的工作日

This formula calculates elapsed working days, excluding Saturday and Sunday, between any two dates ( FromDate and ToDate).

Totaldays := ((FromDate - ToDate) / (3600  * 24)) + 1 ;
Extday :=  @Weekday(FromDate) - 1  + (7 - @Weekday(ToDate));
Totweekday := (Totaldays - Extday) - 2 ;
Totsatsun := (Totweekday / 7) * 2;
Elapsed := Extday + (Totweekday - Totsatsun) ;
FinalElapsed :=  @If(@Left(@Text(Elapsed) ; ".") != "" ;
@Left(@Text(Elapsed + 1) ; ".") ; Elapsed);
FinalElapsed

一段用于 Web login 按钮的代码

Here is the code for a login button for a Web application that permits Anonymous access. Simple create a hidden agent with this LotusScript code. Then use a button to call the agent. For example, if your agent is called "(Login)", you would call it with this formula command:
@Command([ToolsRunMacro]; "(LogIn)")
Set the button to hide-when the username is "Anonymous". Finally, if the application uses frames, you may want to set the button to open in a new window to avoid nesting a frameset within a frameset.
Code
Code for the agent:
Sub Initialize
Dim db As Notesdatabase
Dim session As New NotesSession
Set db = session.CurrentDatabase
Dim servername As New Notesname (db.Server)
Dim vEvaluate As Variant
Dim dbWebPath As String
vEvaluate =Evaluate(|"/"+@ReplaceSubstring(@Subset(@DbName;-1);"";"/")+"/";|)
dbWebPath = vEvaluate(0)
Print "[http://" + servername.common + dbWebPath + "?OpenDatabase&login" + "]"
End Sub

@Function.lss 使用方法

The .lss file show a few @functions, which have been implemented in Lotus Script.
any .lss file can referenced in a Lotusscript Library by adding line as shown below to the declarations section of the script library.

%INCLUDE "@function.lss"

这个技巧是用来设置基于 web 的视图的列宽的。
代码:
@Implode(@Explode(Your Field Here); " ")
To elaborate on this concept, if you'd like to make sure just the first two
words appear on the same line, use:
@Implode(@Explode(@Word(MANUFACTURER;" ";1): @Word(MANUFACTURER;" ";2));
" ")
+ " " +
@right(@right(manufacturer; " "); " ")

 

如何实现打开一个表单时隐藏菜单

You can hide the menu bar that is normally displayed with a given form.

While in form design, press Ctrl+Shift++ (hold down Ctrl and Shift, and press the "plus" key). Save the form. This is a toggle key. When pressed, a form property flag called "NoMenus" is placed in $Info.

To disable the no-menu mode, open the the form design, press Ctrl+Shift++ and save the form. This removes the form propery flag "NoMenus" from the $Info field.

The only way to determine the no-menus mode of a form is to manually inspect the contents of the $Info field

如何在视图的列中引入其他视图的列值

Occasionally, it's helpful to be able to create a view column that takes advantage of the calculations already done in other view columns. Let's suppose you have a number in column A, and a number in column B, one or both of which is calculated by a formula in the view column. You want to display their total in column C without having to repeat any complex formulas.

There's a little known feature that will let you do this. In the propeller head tab of the view column properties, there's a field that'll let you enter a column name. For a formula column, Domino Designer will automatically generate a name such as "$5." To use the value from this column in other columns, you need to change this to a name that's a legal variable, e.g. "columnA." After giving names to columns A and B, you can write the formula for column C as follows.
Code
columnA + columnB

时间数组的处理方法:When you need to create a list of dates, based on a begin date and an end date. This is extremely useful when creating calendar views, allowing you to display activities that extend over a single day. Requirements - three fields:
BeginDate

EndDate
DateArray
Place the code in the query save event, and when the document is saved it will populate the DateArray field with a list of dates.
Dim session As New NotesSession
Dim db As NotesDatabase
Dim workspace As New NotesUIWorkspace
Dim currentdoc As NotesDocument
Dim uidoc As NotesUIDocument
Dim doc As NotesDocument
Set db=session.CurrentDatabase
Set uidoc=workspace.currentdocument
Set doc = uidoc.document
If doc.BeginDate(0) = doc.EndDate(0) Then
doc.DateArray = doc.BeginDate(0)
Else
result = doc.BeginDate(0) & | - | & doc.EndDate(0)
result2 = Evaluate(|@Explode(@TextToTime("| & result & |"))|)
doc.DateArray=result2
End If
Call doc.Save(True, False)

如何校验填写邮件地址的域是否填写正确

domain := @RightBack(Email; ".");
@If(
@Trim(Email) = "" |
!@Contains(Email; "@") |
@Length(domain) < 2 | @Length(domain) > 3 |
(@Length(domain) = 3 & @Member(@LowerCase(domain); "com":"edu":"org":"net":"gov":"mil":"int") = 0) |
@Trim(@Left(Email; "@")) = "";
@Failure("A valid Internet e-mail address is required. Please go back to the form to enter or correct the e-mail address."); @Success)

在字符列表中找到字符的位置

Field - List = your input list
Field - FindChar = the thing you're trying to find in the list
Field - Position = multi value field with final position of the characters you're looking for.

Button code used to find the position of all of your characters :

NumInList := @Elements(List);
TargetFindList := @Explode(@Repeat(FindChar + ", " ; NumInList -1) + FindChar);
SeqList := @Text(@TextToNumber(("0":"1":"2":"3":"4":"5":"6":"7":"8":"9") *+("0":"1":"2":"3":"4":"5":"6":"7":"8":"9")));
Seq := @Subset(@Subset(SeqList; -99); NumInList);
AltFindList := List + Seq;
AltTargetFindList := TargetFindList + Seq;
FindPos := @Replace(AltFindList; AltTargetFindList;Seq);
Final := @Trim(@Replace(FindPos;AltFindList;""));
@SetField("Position";@Trim(@Replace(FindPos;AltFindList;"")))

如何在视图中显示RTF中的内容

Have you ever wanted to display the contents of rich text fields in a view? For example:
You want to let your users be able to bold and set the fonts for their comments, but you also want to have these comments appear in a view.

Here's a solution using the @Abstract function. On the form, if the rich text field name is Body, create a hidden, computed text field (for example, call it BodyText) with the following value:

@Abstract( [TextOnly]:[TrimWhite]; 64000 ; "" ; "Body" )

You then can display the Body Text field in views!

如何动态访问其他的数据库

This tip uses the profile extensively or you can create a separate
profile form available in a separate view. The view name is "Profile"
with one column that is sorted. The value shown in the column is the
form name or a default value Profile".

On the profile form create four text fields:
Server
Database
View
Key

On the form you need to recover a list of Keywords that are available
in the second database. Place the following code on the Keyword field
with the following properties set:  

Use Formula for choices

The following properties can be set as required:
Refresh Fields on Keyword Change
Refresh Choices on Document Refresh

In the lookup formula place the following code:

srv:=@DbLookup("Notes":"NoCache";"";"Profile";"Profile";"ServerName");
db:=@DbLookup("Notes":"NoCache";"";"Profile";"Profile";"Database");
vw:=@DbLookup("Notes":"NoCache";"";"Profile";"Profile";"View");
ky:=@DbLookup("Notes":"NoCache";"";"Profile";"Profile";"Key");
@DbLookup("Notes":"NoCache";srv:db;vw;ky;<fieldname / Columnnumber>)

The last Dblookup can be replaced with a dbcolumn also. The fieldname
/ column number can also be picked up from the profile.

An enhancement to this could be using the profile commands available
also eg.:  

@GetProfileField

 

本文地址:http://com.8s8s.com/it/it25252.htm