Friday, December 26, 2008

Lotusphere and USA travel authorization

I am finally ready with all my Lotusphere bookings. But as it is right now, I'll have to stay in 3 hotels. First 1 night in "Dolphin", then 4 nights in "Port Orleans Riverside" and then 1 night in "Swan". I am on the waiting list for "Port Orleans Riverside", hope that I'll get at least 1 hotel switch less.

When booking the flight ticket, I noticed a warning that from 12 January travelers must electronically register at least 72 hours prior to travel. See below for more info.

Effective January 12, 2009, all VWP travelers will be required to obtain an electronic travel authorization prior to boarding a carrier to travel by air or sea to the U.S. under the VWP.

VWP=Visa Waiver Program


Monday, December 01, 2008

Strange behavior of DXL import

While working with DXL123 freeware Domino app(beta released soon), I found a strange behavior of DXL importer in LotusScript: swedish letters (åäö) in imported stream are changed to garbled characters. But simple stream.ReadText before importing the stream fixes the problem.
I guess it has to do with wrong encoding, maybe with utf-16 being used instead of utf-8, but I don't see how I would change that or why it begins working after stream.ReadText <?xml version="1.0" encoding="utf-16"?>

Dim tmpstream As NotesStream
Dim importer As NotesDXLImporter
Dim fixencoding As String

Set tmpstream = session.CreateStream
Call domParser.setOutput(tmpstream)
Call domParser.Serialize

fixencoding=tmpstream.ReadText 'This makes the result OK

Set importer = session.CreateDXLImporter(tmpstream, sourcedoc.ParentDatabase)
importer.ReplaceDBProperties = False
importer.ReplicaRequiredForReplaceOrUpdate = False
Call importer.Process '.Import gives same result

DXL123 is a set of LotusScript API to easily perform different operations on inline images and on attachments without knowing anything about DXL.

Function available in DXL123:
Copy attachments between documents (without detaching to disk)
Convert inline image to attachment (without detaching to disk)
Change name of an attachment (without detaching to disk)
Remove inline images
Import disk file as an inline image
Place inline image in text after specified word/phrase
Place inline image inside a table
Replace inline picture to another picture
Replace attachment in richtext to URL link
Replace inline image to HTML image reference

attachment_name=CopyInlineImageToDocAttachment(sourcedoc, targetdoc, "Body", 2, False, True)' make the second image in Body field to become an attachment and delete the original image


Friday, October 31, 2008

Halloween bot

On this dark October evening, amuse yourself with Halloween Sametime Bot, which knows a lot of Halloween jokes about vampires, ghosts and other scary creatures:

Halloween Sametime bot

To see more scary jokes, type "scary" or "joke" to the bot.


Thursday, August 21, 2008

Sametime bot shows currency exchange rates

Based on Translation Bot, I created another multi-step function for our Sametime bot. It shows current exchange rates between different currencies (from Yahoo Finance).
You can try it here:
Currency Exchange Sametime bot

1) Type 1 and click "Say" button (or press Enter key).
2) Type 2 to set Euro as source currency and press Enter key.
3) Type 7 to set Swedish crown as target currency and press Enter key.
The result is the current exchange rate according to Yahoo finance.



Sunday, August 17, 2008

Another Javascript feature

Javascript uses pointers when assigning objects. This can lead to unexpected results for those who are used to work with LotusScript and Visual Basic, where data is copied to the new object and is no longer connected to the original object.

In the example below note that date2 object was not deliberately changed after it was initially set, but still at the end of the script it gets a new value which is the same as the changed date1 object.

var date1=new Date();
var date2=date1;

alert(date2); //shows Sun Aug 17 11:46:50 UTC+0200 2008


alert(date2); //shows Mon Jun 9 11:46:50 UTC+0200 2008

run example

It also works in the opposite direction: if you change date2, the date1 will also be changed.

Monday, August 04, 2008

Why javascript doesn't like August and September in date validation

