Page 1 of 1 1
Topic Options
#206245 - 2012-11-21 08:13 PM Array of variants problem
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
I've again having an issue with COM scripting and Lotus Notes. I need to lookup user details of a known Notes user. I found the method GetMailInfo

Here's my code I borrowed from IBM's example and translated to KIX:

 Code:
Break on
$Ret = SetOption("Explicit", "on")
; ---------------------------------------------------------------------------------------------------------------------
; Search Lotus Notes directory 
; ---------------------------------------------------------------------------------------------------------------------
Function LookupShortname($Shortname)
    Dim $db ; As NotesDatabase
    Dim $mynotesdir ;As NotesDirectory
   
    $mynotesdir  = $oNotesSession.getDirectory("<IP of my Notes Server>")
   
    Dim $homeserver ; As Variant
    Dim $Type
    Dim $Mail   
    $homeserver =  $mynotesdir.GetMailInfo($Shortname, True)
    ? "error returned : " @error @serror
    => I get 0 / success
    $Type = VarType($homeserver)
    => I get 8200 (Array of string)
    ? "Mail Server: " + Cstr($homeserver[0])
    => ERROR : Error in expression: this type of array not supported in expressions.!
Script: I:\Scripting\LnConfigRepair\V 0.75\Addressbook.kix
Line  : 18
    ? "Build Number: " + Cstr($homeserver[1])
    ? "Domino Version: " + Cstr($homeserver[2])
    ? "Mailfile: " 	+ Cstr($homeserver[3])
    ? "Short Name: " + Cstr(homeserver[4])
    ? "MailDomain: " + Cstr(homeserver[5])
    ? "Username: " + Cstr(homeserver[6])
    ? "internetMailAddress: " + Cstr[homeserver(7])
    ? "Out of Office: " + Cstr(homeserver[8])
EndFunction
Global $oNotesSession
Dim $Ret
Dim $Shortname
$Shortname = "sblaettl"
;
$oNotesSession = CreateObject("Notes.NotesSession")
$Ret = LookupShortname($Shortname)


Any hint how I must handle this array of string? Many thanks!


Edited by Sam_B (2012-11-21 08:21 PM)

Top
#206249 - 2012-11-21 10:25 PM Re: Array of variants problem [Re: Sam_B]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I'm not good with types, but I was working on something in the past and the following got me going. I'd be interested in hearing if this works for you...

Try
$homeserver[0].value

or
$homeserver[0].text

Top
#206250 - 2012-11-22 02:07 AM Re: Array of variants problem [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
kixtart fails to handle arrays of real types.
known issue.
only array type that works is array of variants.
there is a fix in the works but otherwise, with current kixtart, your options are limited.

adodb most likely will be able to translate the data to kixtart usable format.
_________________________
!

download KiXnet

Top
#206254 - 2012-11-22 09:51 AM Re: Array of variants problem [Re: Lonkero]
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
these are bad news... Correct me if I wrong, but to be able to use adodb for Notes, I need a Notes SQL driver being available on the client which is not the case in our environment.

I'm thinking about a workaround to implement this part of code in VB, save the output to a file and then read the file in my main script, but this is not a very clever way...

Or can anybody of you suggest another workaround?

Would help my quite a bit...

Regards from Switzerland

Top
#206255 - 2012-11-22 02:39 PM Re: Array of variants problem [Re: Sam_B]
Allen Administrator Online   shocked
KiX Supporter
*****

Registered: 2003-04-19
Posts: 4562
Loc: USA
I did a few searches mainly dealing with vbscript and found two that give hope. I have no way of testing this.

The first appears to be what I suggested above
http://www-10.lotus.com/ldd/nd6forum.nsf/0/72d14e06c0a90e76852572820054459b?OpenDocument

The second uses GetFirstItem (vbscript below)
 Code:
