I had a routine that used an agent to search for phone numbers for people.
It was quite complicated: it would search for aliases for names so that searching for "mike" would also find "Michael" and also searching for "mike" would look for "ext-mike" and "ext-Michael" as they could be contracting staff and their names are prepended with "ext-". It also worked if you searched for firstname, surname, firstname and surname, surname and firstname, firstname and first letter of surname .
The search code also checked to see if the people were on holiday or absent due to sickness, and told you when they were back, and also linked to webpages and a text messaging gateway with their mobile number.
I did all of this using a lotusscript agent.
Anyway it was brilliantly useful, but just too slow. You need a 2 or 3 second response to this sort of thing.
So I changed the code to use @formulas, and it was oh so quick.
I changed the form so that all the serious code was in the $$Return field.
The form had a name field and a saveoptions set to "0".
The view $users2 used just had every document sorted by lots of different ways, surname, firstname etc.
When the form was submitted $$Return did all the searching using @dblookups. Very quick indeed.
Here is a summary of the code:
REM "Make sure $$Return does nothing until the document is completed";
@If(@IsDocBeingLoaded | Name="";@Return("No");"");
n2:=@Trim(@LowerCase(Name));
REM "Do a standard search for the name and ext-name";
r:=@DbLookup("";"";"($Users2)";n2;3);
s:=@DbLookup("";"";"($Users2)";"Ext-"+n2;3);
REM "Synonyms check if they enter david it will find dave as well";
FIELD Syn1:=@If(
@Contains(n2;"david");@ReplaceSubstring(n2;"david" ;"dave");
@Contains(n2;"andrew");@ReplaceSubstring(n2; "andrew" ;"andy");
"");
REM "Synonyms check if they enter dave it will find david as well";
FIELD Syn2:=@If(
@Contains(n2;"dave");@ReplaceSubstring(n2; "dave" ;"david");
@Contains(n2;"andy");@ReplaceSubstring(n2; "andy" ;"andrew");
"");
REM "Search for a few variants";
t:=@If(Syn1="";"";@DbLookup("";"";"($Users2)";Syn1;3)) ;
u:=@If(Syn1="";"";@DbLookup("";"";"($Users2)";"Ext-"+Syn1;3)) ;
v:=@If(Syn2="";"";@DbLookup("";"";"($Users2)";Syn2;3)) ;
w:=@If(Syn2="";"";@DbLookup("";"";"($Users2)";"Ext-"+Syn2;3)) ;
x:=@If(Syn2="";"";@DbLookup("";"";"($Users2)";@Left(n2;" ")+" ext-"+@RightBack(n2;" ");3)) ;
t2:=t;
r1:=@If(@IsError(r);"";r);
s1:=@If(@IsError(s);"";s);
t1:=@If(@IsError(t);"";t);
u1:=@If(@IsError(u);"";u);
v1:=@If(@IsError(v);"";v);
w1:=@If(@IsError(w);"";w);
x1:=@If(@IsError(x);"";x);
tempname:=@ReplaceSubstring( @Name([CN];Name); " "; "%20");
REM "Send log mails, so I can see how many searches fail and why, and also how well used this is";
@If(@Trim(r1:s1:t1:u1:v1:w1:x1)="";
@MailSend("Notes Development/Corp";"";"";@Name([Abbreviate];@UserName)+ " used CIDS Phone lookup " + name+" not found";"";"");
@MailSend("Notes Development/Corp";"";"";@Name([Abbreviate];@UserName)+ " used CIDS Phone lookup " + name+" "+@Text(@Elements(r1:s1:t1:u1:v1:w1:x1));"";"")
);
"<!--" + @Left(n2;" ")+" ext-"+@RightBack(n2;" ") + "Syn1:"+Syn1 +" Syn2: " +Syn2+ "-->"+@NewLine+
"<style type=\"text/css\">"+@NewLine+
"body,td,p,li {font-family: Verdana, Arial; color:#000000; font-size: 9pt}"+@NewLine+
"a:link {font-family: Verdana, Arial; color:#0000FF ; text-decoration: underline}"+@NewLine+
"a:visited {font-family: Verdana, Arial; color:#888800; text-decoration: underline}"+@NewLine+
"</style>"+@NewLine+
@If(@Trim(r1:s1:t1:u1:v1:w1:x1)="";"None Found in CIDS<br> ";
"<TABLE BORDER=0>"+
@Implode(
@ReplaceSubstring(@Trim(r1:s1:t1:u1:v1:w1:x1);
"^St^":"^N^":"^V^":"^M^": "^M2^" : "^A^": "^E^";
"<TR VALIGN=top><TD bgcolor=\"#DDDDDD\"><a target= \"_blank\" href=\"$defaultview/" :
"\">" :
"</a> </TD><TD> " :
" </TD><TD> <a target=\"_blank\" alt=\'sms\' href=\"http://ph.corp.com/?act=sms&num=" :
"\">":
"</a> </TD><TD>")+
"</TD></TR>";
@NewLine) )
+"</TABLE><form>"+
"<a target=_blank href=\'http://ph.corp.com/?skey=name&sval="+tempname+"&skey_x=&sval_x=\'>Try Global Phone Book for \""+@ReplaceSubstring(tempname;"%20";" ")+"\" by clicking here</a><br><br>"+
"<input type=\"button\" value=\"Back\" onclick=\"history.back();\">"
So just rememeber, you are not a real notes programmer unless you know @function code.
$$Return rules!