TexasSwede
texasswede@gmail.com
  • About this blog
  • My Website
  • My Resume
  • XML Export Tool
  • Photos

Monthly Archives: January 2012

Getting ready for Lotusphere

Posted on January 4, 2012 by Karl-Henry Martinsson Posted in Old Blog Post Leave a comment
Like so many other in the Yellowverse, I am getting ready to leave for Orlando. A couple of more days, and I will be on the airplane heading to (hopefully) sunny Orlando again.
My schedule is still up in the air a bit, I know that Monday and Tuesday there are probably some interviews and meetings scheduled for me by IBM, and I will not know about them untilI check in.
Except for the obvious sessions (OGS, Gurupaloza, Beat the Developers and CGS), there are a couple of sessions I want to push for. They are high on my priority list as well,a nd I hope I have time to go to all of them.
 
SHOW112 – How to Build an XPages Application from Start to Finish Tim Clark and Matt White
JMP102 – The Top Things All New IBM Lotus Domino Developers Need To Know Thomas Duff and Kathy Brown
JMP106 – "Kum Bah Yah" Meets "Let’s Kick Butt" John Head and Alex Kassabov
BP108 – Worst Practices 4.0: "Orlando, We Have a Problem" Paul Mooney and Bill Buchan
BP114 – IBM Lotus Domino Server & Application Performance in the Real World Andrew Pollack
BP202 – There´s No Fixing Ugly: How to Make a Great First Impression with Your Applications Scott Good
BP205 – "I’m a Programmer Not a Firefighter!": The Low Maintenance "Notes Shop". Timothy Paque and Bruce Elgort
BP210 – The Great Code Giveaway 9: Never Gonna Let You Down Rob Novak and Viktor Krantz
 
I am not a new Domino developer, but I still hope to be able to pick up a few new tips and tricks fromDuffbert and Kathy. This is Kathy’s first LS presentation so sheneed some friendly faces in the audience.I want to see if she live-twitter during her presentation orif she can survive without twittering for an hour. :-)
Last year I submitted a suggestion for a similar session, and I am very happy to see this session at Lotusphere this year. I think that is important to get new developers interested in the platform, and give them tips and pointers. So great job, IBM!
 
See you in Orlando!
 
 
 
 
 
 

 

Code: Accessing Windows Clipboard

Posted on January 4, 2012 by Karl-Henry Martinsson Posted in Old Blog Post Leave a comment

Several years ago, I found some code to access the Win32 functions for the Windows Clipboard. I don't remember where I found it, who wrote it or if it was VB code that I modified or already written for Lotusscript. I rewrote the the code as a class and put it in a script library called "Class.Win32.ClipBoard". The complete code is listed below. In my next blog entry I will describe how I am using this class for some very convenient functions.

 

 

Option Public

Option Declare

 

Declare Private Function GetClipboardData Lib "User32" (Byval wFormat As Long) As Long

Declare Private Function SetClipboardData Lib "user32" (Byval wFormat As Long, Byval hData As Long) As Long

Declare Private Function OpenClipboard Lib "User32" Alias "OpenClipboard" (Byval hwnd As Long) As Long

Declare Private Function CloseClipboard Lib "User32" Alias "CloseClipboard" () As Long

Declare Private Function GlobalLock Lib "kernel32" Alias "GlobalLock" (Byval hMem As Long) As Long

Declare Private Function GlobalUnlock Lib "kernel32" Alias "GlobalUnlock" (Byval hMem As Long) As Long

Declare Private Function GlobalAlloc Lib "kernel32" (Byval wFlags As Long, Byval dwBytes As Long) As Long

Declare Private Function GlobalFree Lib "kernel32" (Byval hMem As Long) As Long

Declare Private Function EmptyClipboard Lib "user32" () As Long

Declare Private Function lstrcpyLP2Str Lib "kernel32" Alias "lstrcpyA" (Byval lpString1 As String, _

Byval lpString2 As Long) As Long

Declare Private Function lstrlenLP Lib "kernel32" Alias "lstrlenA" (Byval lpString As Long) As Long