Do you like August and September months? Well, then bad news, because JavaScript doesn't like them. Using parseInt function without base parameter to convert from text to number when validating month number 08 gives 0.
This is true only for August(month "08") and September(month "09"), so it can take a while until the error is discovered. Why is that happening? Well, probably because genious developers of Javascript API thought that people use octal (base8) as default. Numbers until 08(August, put as "08" in dates) are converted correctly because they are same in octal as in base10, and numbers after 09 are recognized correctly because they(almost never) have a non-zero leading number. In between we have our poor "08" and "09".
Fortunately, there is a parameter you can add to parseInt function which specifies the base, e.g. parseInt("09", 10). But was it really so smart to use base8 as default for numbers beginning with 0 instead of always using base10 and requiring user to explicitely enter parameter for other (less used) bases?

Alternatives for parseInt are parseFloat and Number functions:

Doesn't work correctly:

Works correctly:
javascript:alert(parseInt("09", 10))

Monday, July 28, 2008

Sametime bot for text translations

As I wrote in my previous blog post "LotusScript to translate text between languages", I have created a function in Sametime bot to translate text between languages using Google Translate. Now this bot functionality is available for everyone to test through STWidget-Sametime AJAX web client.

Link to live demo: Sametime translation bot

Quick instructions:
1) type 1 (to choose "Translate between languages" option) and then press Enter or click "Say" button.
2) type 1 (to choose English language) and then press Enter.
3) then type 2 (to choose German language) and Enter.
4) then type text you want to get translated, e.g. "I love programming" and Enter.

To fetch the translation result, Bot makes a web call to Google Translate service, using MSXML2 object in a slightly modified LotusScript code as in the old post. Here is an animated picture of the translation process:

Sametime translation bot animation

Click picture to see animation

Some other funny functions available through the same bot are "joke", "wisdom", "morse" and "random bible quote". The main difference between these small functions and Translation function is that Translation works in multi-step mode, prompting user with available choices, thus eliminating the need for user to remember the syntax of the commands. Another multi-step function is "Company info" where user can get virtually any corporate info through Sametime bot.

All of the example functions above are handled by the same bot instance, so users do not need to add a separate bot to their buddy list for each new function added by developer/admin to bot.

In one of my next posts I will show a screencapture video how to develop a "whois username" function using @Formula language and how to create multi-step "Translation" function.


Wednesday, July 23, 2008

Automated login to Domino by HTTP POST request

In a comment to Joachim Dagerot's blog post "Login in with just url-arguments" I mentioned that it's possible to login without exposing login credentials in the URL. It is done by making a POST request to Domino web server, instead of GET request. User still can see login credentials if he views page's HTML source, but they are at least not shown directly in the URL. Showing login details in URL makes it possible for bypassers to see your password, it's saved in the browser's URL history and it's also logged in the Domino log database, which is not so good as anyone with access to the log database can see them. Such URL might even get indexed by Google and show up in the search results.

To additionally secure automated login, an extra redirect can be used, so the page itself does not contain the password. Or even better and without any password exposure is a page/form which calls an agent which makes login in background and then passes the session cookie back to the initial page. But that's a topic for another blog post. Here i will show the simplest solution.

<form action="/names.nsf?Login" method="POST" name="LogonForm">
<input type="hidden" name="Username" value="myname">
<input type="hidden" name="Password" value="mypassword">
<input type="hidden" name="RedirectTo" value="/anotherdb.nsf/view?OpenView">


When user opens this page, the first form gets automatically submitted to "/names.nsf?Login". User gets logged in to Domino with username and password specified in the form's fields and then redirected to another database according to the value in RedirectTo field.


Sunday, June 01, 2008

LotusScript's List bug strikes again

