Sign in to follow this  
Followers 0
gcue

convert LotusScript to au3 <please>

18 posts in this topic

#1 ·  Posted (edited)

hello,

i am trying to convert this vbs script to au3.. any help would be very appreciated!

(the script is to clean-up the contents of some notes NSF files - cache.ndk and bookmarks.nsf - perhaps some of you may find use for it also!)

'bookmark.nsf cleanup
    Set DB = Session.GetDatabase( "", "bookmark.nsf", False)
    
    Set View = DB.GetView("ByURL")
    Set Doc = view.GetFirstDocument
    
    Do Until doc Is Nothing
        Call Doc.Remove(True)
        Set Doc = view.GetFirstDocument
    Loop    
        
    Messagebox "Clean up completed.  Please restart Notes", OK, "Finished"

many thanks

Edited by gcue

Share this post


Link to post
Share on other sites



Assigning variable types (i.e. "Dim Session As New NotesSession") is not VBScript. More like Visual Basic (VB) with a notes library referenced to provide those types/classes.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

ok i managed to convert the last part to:

$Session = ObjCreate("Notes.NotesSession")
    $Bookmark_db = $Session.GetDatabase("", "C:\lotus\notes\data\bookmark.nsf", False)
    $Bookmark_view = $Bookmark_db.GetView("ByURL")
    $Bookmark_Doc = $Bookmark_view.GetFirstDocument


Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $Nothing = $oVBS.eval("Nothing")
$oVBS = $Nothing

Do
        ;$Bookmark_Doc.Remove(True)
        $Bookmark_Doc = $Bookmark_view.GetFirstDocument
Until $Bookmark_Doc = $Nothing

i just need help converting one more line:

Call Doc.Remove(True)

ive tried:

$Bookmark_Doc.Remove(True)

$Bookmark_Doc.Remove.True

$Bookmark_Doc.Remove

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Try this:

$Bookmark_Doc.Remove(-1)

"True" sometimes has a squishy definition when you pass it from one language to another.

:)

P.S. If -1 doesn't work for TRUE, try the same thing you did with NOTHING:

Global Const $fTRUE = $oVBS.eval("True")

;)

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

hey psalty =)

i tried both ways - neither worked... :)

any other thoughts?

$bookmark_file = "c:\lotus\notes\data\bookmark.nsf"
;$bookmark_file = "c:\lotus\notes\data\cache.ndk"

$Session = ObjCreate("Notes.NotesSession")
;$Bookmark_db = $Session.GetDatabase("", $bookmark_file, False)
$Bookmark_db = $Session.GetDatabase("", $bookmark_file)
$Bookmark_view = $Bookmark_db.GetView("ByURL")
$Bookmark_Doc = $Bookmark_view.GetFirstDocument

Local $oVBS = ObjCreate("ScriptControl")
$oVBS.language = "VBScript"
Global Const $Nothing = $oVBS.eval("Nothing")
$oVBS = $Nothing

Local $oVBS2 = ObjCreate("ScriptControl")
$oVBS2.language = "VBScript"
Global Const $fTRUE = $oVBS2.eval("True")
$oVBS2 = $fTRUE

Do
    $Bookmark_Doc = $Bookmark_view.GetFirstDocument
    $Bookmark_Doc.Remove($fTRUE)
        ;$Bookmark_Doc.Remove(-1)
    ;MsgBox(0,"", $Bookmark_Doc)
Until $Bookmark_Doc = $Nothing

Share this post


Link to post
Share on other sites

$Bookmark_Doc.Remove("TRUE")

Maybe it will interpret the string?

Pretty weak, I know, but nothing to test against as I (thankfully) don't have Lotus Notes.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

yep i tried that.. no dice :)

Share this post


Link to post
Share on other sites

at this point, should i just spawn off a vb script and auto delete it when done? hmm i think i saw someone do that before here in autoit...

Share this post


Link to post
Share on other sites

at this point, should i just spawn off a vb script and auto delete it when done? hmm i think i saw someone do that before here in autoit...