Declare Private Sub MoveMemory Lib "kernel32" Alias "RtlMoveMemory" (Byval strDest As Any, _

Byval lpSource As Any, Byval Length As Any)

Declare Private Function GetFocus Lib "User32" Alias "GetFocus" () As Long 

 

Private Const CF_TEXT = 1

Private Const GMEM_MOVABLE = &H2&

Private Const GMEM_DDESHARE = &H2000&

 



Class WindowsClipboard

 

Public Property Get Contents As String

    Dim hClipboard As Long

Dim LpStrl As Long

     Dim Resultl As Long

    Dim Clipboardstr As String

 

         If (OpenClipboard(0&) <> 0) Then

            hClipboard = GetClipboardData(CF_TEXT)

            If (hClipboard <> 0) Then

                LpStrl = GlobalLock(hClipboard)

                Clipboardstr = Space$(lstrlenLP(LpStrl))

                 Resultl = lstrcpyLP2Str(Clipboardstr, LpStrl)

                GlobalUnlock(hClipboard)

             Else 

                 Clipboardstr = "NULL"

              End If

            Call CloseClipboard()

  &nbs
p;
     Else

            Clipboardstr = ""

        End If

        Contents = Clipboardstr

    End Property ' Ends the "Get" method for the "Contents" property

 

    Public Property Set Contents As String

         Dim lSize As Long

         Dim hMem As Long

         Dim pMemory As Long

        Dim temp As Variant

 

        lSize = Len(Contents)+1

        hMem = GlobalAlloc(GMEM_MOVABLE Or GMEM_DDESHARE, lSize)

        If hMem = 0 Or Isnull(hMem) Then Exit Property

        pMemory = GlobalLock(hMem)

        If pMemory = 0 Or Isnull(pMemory) Then 

            GlobalFree(hMem)

            Exit Property

        End If

         Call MoveMemory(pMemory, Contents, lSize)

        Call GlobalUnlock(hMem)

        If (OpenClipboard(0&) <> 0) Then

            If (EmptyClipboard() <> 0) Then

                temp = SetClipboardData(CF_TEXT, hMem)

             End If

            temp = CloseClipboard()

        End If

        GlobalFree(hMem)

    End Property ' Ends the "Set" method for the "Contents" property

 

End Class

 

 

 

14 Years Ago…

Posted on January 3, 2012 by Karl-Henry Martinsson Posted in Old Blog Post Leave a comment

This Sunday it was 14 years ago I stepped onto an airplane in Stockholm, Sweden. In the morning hourse of January 1, 1998, my dad and my sister took me to the airport for my move to the US. I had married Angie back in August, and soon after that she told me she wanted to move back to the US. I applied for and got a resident visa (green card) and got a job with IDG in Boston. Initially we had planned to move to Seattle, but when I was offered the job in Boston I took that one instead.

Some 18 hours later I landed in Spokane, WA, where Angie met me. She had been staying with her mom, who lived in northern Idaho, while I got our appartment in Sweden packed up in 13 moving boxes (that is what I could afford to ship) and I got everything finished at my previous job at IDG in Sweden. My last task was to build an editorial system in Lotus Notes 4.6, that I built in 3 weeks. By the way, this system is still in use today, having survived several attempts to have it replaced with different other publishing systems.

After four days of driving cross-country from Idaho to Boston, we got an apartment and I started working as a full-time Lotus Notes developer on January 7.

Much have happened since. In 2000 we had our son Erik, in May 2002 we moved to Texas and I started working at Deep South as a Sr. Lotus Notes developer, in late summer of 2002 we moved into our first house, and then in July 2003 Angie and I separated and finally divorced aftyer 6 years of marriage.

It is interesting that I now have been working with Lotus Notes almost three times the time I was married, despite all the claims I have seen for many years that "Notes is Dead"…

As always, it will be exciting to see what the coming year brings me, both on a personal and professional level. Perhaps I will finally get the time to learn Xpages and/or Java?

 

 

Free Tool: Clean your NAB