Do While Not fDoc Is Nothing
	ReDim Preserve fUNID(i)
	fUNID(i) = fDoc.UniversalID
						
	Set arrItem = fDoc.GetFirstItem("LastName")
	arrName = arrItem.Text
         wscript.echo arrName
 
	Set fDoc = notesView.GetNextdocument(fDoc)
	i=i+1
Loop


Powershell might also be an option.

Top
#206256 - 2012-11-22 06:06 PM Re: Array of variants problem [Re: Allen]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
no need for adodb on the server.
you can access it via kix. this most likely doesn't work but gives you an idea what I mean:
 Code:
    $stream_object = createobject("ADODB.Stream")
    $RC = $stream_object.open
    $stream_object.type = 2
    $stream_object.charset = "iso-8859-1"
    $RC = $stream_object.write($string)
    $stream_object.position = 0
    $stream_object.type = 1
    $stream_object.position = 0
    $string = $stream_object.read


these lines taken from base64 translator code. you write the bytes of the array into an object and then read as text.
it should return the first object this way but to get them all you need to alter the data.

if you really want to make it work, check out kixtart binary:
http://www.kixtart.org/downloads/jooel/KixtartBinary.zip

or kixforms.net
I stopped developing the first once I got to work on kf.net
for your needs kixbin should be just fine.
_________________________
!

download KiXnet

Top
#206257 - 2012-11-23 04:26 PM Re: Array of variants problem [Re: Lonkero]
Sam_B Offline
Getting the hang of it

Registered: 2005-10-25
Posts: 68
Loc: Bern, Switzerland
Many thanks for the feedback!

tried

$homeserver[0].value
and
$homeserver[0].text

and both get kix to crash :-(

I think GetFirstItem("Itemname") doesn't work either, because I have not a notes document returned, but an array. So I focus on the ADODB stuff..

 Code:
Function LookupShortname($Shortname)
  Dim $db ; As NotesDatabase
  Dim $mynotesdir ;As NotesDirectory
     
  $mynotesdir = $oNotesSession.getDirectory("Servername")
     
  Dim $homeserver ; As Variant
  Dim $Type
  Dim $Mail
  Dim $stream_object
  Dim $RC
  Dim $String
  
  $homeserver = $mynotesdir.GetMailInfo($Shortname, True)
  $stream_object = CreateObject("ADODB.Stream")
  $RC = $stream_object.open
  $stream_object.type = 1 ; Set input data to binary I hope...
  $RC = $stream_object.write($homeserver)
=> here I get COM exception error "write" (ADODB.Stream - Arguments are of the wrong type, are out of acceptable range, or are in conflict with one another.) [-2147352567/80020009]
  $stream_object.position = 0
  $stream_object.charset = "iso-8859-1"
  $stream_object.type = 2
  $stream_object.position = 0
  $string = $stream_object.read
  ? $string
EndFunction


Hmm, think this exercise gets to hard for me....






Edited by Sam_B (2012-11-23 04:27 PM)

Top
#206258 - 2012-11-23 05:11 PM Re: Array of variants problem [Re: Sam_B]
Lonkero Administrator Offline
KiX Master Guru
*****

Registered: 2001-06-05
Posts: 22346
Loc: OK
dang it...
there is an example with vb how to write an byte array but kinda not sure why this exercise you have fails:
http://stackoverflow.com/questions/548102/how-to-create-binaryarray-in-vbscript
_________________________
!

download KiXnet

Top
Page 1 of 1 1


Moderator:  Shawn, ShaneEP, Ruud van Velsen, Arend_, Jochen, Radimus, Glenn Barnas, Allen, Mart 
Hop to:
Shout Box

Who's Online
0 registered and 456 anonymous users online.
Newest Members
M_Moore, BeeEm, min_seow, Audio, Hoschi
17883 Registered Users

Generated in 0.032 seconds in which 0.013 seconds were spent on a total of 13 queries. Zlib compression enabled.

Search the board with:
superb Board Search
or try with google:
Google
Web kixtart.org