Wait, you a working script if you save it as a .vbs and run it with cscript?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

heres the example i was talking about...

http://www.autoitscript.com/forum/index.php?showtopic=103657&view=findpost&p=734173

Share this post


Link to post
Share on other sites

heres the example i was talking about...

http://www.autoitscript.com/forum/index.php?showtopic=103657&view=findpost&p=734173

Running vbscript code doesn't even require a file. You can create a WScript shell object, set the code a string of the whole script and then .run it. I think Dale Hohm posted that the first time I saw it.

But it doesn't matter if you don't have working VBScript code to begin with.

So what am I missing? I thought you had VB (not VBScript) code and were trying to convert to AutoIt.

If it's really working VBScript code to begin with, then you can shell out and run it from AutoIt just fine (but then we should have been able to make it work inside AutoIt too).

If it really is Visual BASIC (not VBScript) then it won't work in a scripting shell any better than it does in AutoIt.

So the question is still the same: Do you have a WORKING VBScript that you can already run via cscript outside of AutoIt?

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

looks like the script is a lotuscript! arrghh looks just like visual basic

Share this post


Link to post
Share on other sites

looks like the script is a lotuscript! arrghh looks just like visual basic

To quote the sage philosopher, Homer: "Doh!" :)

But I hope you got the idea that even if it WAS VB (not VBScript), you would not be able to translate it straight to AutoIt. VB and VBScript are not the same.

;)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

if it was vb, can i use autoit to throw it into an excel doc and run it from there? (with the wksheet hidden) ?

Share this post


Link to post
Share on other sites

if it was vb, can i use autoit to throw it into an excel doc and run it from there? (with the wksheet hidden) ?

You could try.

Excel doesn't run VB either (exactly). The MS Office products run Visual Basic for Applications (VBA), which is closer to VB but still not the same thing. The problem is that in the Excel environment, the Lotus libraries might not be available.

:)


Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post


Link to post
Share on other sites

I do not have any Lotus/Domino programs installed anymore but found this in an old script I wrote that reads through the Inbox of a Mailin database and deletes all entries in the Inbox:

$Session = ObjCreate("Notes.NotesSession")
$MailDbName = "adminche.nsf"
;Open the mail database in notes
$Maildb = $Session.GetDatabase ("", $MailDbName)
If Not $Maildb.IsOpen  Then
    $Maildb.OPENMAIL
EndIf
$ntView = $Maildb.GETVIEW ("($Inbox)")
$ntNavigator = $ntView.CREATEVIEWNAV ()
$ntViewEntry = $ntNavigator.GETLASTDOCUMENT ()
While 1
;~     ' for each document in the inbox
    If Not IsObj($ntViewEntry) Then ExitLoop
    $ntDocument = $ntViewEntry.Document
    $Subject = $ntdocument.GETFIRSTITEM ("subject")
    ConsoleWrite("Processing record :" & $Subject.Text & " ")
    $PostedDate = $ntdocument.GETFIRSTITEM ("PostedDate")
    ConsoleWrite("Date:" & $PostedDate.Text & " -> ")
    ; remove record
    $ntViewEntry = $ntNavigator.GetPrevDocument ($ntViewEntry)
    $ntdocument.REMOVEFROMFOLDER ("($Inbox)")
    ConsoleWrite(@LF)
WEnd

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

got it to work - yipeeeeee!!!!!!

thank you for all your input and help

here's what it looks like

$bookmark_file = $npath & "\bookmark.nsf"
    $cache_file = $npath & "\cache.ndk"

    $session = ObjCreate("Notes.NotesSession")

    $bookmark_db = $session.GetDatabase("", $bookmark_file, False)
    $bookmark_view = $bookmark_db.GetView("ByURL")
    $bookmark_view.AllEntries.RemoveAll(True)

    $cache_db = $session.GetDatabase("", $cache_file, False)
    $cache_view = $cache_db.GetView("ByURL")
    $cache_view.AllEntries.RemoveAll(True)

who would have thought eh? what can i look up to find out this syntax next time??

again, many thanks!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0