Posted on January 3, 2012 by Karl-Henry Martinsson Posted in Old Blog Post Leave a comment

As a follow-up to my previous tool that let you analyze the ACL of a database, I built another tool for my admin. For different reasons, we need to keep the mailbox of terminated users, sometimes for a shorter time but sometimes for long periods of time. As far as I understand it, if a traditional approach was used to remove a user from the system, the mail file would also be deleted. So the admin put the terminated user in the Deny Access group and change the ACL of the mailfile to include a manager, supervisor or replacement.

But because of this process, AdminP will not remove the terminated user from all the groups he/she is listed in. When you have hundreds of groups, many of them nested, this could be a real headache. So I was asked to build something simple that allows us to remove one or more specified users from all groups in the Domino Directory. Below is the result. Enjoy!

Update: I tweaked the code slightly, to avoid three separate calls to GetItemValue() and to make a line shorter. The modified code is in the end, where I update the deletelog list.

 

First I created a form with 3 fields:

Form with 3 fields

‘SaveOptions’ has a default value of “0” (to prevent the form from being saved).
‘Users’ is a Names field, getting it’s values using the addresses dialog. The field is multi-value and using New Line as separator.
‘LogResult’ is a multi-value text field, again with New Line as separator.

Finally I added a button to the action bar to remove the user(s). The Lotusscript code is listed below. It is using my class for mail notifications that I blogged about in November, to send a confirmation to the user running the agent. This is useful for example when you need to log all data changes done to a system.

 
Use "Class.MailNotification"

Sub Click(Source As Button)
 Dim ws As New NotesUIWorkspace
 Dim uidoc As NotesUIDocument
 Dim session As New NotesSession
 Dim nab As NotesDatabase
 Dim view As NotesView
 Dim doc As NotesDocument
 Dim members As Variant
 Dim newmembers List As String
 Dim delmembers List As String
 Dim users As Variant
 Dim userlist List As String
 Dim user As NotesName
 Dim nmcnt As Integer
 Dim newarray() As String
 Dim ret As Integer
 Dim removelog List As String
 Dim userarr As Variant
 Dim mail As NotesMail 
 Dim mailtext As String
 Dim listname as String
 Dim updated As Boolean

 ' *** Make sure the operator is sure
 ret = Msgbox("Are you sure?",4+32+256,"WARNING")
 If ret = 7 Then
  Exit Sub
 End If

 ' *** Get a list of users in field 'Users'
 Set uidoc = ws.CurrentDocument
 users = Split(uidoc.FieldGetText("Users"),Chr$(13))
 Forall u In users
  Set user = New NotesName(u)
  userlist(Fulltrim(user.Common)) = Fulltrim(user.Common)
 End Forall

 ' *** Get all groups in NAB and process them one by one
 Set nab = New NotesDatabase(session.CurrentDatabase.Server,"names.nsf")
 Set view = nab.GetView("Groups")
 Set doc = view.GetFirstDocument
 Do While Not doc Is Nothing
  Print "Processing " & doc.GetItemValue("Listname")(0)
  Erase newmembers
  Erase delmembers
  updated = False
  ' *** Get members in the group and create a list of the ones to keep
  members = doc.GetItemValue("Members")
  nmcnt = 0
  Forall m In members
   Set user = New NotesName(m)  
   If Iselement(userlist(Fulltrim(user.Common))) = False Then
    ' User is not among the ones to delete
    newmembers(Fulltrim(user.Common)) = Fulltrim(m)
    nmcnt = nmcnt + 1
   Else
    delmembers(Fulltrim(user.Common)) = Fulltrim(m)
    updated = True
   End If
  End Forall
  ' *** Build array of members to keep
  Redim newarray(nmcnt) As String
  nmcnt = 0
  Forall nm In newmembers
   newarray(nmcnt) = nm
   nmcnt = nmcnt + 1
  End Forall
  ' *** Write array of new members back to document and save it
  If updated = True Then
   Call doc.ReplaceItemValue("Members", Fulltrim(newarray))
   Call doc.Save(True,False)
   listname = doc.GetItemValue("Listname")(0)
   Print "Updating " & listname
  End If
  Forall dm In delmembers
   removelog(listname) = removelog(listname) & dm & ";"
  End Forall
  Set doc = view.GetNextDocument(doc)
 Loop
 ' *** We are all done
 mailtext = ""
 Forall rl In removelog
  Call uidoc.FieldAppendText("LogResult", "Group '" & Listtag(rl) & "':" & Chr$(10))
  mailtext = mailtext & "Group '" & Listtag(rl) & "':" & Chr$(10)
  userarr = Split(Cstr(rl),";")
  Forall u In userarr
   Set user = New NotesName(u)     
   Call uidoc.FieldAppendText("LogResult", user.Common & Chr$(10))
   mailtext = mailtext & user.Common & Chr$(10)
  End Forall
 ' Call uidoc.FieldAppendText("LogResult", Chr$(10))
 End Forall
 Set mail = New NotesMail()
 mail.MailTo = session.CommonUserName
 mail.Subject = "[Notification] - Users removed from NAB"
 Call mail.AppendText(mailtext)
 mail.Principal = "IT Programs"
 Call mail.Send()
 Msgbox "Done removing specified user(s) from Domino Directory.",64,"Finished"
