You can find my presentation from yesterday here.
I plan to publish the speaker notes soon, after I clean them up some.
You can find my presentation from yesterday here.
I plan to publish the speaker notes soon, after I clean them up some.
The session schedule for MWLUG in Atlanta is now online. The conference is less than 4 weeks, and there is a very strong lineup of speakers. Many have been presenting in the Best Practices track at Lotussphere fo years, and this conference is well worth attending. The cost is only $50, and there are still inexpensive flights left. Registration is still open, as I write this.
I will present my session AD102 Break out of the box – Integrate existing Domino data with modern websites on Wednesday afternoon, starting at 4.30pm. Hope to see you in Atlanta!
Microsoft today released the latest version of their development environment Visual Studio. There are even free versions, including the complete IDE Visual Studio Community and the code editor Visual Studio Code (available for Widnows, Linux and OSX).
Visual Studio now includes even more tools for cross platform mobile development for iOS and Android. There is even an Android emulator included. The web development part supports tools and frameworks like Angular, Bootstrap, jQuery, Backbone and Django.
And naturally the IDE also supports Windows, including Windows 10 (expected to be released at the end of the month).
I have been using tools in the Visual Studio family for many years, I started with a beta of Visual Basic 1.0 a long time ago, and used all version up to and including VB 6.0. I also played around some with Visual C++ and even Visual J++. After that I focused mainly on Lotus Notes development, but recently I have started some C#/.NET projects at work using Visual Studio Community 2013.
It is less than 7 weeks left until MWLUG, the Midwest Lotus User Group conference. This year the conference takes place in Atlanta, between August 19 and 21. During the three days there will be over 40 technical session and workshops on collaboration, receptions and networking opportunities, as well as access to experts of IBM solutions, both from IBM and other companies. The topics includes application development, system administration, best practices, customer buisness cases and innovation/future plans by IBM. Breakfast and lunch is included for two days as well. And all this for the cost of only $50 per person! The event takes place at Ritz-Carlton in downtown Atlanta. There is a block of rooms reserved at a special conference rate of $149.00 per night.
One of the sessions will also mark my personal debute as a speaker at a conference. I will present “Break out of the box – Integrate existing Domino data with modern websites” where I will talk about how to integrate websites built either within Domino or on other platforms with backend data that resides in a Domino database. I will talk about how you can build a modern looking website using tools like jQuery and Bootstrap and seamlessly integrate them with existing data on your trusty Domino server using JSON and Ajax. I will also provide plenty of example code ready for you to bring home and start playing with.
A number of IBM Champions will be presenting, as well as IBMers and other industry experts. So no matter your interest, I am sure you will find plenty of good sessions. I am sure I will have a hard time picking which sessions to attend!
So what are you waiting for? Go to http://www.mwlug.com and register! See you there!
There is a question in the IBM DeveloperWorks forum for Notes/Domino 8 about how to calculate the number of years, months and days between two dates. Then the poster wanted to calculate the sum of two such date ranges and return that as years, months and days as well.
Since the lack of formatting in the forum makes it hard to read the code, I decided to simply post it here on my blog. As always, there are several ways to write the code. One could for example use Mod (a very under-used function that many developers don’t even know about) to help calculate the number of years, months and days.
I also include a function I use to calculate the number of business days between two dates. This could be used to calculate how long a ticket has been open in a help desk system, where you usually don’t want to include Saturday and Sunday in the count.
Simply change diffOne = Days(startDate,endDate) to diffOne = BusinessDays(startDate,endDate).
Option Public Option Declare Type Components yearCount As Integer monthCount As Integer dayCount As Integer End Type Sub Initialize '*** Declare variable for componentized date Dim compOne As Components Dim compTwo As Components Dim compSum As Components '*** Declare variables for day difference count Dim diffOne As Integer Dim diffTwo As Integer '*** Declare start and end date variables Dim startDate As String Dim endDate As String '*** First date range startDate = "01/01/2011" endDate = "03/02/2013" diffOne = Days(startDate,endDate) Call DayCountToComponents(diffOne, compOne) MsgBox compOne.yearCount & " years " & _ compOne.monthCount & " months " & compOne.dayCount & " days" '*** Second date range startDate = "04/03/2012" endDate = "08/17/2015" diffTwo = Days(startDate,endDate) Call DayCountToComponents(diffTwo, compTwo) MsgBox compTwo.yearCount & " years " & _ compTwo.monthCount & " months " & compTwo.dayCount & " days" '*** Sum of first and second date range Call DayCountToComponents(diffOne + diffTwo, compSum) MsgBox compSum.yearCount & " years " & _ compSum.monthCount & " months " & compSum.dayCount & " days" End Sub %REM Function DayCountToComponents Description: Convert day count to years, month and days %END REM Function DayCountToComponents(dayCount As Integer,components As Components) As Boolean Dim daysLeft As Integer On Error GoTo errHandler components.yearCount = Int(dayCount/365) daysLeft = dayCount - components.yearCount * 365 components.monthCount = Int(daysLeft/30) daysLeft = dayCount - (components.yearCount * 365) - (components.monthCount * 30) components.dayCount = daysLeft '*** Return DayCountToComponents = True exitFunction: Exit Function errHandler: DayCountToComponents = True Resume exitFunction End Function %REM Function Days Description: Get the number of days between two dates %END REM Function Days(startDate As Variant,endDate As Variant) As Integer Days = Int(CDbl(CDat(endDate))-CDbl(CDat(startDate))) End Function %REM Function BusinessDays Description: Get the number of business days (Monday-Friday) between two dates %END REM Function BusinessDays(startDate As Variant,endDate As Variant) As Integer Dim startDT As NotesDateTime Dim endDT As NotesDateTime Dim cnt As Integer On Error GoTo errHandler Set startDT = New NotesDateTime(startDate) Set endDT = New NotesDateTime(endDate) cnt = 0 Do Until CDbl(startDT.Lslocaltime) > CDbl(endDT.Lslocaltime) If Weekday(startDT.Lslocaltime)<7 Then If Weekday(startDT.Lslocaltime)>1 Then cnt = cnt + 1 End If End If Call startDT.Adjustday(1, True) Loop BusinessDays = cnt exitFunction: Exit Function errHandler: BusinessDays = 0 Resume exitFunction End Function
A question was posted in the IBM DeveloperWorks forum for Notes/Domino 8 about the possibility to detect from within Notes if a computer is equipped with a touch screen. The answer was that you have to check if a specific DLL is installed, which is done though the registry.
The original posted then asked how to do that in Lotusscript, so I deceded to simply post some code I am using. I did not write this code, and I don’t know who originally did. I think I may have taken some VB code and simply adapted it for Lotusscript. I plan to rewrite this a s a class when I have some time. In the mean time, here is the code.
Option Public Option Declare Dim REG_NONE As Long Dim REG_SZ As Long Dim REG_EXPAND_SZ As Long Dim REG_BINARY As Long Dim REG_DWORD As Long Dim REG_DWORD_LITTLE_ENDIAN As Long Dim REG_DWORD_BIG_ENDIAN As Long Dim REG_LINK As Long Dim REG_MULTI_SZ As Long Dim REG_RESOURCE_LIST As Long Dim REG_FULL_RESOURCE_DESCRIPTOR As Long Declare Function RegCloseKey Lib "advapi32.dll" (Byval hKey As Long) As Long Declare Function RegCreateKeyEx Lib "advapi32.dll" Alias "RegCreateKeyExA" (Byval hKey As Long, _ Byval lpSubKey As String, Byval Reserved As Long, Byval lpClass As String, _ Byval dwOptions As Long, Byval samDesired As Long, Byval lpSecurityAttributes As Long, _ phkResult As Long, lpdwDisposition As Long) As Long Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (Byval hKey As Long, _ Byval lpSubKey As String, Byval ulOptions As Long, Byval samDesired As Long, _ phkResult As Long) As Long Declare Function RegSetValueExString Lib "advapi32.dll" Alias "RegSetValueExA" (Byval hKey As Long, _ Byval lpValueName As String, Byval Reserved As Long, Byval dwType As Long, Byval lpValue As String, _ Byval cbData As Long) As Long Declare Function RegSetValueExLong Lib "advapi32.dll" Alias "RegSetValueExA" (Byval hKey As Long, _ Byval lpValueName As String, Byval Reserved As Long, Byval dwType As Long, lpValue As Long, _ Byval cbData As Long) As Long Declare Function RegQueryValueExString Lib "advapi32.dll" Alias "RegQueryValueExA" _ (Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, _ Byval lpData As String, lpcbData As Long) As Long Declare Function RegQueryValueExLong Lib "advapi32.dll" Alias "RegQueryValueExA" _ (Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, _ lpData As Long, lpcbData As Long) As Long Declare Function RegQueryValueExNULL Lib "advapi32.dll" Alias "RegQueryValueExA" _ (Byval hKey As Long, Byval lpValueName As String, Byval lpReserved As Long, lpType As Long, _ Byval lpData As Long, lpcbData As Long) As Long ' --- Registry key values Const HKEY_CLASSES_ROOT = &H80000000 Const HKEY_CURRENT_USER = &H80000001 Const HKEY_LOCAL_MACHINE = &H80000002 Const HKEY_USERS = &H80000003 Const HKEY_CURRENT_CONFIG = &H80000005 ' --- Registry return values Const ERROR_NONE = 0 Const ERROR_BADDB = 1 Const ERROR_BADKEY = 2 Const ERROR_CANTOPEN = 3 Const ERROR_CANTREAD = 4 Const ERROR_CANTWRITE = 5 Const ERROR_OUTOFMEMORY = 6 Const ERROR_INVALID_PARAMETER = 7 Const ERROR_ACCESS_DENIED = 8 Const ERROR_INVALID_PARAMETERS = 87 Const ERROR_NO_MORE_ITEMS = 259 ' --- Registry access key Const KEY_ALL_ACCESS = &H3F Const REG_OPTION_NON_VOLATILE = 0 Sub Initialize REG_NONE = 0 REG_SZ = 1 REG_EXPAND_SZ = 2 REG_BINARY = 3 REG_DWORD = 4 REG_DWORD_LITTLE_ENDIAN = 4 REG_DWORD_BIG_ENDIAN = 5 REG_LINK = 6 REG_MULTI_SZ = 7 REG_RESOURCE_LIST = 8 REG_FULL_RESOURCE_DESCRIPTOR = 9 End Sub Function SetValueEx(Byval lngHKey As Long, strValueName As String, lngType As Long, varValue As Variant) As Long Dim lngValue As Long Dim strValue As String Select Case lngType Case REG_SZ strValue = varValue & Chr(0) SetValueEx = RegSetValueExString(lngHKey, _ strValueName, _ 0&, _ lngType, _ strValue, _ Len(strValue)) Case REG_DWORD lngValue = varValue SetValueEx = RegSetValueExLong(lngHKey, _ strValueName, _ 0&, _ lngType, _ lngValue, _ 4) End Select End Function Sub RegistryCreateKey(dblHiveID As Double, strBaseKey As String, strKey As String, strData As String) Dim lngResult As Long Dim lngDisplay As Long Dim intReturn As Integer lngResult = 0 lngDisplay = 0 intReturn = RegCreateKeyEx(Byval dblHiveID, _ Byval strBaseKey, _ Byval 0&, _ Byval "REG_SZ", _ Byval 0&, _ Byval KEY_ALL_ACCESS, _ Byval 0&, _ lngResult, _ lngDisplay) intReturn = RegSetValueExString(Byval lngResult, _ Byval strKey, _ Byval 0&, _ Byval 1&, _ Byval strData, _ Byval Len(strData)) End Sub Function RegistryGetValue(dblHiveID As Double, strKeyName As String, strValueName As String, _ strDefaultValue As Variant) As Variant Dim lngReturn As Long ' result of the API functions Dim lngHKey As Long ' handle of opened key Dim varValue As Variant ' setting of queried value On Error Goto RegistryGetValueError lngReturn = RegOpenKeyEx(dblHiveID, strKeyName, 0, _ KEY_ALL_ACCESS, lngHKey) lngReturn = RegistryQueryValueEx(lngHKey, strValueName, varValue) RegCloseKey (lngHKey) If (varValue = "") Then RegistryGetValue = strDefaultValue Else RegistryGetValue = varValue End If Exit Function RegistryGetValueError: RegistryGetValue = strDefaultValue End Function Function RegistryQueryValueEx(Byval lngHKey As Long, Byval strValueName As String, _ varValue As Variant) As Long Dim lngDataPntr As Long Dim lngReturn As Long Dim lngType As Long Dim lngValue As Long Dim strValue As String On Error Goto RegistryQueryValueExError ' Determine the size and type of data to be read lngReturn = RegQueryValueExNULL(lngHKey, strValueName, 0&, _ lngType, 0&, lngDataPntr) If (lngReturn <> ERROR_NONE) Then Error 5 End If Select Case lngType ' For strings Case REG_SZ: strValue = String(lngDataPntr, 0) lngReturn = RegQueryValueExString(lngHKey, _ strValueName, 0&, _ lngType, strValue, lngDataPntr) If (lngReturn = ERROR_NONE) Then varValue = Trim(Left(strValue, lngDataPntr - 1)) Else varValue = FullTrim("") 'returns empty End If ' For DWORDS Case REG_DWORD: lngReturn = RegQueryValueExLong(lngHKey, _ strValueName, 0&, _ lngType, lngValue, lngDataPntr) If (lngReturn = ERROR_NONE) Then varValue = lngValue End If Case Else ' all other data types not supported lngReturn = -1 End Select RegistryQueryValueExExit: RegistryQueryValueEx = lngReturn Exit Function RegistryQueryValueExError: Resume RegistryQueryValueExExit End Function
Here is another little code snippet I want to share. I use it all the time in my Lotusscript-based Domino web agents, and I figured that other could benefit from it as well. It is just an easy way to check for and read the name-value pairs (arguments) passed from the browser to the web server by HTTP GET or POST calls.
Put the code below in a script library, I call it Class.URL:
%REM Library Class.URL Created Oct 9, 2014 by Karl-Henry Martinsson Description: Lotusscript class to handle incoming URL (GET/POST). %END REM Option Public Option Declare %REM Class URLData Description: Class to handle URL data passed to web agent %END REM Class URLData p_urldata List As String %REM Sub New() Description: Create new instance of URL object from NotesDocument %END REM Public Sub New() Dim session As New NotesSession Dim webform As NotesDocument Dim tmp As String Dim tmparr As Variant Dim tmparg As Variant Dim i As Integer '*** Get document context (in-memory NotesDocument) Set webform = session.DocumentContext '*** Get HTTP GET argument(s) after ?OpenAgent tmp = FullTrim(StrRight(webform.GetItemValue("Query_String")(0),"&")) If tmp = "" Then '*** Get HTTP POST argument(s) after ?OpenAgent tmp = FullTrim(StrRight(webform.GetItemValue("Request_Content")(0),"&")) End If '*** Separate name-value pairs from each other into array tmparr = Split(tmp,"&") '*** Loop through array, split each name-value/argument For i = LBound(tmparr) To UBound(tmparr) tmparg = Split(tmparr(i),"=") p_urldata(LCase(tmparg(0))) = Decode(tmparg(1)) Next End Sub %REM Function GetValue Description: Get value for specified argument. Returns a string containing the value. %END REM Public Function GetValue(argname As String) As String If IsElement(p_urldata(LCase(argname))) Then GetValue = p_urldata(LCase(argname)) Else GetValue = "" End If End Function %REM Function IsValue Description: Check if specified argument was passed in URL or not. Returns boolean value (True or False). %END REM Public Function IsValue(argname As String) As Boolean If IsElement(p_urldata(LCase(argname))) Then IsValue = True Else IsValue = False End If End Function '*** Private function for this class '*** There is no good/complete URL decode function in Lotusscript Private Function Decode(txt As String) As String Dim tmp As Variant Dim tmptxt As String tmptxt = Replace(txt,"+"," ") tmp = Evaluate(|@URLDecode("Domino";"| & tmptxt & |")|) Decode = tmp(0) End Function End Class
It is now very easy to use the class to check what values are passed to the agent. Below is a sample agent:
Option Public Option Declare Use "Class.URL" Sub Initialize Dim url As URLData '*** Create new URLData object Set url = New URLData() '*** MIME Header to tell browser what kind of data we will return Print "content-type: text/html" '*** Check reqired values for this agent If url.IsValue("name")=False Then Print "Missing argument 'name'." Exit Sub End If '*** Process name argument If url.GetValue("name")="" Then Print "'Name' is empty." Else Print "Hello, " + url.GetValue("name") + "!" End If End Sub
It is that easy.
If my proposal for a session at ConnectED is accepted, you will about how to use jQuery and Bootstrap to retrieve data in .NSF databases through Lotusscript agents, and I will be using this class in my demos. So see this as a preview.
If the session doesn’t get selected by IBM, I plan to record it and post it somewhere online later.
The premise of the session is that you have data in a Domino database, but for some reason you can’t use XPages. Your company may be on an older version of Notes/Domino with no plans/budget to upgrade, the web developer don’t know XPage and have no time to learn it, or the data will be retreived from some other Web based system, perhaps WordPress.
Update: The session was not accepted at ConnectED, but I will present it at WMLUG in Atlanta on August 19, 2015.
Paul Mooney and Bill Buchan returns with a brand new Worst Practices at IBM Connect 2013.
This session alone is almost worth the cost to attend Lotusphere/Connect/ConnectED.
There is a slight skip towards the end, when I had to switch batteries. Otherwise you have the whole session, including the warm-up performance.
I recorded this video of the session JMP101 IBM Lotus Domino XPages JumpStart at Lotusphere 2012 in Orlando. The conference, later renamed IBM Connect and now renamed again to IBM ConnectED, will take place again in January 2015. Perhaps this video will get you inspired to do some XPages development, or you can show it to your boss as a good example of what you can learn at ConnectED.
Hope to see you in Orlando in January!
During June and most of July this year, I did not do much/any programming, due to me recovering from surgery. At work I also do more administration work and research, leaving less time for actual programming and even less time to pick up new skills like XPages. Coming back and starting writing code again made me realize how much I enjoy programming.
I miss writing code and solving problems by writing a program that help our users (or me) accomplish something faster and better than before. I enjoy posting code here on my blog, as well as on Stack Overflow and in the developerWorks forums. If I can help someone, like so many have been helping me in the past, at the same time as I get to write code and have fun, that is a double whammy.
But even writing code for myself, just for fun and to learn new things is enjoyable to me even after all these years. In a way it is me against the computer. I get to make the machine do what I want by taking a problem or process and breaking it down in smaller and smaller pieces until I have a working solution. Every time I come up with a smarter or more clever way to do something, I get excited and happy.
I love learning new things, and in the field of programming (as in the rest of IT), learning never ends. Hopefully I soon will have time to sit down and view some courses at Lynda.com as well as watch some of David Leedy’s excellent Notes-in-9 tutorials, to improve my skills and add more/new tools to my toolbox. And to have fun.