Last week i was working with a LotusScript agent which uses List data type for storing text values. The agent was not working properly as it could not find matching values in the second list(which was populated with the same listtags as the first list). I suspected it was something wrong with processing of List, but couldn't find what part of the code was wrong, as I got no error messages. The List was more than 1000 elements and in the debugger I could only see about 200 first elements, which was not very helpful. I have earlier experienced similar problem with IsNull(mylist("listtag")) function, but in this agent there were no such IsNull checks (use IsElement instead of IsNull). After 2 hours of commenting parts of the code out, I finally found what was wrong. The fact of calling tst procedure with nonexistant list value mylist("b") as parameter, creates "b" list element with value ""! It does not generate "List item does not exist" error message as one would expect!

I have hard to think that it works "as designed", as a programmer clearly doesn't want to create a new list element by simply passing it to a procedure.
Using IsElement(mylist("b")) before calling the procedure/function helps to avoid the problem, but that shouldn't be necessary, as the programmer expects an error if the List element does not exist.

Sub Initialize
Dim mylist List As String
' Msgbox mylist("b") 'properly results in error "List item does not exist"

Call tst(mylist("b")) 'erroneously creates "b" list element

' Msgbox Isnull(mylist("b")) 'erroneously creates "b" list element

Msgbox mylist("b") 'shows "" as list value for "b" instead of an error

End Sub

Sub tst(tmp)

End Sub


Sunday, March 02, 2008

Short tip: connect to remote Windows desktop console session

Just a short tip which I discovered today.

When connecting to a remote Windows server using the standard "Remote Desktop" client program, you are connected to a user session and can not see what happens on the server's main console (the one which you get when you login physically on the server). You can not, for example, see the Domino server console.

But there is a special parameter which can be used with Remote Desktop client to login into Windows console session instead of user session.
In Start/Run menu type:
mstsc /console
use your regular username and password, and you will be logged in directly to Windows console. I guess that you must have some kind of admin privilegies to do that.

Saturday, February 23, 2008

LotusScript to translate text between languages

I am currently working to update our Sametime Bot with a new feature: translation of text. It will be a prompted flow where user is asked for input language, output language and text. The answer from the bot is the translated text. The translation is done by using a LotusScript agent which gets the translation from Google Translate page. LotusScript agent uses MSXML object for web communication with the Goggle server.
See below for an example of translation between English and German.
Pictures show the messagebox for German, Spanish, French and Russian translations. The translation is of course not perfect, but enough good to understand the general meaning.
The best automated translator I've seen so far is by the company "Prompt": It produces very correct translations and even sees the difference between "hello all Domino developers" and "hello to all Domino developers".

Sub Initialize
Dim xmlhttp, MySoap
Dim StartTag As String,EndTag As String, FromLang As String, ToLang As String, TextToTranslate As String
StartTag= |<div id=result_box dir="ltr">|
EndTag = "</div>"
TextToTranslate="hello all Domino developers"
TextToTranslate=Replace(TextToTranslate," ","%20")

Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
Call"GET", WebServer, False)
Call xmlhttp.setRequestHeader("Content-Type", "text/html; charset=utf-8")
Call xmlhttp.setRequestHeader("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)")
Call xmlhttp.setRequestHeader("Accept","image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*")
Call xmlhttp.setRequestHeader("Accept-Language","sv")
Call xmlhttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded")
Call xmlhttp.send(Null)

strxml = xmlhttp.responseText

Msgbox Strleft(Strright(strxml,StartTag),EndTag)

End Sub


Sunday, February 03, 2008

Sametime bot to read Lotusphere RSS feeds is updated

Hey folks! I am back from the long period of not blogging! And several more posts are in the pipeline, including DXL API for handling pictures/files, webcam API for spying on Notes users and Java agent to impersonate web users! :)

Last week I've updated my Sametime bot which shows blog posts in Lotusphere2007 category(on Technorati). Now it shows the last 20 posts for keyword Lotusphere2008.
You can try it here: Sametime bot

If you want to see another blog category available through STWidget and Sametime Bot, drop me a line and I'll create a new function and an appropriate STWidget link. Or do you have an idea for a cool Bot function not related to RSS? Drop me a line and I'll see what I can do :)

For sample of LotusScript agent fetching the RSS data from Technorati, see the old post: Sametime bot shows latest Lotusphere2007 blogs