Lapas

Friday 2 November 2012

Lotus Notes. Getting user HOME on MACINTOSH

I had run in problem building application for MACINTOSH in LN. It was required to install some user files for regular use and it should be installed in user home directory. So then problem was, that Lotusscript does not gives user home directory location using Environ, or NotesSession.getEnvironmentString.
First my attempt were to execute shell like "env > /tmp/userenv.txt" and then read the file, parse and get HOME directory from file - I don't like this, because You need to create a file on disk.
Second attempt were to search for dll containing standard C function getenv, which must return environment variable by specified name. So the library found is "libSystem.dylib" and resulting declaration in LS library, agent {Declare Function mac_getenv  Lib "libSystem.dylib" Alias "getenv" (ByVal varnameAs String) As String}, so call mac_getenv("HOME") and voila!


Creating Type-ahead searches in Lotus Notes

This will be short article about how to build user friendly type-ahead searches for Lotus Notes clients.
This will not be tutorial, but only idea and some basic concepts.
Basic instruments:
1) Form - dialog basic form
2) Dialog list field - search text entering
3) Query recalc - search performing
4) NotesTimer - for large database search optimization
5) Table with hotspots - user friendly result display

Example to-do:

  1. Required to build dialog for searching data in database (people, organization, product or other object search).
  2. Build a dialog form, which will be called from our hotspot in some basic form (better to use dialog, because of complex design of search dialog)
  3. Add dialog list field, and put it in table, disable delimiters, add formula "" for choices, check refresh on each character.
  4. On query recalc add function to perform search before form is refreshed, get value from search field and compute formula and search for results. After search put result in fields, from whose will be computed out table. Maybe You will need to limit search starting from 2-3 characters entered in searchfield.
  5. Create table with row count about 10 result rows. You could build paged table or table with hotspot for more results in ex. ws.prompt LIST. Each row could consist of index, name of found entry, id, other info ex. No., Product Name, ID, Manufacturer. For table correctly to work it is required to add bunch of hide formulas and field formulas, for faster results, build one row with field indexes ex. No_1, Name_1, ID_1,Man_1, but results put in fields No,Name,ID,Man, so You can compute which entry to pick from result field for row ex. @getfield(@left(@thisname;"_"))[@tonumber(@right(@thisname;"_")] (add error handling :) ) - it's pretty easy to build row with this technique. For pickfield ex. Product Name add hotspot, to allow to pick clicking on entry directly and add script like call entrySelected(0). For faster 10 row run initially create fields with no index and then use copy/paste, because LN will add indexes - if You copy field Name, then paste result will be Name_1, next Paste, Name_2 (pretty easy).
  6. Next searched database contains a lot of records and each search if about 1,2 seconds, then it could be possible to add optimization with NotesTimer. Put code to create timer on queryrecalc and call search code on alarm, so if user types fast, then reset timer on refresh - do not perform search. If user stopped typing, then in about second Your search code will be executed (limitation of notestimer - no millisecond execution intervals) - search, put results, refresh.
Thank You for attention