• Browse Blogs
  • My Blog
  • My Updates

+Tags Get help with tags?

  • View as cloud  | list

+ Similar Blogs

photo

Lotus Nut

111 Entries |  Chris Whisonant
Updated 
RatingsRatings 23     CommentsComments 157
photo

Big Mutant Bl...

49 Entries |  Michael Smelser
Updated 
RatingsRatings 1     CommentsComments 49
photo

Yellow is the...

72 Entries |  Tim Tripcony
Updated 
RatingsRatings 2     CommentsComments 34
photo

Patrick Picar...

62 Entries |  Patrick Picard
Updated 
RatingsRatings 2     CommentsComments 112
photo

off the Hook ...

53 Entries |  Scott Hooks
Updated 
RatingsRatings 6     CommentsComments 81

+ Blog Authors  

All entries tagged with programming

1 - 3 of 3
  • Previous
  • Next
  • Page   1

Generate Excel spreadsheets using Lotusscript

Karl-Henry Martinsson |   | Tags:  lotusscript programming | Comments (1)  |  Visits (557)

 Bill Buchan just wrote about exporting data to Excel using a CSV file. There is actually a cool and surprisingly easy way to generate documents that show up in Excel as real spreadsheets, with formatting, colors, etc.

Simply create a file containing a HTML table. It may even work with multiple tables. You can use tags like <B> and <I> for bold/italic, and use the color attribute to set text color and background color. Use the colspan attribute to split a cell over multiple columns.

Save the file in Lotusscript as a regular text file, but with the extension XML XLS. Excel, as well as OpenOffice.org, will read the HTML and present as a nice spreadsheet.

No RatingsRatings 0

Parse URL in Domino agent

Karl-Henry Martinsson |   | Tags:  web code_snippet programming lotusscript | Comments (3)  |  Visits (1,179)

Not Forum Friday, but Usenet Tuesday. :-)  A user in comp.groupware.lotus-notes.programmer had a question about generating Notes document remotely/in an automated way from another web application, using Perl:

 

> We have a Lotus Notes application and we would like to automate
> creating a new document or record in that application from another web
> based application.
>
> Here are the details:
> User action on web application triggers a PERL script to create a new
> record (document) in Lotus Notes (or Domino).

 

Here is my suggestion:

 

Create an agent that read the URL parameters you send to it.
Let's call the agent CreateNewDocument, and have two fields we want to fill out when the document is created. The Perl script can then call the URL like this:
 
 
The agent read the arguments and populate the corresponding fields, then save the document. I would highly recommend using a list to store the parameters, then you have a generic function you can re-use in any application.
In my article in the November/December 2006 issue of The View (starting on page 25) you have code for this.
 
Here is a class I just wrote to parse an incoming HTTP GET or POST. Put it in a script library called for example "URL.class":
 
Class URLclass
Public url As String
Private params List As String

Public Sub New()
  Dim session As New NotesSession
  Dim doc As NotesDocument
  Set doc = session.DocumentContext ' Document with all CGI variables
  ' Check if HTTP GET or POST was used...
  If Instr(doc.Query_String(0),"&") > 0 Then  ' GET was used
   url = doc.Query_String(0) 
  Elseif Instr(doc.Request_Content(0),"&") > 0 Then ' POST was used
   url = "&" & doc.Request_Content(0)
  Else          ' No parameters
   Exit Sub
  End If
End Sub

Public Function GetParams() As Variant
  Dim offset As Integer
  Dim startpos As Integer
  Dim midpos As Integer
  Dim endpos As Integer
  Dim nextpos As Integer
  Dim dataname As String
  Dim datavalue As String
  startpos = Instr(url,"&")    ' Start of first parameter
  Do While Not startpos = 0
   nextpos = Instr(startpos+1, url, "&") ' Start of next parameter
   If nextpos = 0 Then     ' We reached the end
    endpos = Len(url)+1
   Else
    endpos = nextpos
   End If
   midpos = Instr(startpos+1, url, "=") ' Position of = character
   dataname = Mid$(url,startpos+1,midpos-startpos-1)  ' Get name
   datavalue = Mid$(url,midpos+1,endpos-midpos-1)  ' Get value
   params(dataname) = datavalue   ' Add value to list
   startpos = nextpos     ' Set new start position
  Loop
  GetParams = params
End Function

End Class
 

Here is a sample agent that uses the class and print the arguments to the browser. Just expand on that code to create the document in the database:

 

Option Public
Option Declare
Use
"URL.class"
 

Sub Initialize
 Dim url As New URLclass

 Dim params As Variant
 params = url.GetParams()
 Forall x In params
   Print Listtag(x) & " = " & params(Listtag(x)) & "<br>"
 End Forall
End Sub

 

The LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.
No RatingsRatings 0

SNTT: Lists - the forgotten gem in Lotusscript

Karl-Henry Martinsson |   | Tags:  programming show-and-tell-thursday sntt lotusscript | Comments (2)  |  Visits (447)
OK, I know it is Friday already, but here is my Show-n-Tell-Thursday entry...

Lists are a data type that I don't think is used enough. Many Notes developers, even some that been programming in the environment for years, don't use this very powerful feature. In previous years, Bill Buchan have been talking about lists in some of his Lotussphere sessions, and when asking how many in the audience that used lists, less than 10% raised their hands.

So what are lists? They are a data type, similar to an array, but instead of using a numeric index, it uses a string as index, or tag as it is called.

This makes it easy to address items in the list, check if they exists, etc.

Here is a simple example:

Dim age List as Integer

Dim name as String

age( "karl" ) = 38

age( "erik" ) = 7

name = InputBox$( "Enter name:" )

If IsElement(age(Lcase(name))) = True Then

MsgBox name & " is " & age(lcase(name)) & " years old."

Else

MsgBox name & " does not occur in the list."

End If

This code define a list of integers, containing the age of two people. When a name is entered in the input box, IsElement is used to check if an item with that name is found in the list. If it is, the age is displayed, if not another message is displayed, saying that the name was not found.

Note that the list tag (name in this case) is case sensitive! 

To loop through a list and display all the values, use ForAll. Here is an example where we loop thorugh all the entries and display their list tags as well as the values:

Dim age List As Integer
age( "Karl" ) = 38
age( "Erik" ) = 7
Forall a In age
Msgbox Listtag(a) & " is " & a & " years old."
End Forall

Some of the things I use lists for are web agents, where I parse the URL passed for parameters, and build a list of them. Then it is very easy to write code that check for parameters and get the value if they exist.

I wrote an article about lists for The View, published in November/December 2006. You can find more details and examples there.

No RatingsRatings 0

  • Previous
  • Next
Jump to page of 1
Skip to main content link. Accesskey S
IBM Lotus Connections Help Tools About