End Sub

Stack Exchange

profile for Karl-Henry Martinsson on Stack Exchange, a network of free, community-driven Q&A sites

Recent Posts

  • Domino 14 is now available
  • Domino 14 Early Access Program
  • Announced: Engage 2024
  • Integrate Node-RED with Notes and Domino
  • Notes and Domino v12 is here!

Recent Comments

  • Theo Heselmans on Announced: Engage 2024
  • Lotus Script Multi-thread Message Box [SOLVED] – Wanted Solution on ProgressBar class for Lotusscript
  • Viet Nguyen on Keep up with COVID-19 though Domino!
  • Viet Nguyen on Keep up with COVID-19 though Domino!
  • Mark Sullivan on Looking for a HP calculator? Look no further!

My Pages

  • How to write better code in Notes

Archives

  • December 2023 (1)
  • October 2023 (2)
  • September 2023 (1)
  • June 2021 (1)
  • April 2021 (2)
  • March 2021 (1)
  • August 2020 (3)
  • July 2020 (2)
  • April 2020 (2)
  • March 2020 (1)
  • December 2019 (2)
  • September 2019 (1)
  • August 2019 (2)
  • July 2019 (2)
  • June 2019 (3)
  • April 2019 (2)
  • December 2018 (1)
  • November 2018 (1)
  • October 2018 (5)
  • August 2018 (2)
  • July 2018 (3)
  • June 2018 (2)
  • May 2018 (1)
  • April 2018 (2)
  • March 2018 (1)
  • February 2018 (2)
  • January 2018 (4)
  • December 2017 (3)
  • November 2017 (2)
  • October 2017 (2)
  • September 2017 (1)
  • August 2017 (2)
  • July 2017 (6)
  • May 2017 (4)
  • February 2017 (1)
  • January 2017 (2)
  • December 2016 (2)
  • October 2016 (3)
  • September 2016 (4)
  • August 2016 (1)
  • July 2016 (2)
  • June 2016 (2)
  • May 2016 (3)
  • April 2016 (1)
  • March 2016 (4)
  • February 2016 (2)
  • January 2016 (4)
  • December 2015 (3)
  • November 2015 (2)
  • October 2015 (1)
  • September 2015 (2)
  • August 2015 (1)
  • July 2015 (5)
  • June 2015 (2)
  • April 2015 (2)
  • March 2015 (3)
  • February 2015 (2)
  • January 2015 (10)
  • December 2014 (1)
  • November 2014 (3)
  • October 2014 (3)
  • September 2014 (13)
  • August 2014 (6)
  • July 2014 (5)
  • May 2014 (3)
  • March 2014 (2)
  • January 2014 (10)
  • December 2013 (5)
  • November 2013 (2)
  • October 2013 (5)
  • September 2013 (4)
  • August 2013 (7)
  • July 2013 (3)
  • June 2013 (1)
  • May 2013 (4)
  • April 2013 (7)
  • March 2013 (8)
  • February 2013 (9)
  • January 2013 (5)
  • December 2012 (7)
  • November 2012 (13)
  • October 2012 (10)
  • September 2012 (2)
  • August 2012 (1)
  • July 2012 (1)
  • June 2012 (3)
  • May 2012 (11)
  • April 2012 (3)
  • March 2012 (2)
  • February 2012 (5)
  • January 2012 (14)
  • December 2011 (4)
  • November 2011 (7)
  • October 2011 (8)
  • August 2011 (4)
  • July 2011 (1)
  • June 2011 (2)
  • May 2011 (4)
  • April 2011 (4)
  • March 2011 (7)
  • February 2011 (5)
  • January 2011 (17)
  • December 2010 (9)
  • November 2010 (21)
  • October 2010 (4)
  • September 2010 (2)
  • July 2010 (3)
  • June 2010 (2)
  • May 2010 (3)
  • April 2010 (8)
  • March 2010 (3)
  • January 2010 (5)
  • November 2009 (4)
  • October 2009 (7)
  • September 2009 (1)
  • August 2009 (7)
  • July 2009 (1)
  • June 2009 (4)
  • May 2009 (1)
  • April 2009 (1)
  • February 2009 (1)
  • January 2009 (3)
  • December 2008 (1)
  • November 2008 (1)
  • October 2008 (7)
  • September 2008 (7)
  • August 2008 (6)
  • July 2008 (5)
  • June 2008 (2)
  • May 2008 (5)
  • April 2008 (4)
  • March 2008 (11)
  • February 2008 (10)
  • January 2008 (8)

Categories

  • AppDev (10)
  • Blogging (11)
    • WordPress (5)
  • Design (5)
    • Graphics (1)
    • UI/UX (2)
  • Featured (5)
  • Financial (2)
  • Food (5)
    • Baking (3)
    • Cooking (3)
  • Generic (11)
  • History (5)
  • Hobbies (10)
    • LEGO (4)
    • Photography (4)
  • Humor (1)
  • IBM/Lotus (178)
    • #Domino2025 (14)
    • #DominoForever (8)
    • #IBMChampion (46)
    • Administration (7)
    • Cloud (7)
    • CollabSphere (9)
    • Community (49)
    • Connect (33)
    • ConnectED (12)
    • Connections (3)
    • HCL (15)
    • HCL Master (1)
    • IBM Think (1)
    • Lotusphere (46)
    • MWLUG (25)
    • Notes/Domino (99)
      • Domino 11 (7)
    • Sametime (8)
    • Verse (14)
    • Volt (3)
    • Watson (6)
  • Life (8)
  • Microsoft (7)
    • .NET (2)
    • C# (1)
    • Visual Studio (1)
  • Movies (3)
  • Old Blog Post (259)
  • Personal (23)
  • Programming (84)
    • App Modernization (11)
    • Formula (4)
    • Lotusscript (47)
    • NetSuite (4)
      • SuiteScript (3)
    • node.js (4)
    • XPages (4)
  • Reviews (9)
  • Sci-Fi (4)
  • Software (24)
    • Flight Simulator (2)
    • Games (4)
    • Open Source (2)
    • Utilities (6)
  • Technology (37)
    • Aviation (3)
    • Calculators (2)
    • Computers (6)
    • Gadgets (7)
    • Mobile Phones (7)
    • Science (3)
    • Tablets (2)
  • Travel (7)
    • Europe (1)
    • Texas (2)
    • United States (1)
  • Uncategorized (16)
  • Web Development (50)
    • Frameworks (23)
      • Bootstrap (14)
    • HTML/CSS (12)
    • Javascript (32)
      • jQuery (23)
  • Prev
  • 1
  • 2

Administration

  • Log in
  • Entries feed
  • Comments feed
  • WordPress.org

Tracking

Creeper
MediaCreeper
  • Family Pictures
© TexasSwede 2008-2014