Autor Thema: Mal eine Standard Frage ;)  (Gelesen 2824 mal)

Offline andrew22

  • Aktives Mitglied
  • ***
  • Beiträge: 126
  • Ich liebe dieses Forum!
Mal eine Standard Frage ;)
« am: 15.02.06 - 14:21:42 »
hi ho !

irgendwie merk ich gerade das mein Lotus Script Know How ganz schön nachlässt :(.

Frage : Wenn ich mehrere Script bibliotheken habe kann ich dann nicht auch in den verschiedenen Script biblos Funktionen aufrufen ?!

Beispiel -> Ich habe einen Agenten -> Dieser ruft mit Call eine Funktion auf -> Diese Funktion befindet sich in einer Script Bibliothek -> "Sub TestFunktion" -> in dieser Funktion soll nun wiederrum eine Funktion aus einer anderen Script Bibliothek aufgerufen werden und wenn möglich auch verarbeitet werden mit Call.

Hintergrund ist das ich aus einem Agenten heraus eine Funktion aufrufe die sich verteilt in mehreren Script Bibliotheken befindet wo wiederrum Funktionen etc. aufgerufen werden . Ich will jede einzelne zeitlich testen und schauen welche am längsten braucht ?!

thx  :-:

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
Re: Mal eine Standard Frage ;)
« Antwort #1 am: 15.02.06 - 14:26:23 »
Hi

Dazu müssen aber die entsprechenden use statements in den Scriptbiblotheken stehen.

in Lib1:
use "Lib2"
in Lib2:
use "Lib1"

und schon können Funktionen in Lib1, Funktionen in Lib 2 aufrufen und umgekehrt.

Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline andrew22

  • Aktives Mitglied
  • ***
  • Beiträge: 126
  • Ich liebe dieses Forum!
Re: Mal eine Standard Frage ;)
« Antwort #2 am: 15.02.06 - 14:31:30 »
und wie läuft das dann mit dem statement Set ... = ... und einem Call ?!  :-:

Offline koehlerbv

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 20.460
  • Geschlecht: Männlich
Re: Mal eine Standard Frage ;)
« Antwort #3 am: 15.02.06 - 14:33:59 »
in Lib1:
use "Lib2"
in Lib2:
use "Lib1"

und schon können Funktionen in Lib1, Funktionen in Lib 2 aufrufen und umgekehrt.

Da freut sich aber der Compiler über cross referencing  ;D

Bernhard

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
Re: Mal eine Standard Frage ;)
« Antwort #4 am: 15.02.06 - 14:34:50 »
Set gilt nur für Objekte
z.B.
dim Doc as notesdocument
dim s as notessession

set s = new notessession
set doc = s.documentContext

call ruft einfach funktionen auf z.B.
call doc.replaceitemvalue("Subject", "dies ist ein Subject")
Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline andrew22

  • Aktives Mitglied
  • ***
  • Beiträge: 126
  • Ich liebe dieses Forum!
Re: Mal eine Standard Frage ;)
« Antwort #5 am: 15.02.06 - 15:31:10 »
hmm aber irgendwie klappt das nicht :(

Meine Script Biblo schaut so aus :

Options -> hole ich die script bilbo rein die ich brauche mit USE ..

Declarations -> Dim test As Test

und dann hab ich halt ne Funktion : Sub Bla (Doc as NotesDocument)

und dort mach ich nen Set test = New ....

und rufe dann in der Funktion Methoden auf mit Call

er sollte dann eigentlich etwas in nem dokument speichern aber dat macht er nicht :(

Offline umi

  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 2.062
  • Geschlecht: Männlich
  • one notes to rule'em all, one notes to find'em....
    • Belsoft AG
Re: Mal eine Standard Frage ;)
« Antwort #6 am: 15.02.06 - 15:35:48 »
Was sagt den der Debugger dazu?

Ohne Code kann meine Kristallkugel leider nichts machen.....

Hast Du irgendwelchs ErrorHandling/Logging eingebaut?

Wird das Dokument am Schluss gespeichert?
Gruss

Urs

<:~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Jegliche Schreibfehler sind unpeabischigt
http://www.belsoft.ch
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~:>

Offline Axel

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.658
  • Geschlecht: Männlich
  • It's not a bug, it's Notes
Re: Mal eine Standard Frage ;)
« Antwort #7 am: 15.02.06 - 15:36:00 »
Was ist Test für ein Variablentyp? Set test = New....   New was?

So kommen wir nicht weiter.  Ein paar mehr Infos und auch Code wäre nicht schlecht.


Axel


Ohne Computer wären wir noch lange nicht hinterm Mond!

Offline andrew22

  • Aktives Mitglied
  • ***
  • Beiträge: 126
  • Ich liebe dieses Forum!
Re: Mal eine Standard Frage ;)
« Antwort #8 am: 15.02.06 - 15:50:50 »
Okay Ich habe die Script Libary :

Code
Stopwatch :
Options :
Option Public
Option Explicit
Declarations :
'-------------------------------------------------------------------
' Windows API declarations
'-------------------------------------------------------------------
Declare Function GetTickCount& Lib "kernel32" ()
'-------------------------------------------------------------------
' User-defined data types
'-------------------------------------------------------------------
'All information about a "Event Being Timed" will be stored in a list of type EventBeingTimedType
Type EventBeingTimedType
lngPreviousRunTime As Long     'CPU time on the stopwatch from previous run(s) for an EventBeingTimed
lngThisRunStartTime As Long     'CPU time at which the running stopwatch was started for an EventBeingTimed. If lngThisRunStartTime is not zero, the watch is running for thig EventBeingTimed.  If it is zero, the watch is stopped for this EventBeingTimed.
lngStartCalls As Long     'Number of times the stopwatch has been started for this EventBeingTimed.
End Type
'ReportRowType is used to sort watch values when building a report.  Each EventBeingTimed becomes a array element of ReportRowType.
Type ReportRowType
strName As String     'name of EventBeingTimed
lngRunTime As Long     'milliseconds active run time for an EventBeingTimed
lngStartCalls As Long     'number of times watch has been started for an EventBeingTimed
End Type
'-------------------------------------------------------------------
'Stopwatch object class
'-------------------------------------------------------------------
Class Stopwatch
     'EventList is the main data store for the Stopwatch class.  EventList is an associative array.  The index into the array is the name of EventsBeingTimed.  The list contains elements of EventBeingTimedType .
Private EventList List As EventBeingTimedType
     '-------------------------------------------------------------------
     ' New
     '-------------------------------------------------------------------
Sub New
EventList("Total run time").lngThisRunStartTime = GetTickCount()
EventList("Total run time").lngStartCalls = 1
End Sub
     '-------------------------------------------------------------------
     ' Start
     ' If there is an EventBeingTimed with this name and the watch is already running, do nothing.
     ' If there is an EventBeingTimed with this name but the watch isn't running, start the watch by placing the curent TickCount into lngThisRunStartTime for this EventBeingTimed.
     ' If there is no EventBeingTimed with this name, create and start the watch by placing the curent TickCount into lngThisRunStartTime for this EventBeingTimed.
     '-------------------------------------------------------------------
Sub Start(strEventBeingTimedName As String)
If (Iselement(EventList(strEventBeingTimedName))) Then
If (EventList(strEventBeingTimedName).lngThisRunStartTime <> 0) Then
                    'Watch already running for this EventBeingTimed (do nothing)
Else
                    'Watch stopped for this EventBeingTimed
EventList(strEventBeingTimedName).lngThisRunStartTime = GetTickCount()
End If
Else
               'Start a watch for a new EventBeingTimed
EventList(strEventBeingTimedName).lngThisRunStartTime = GetTickCount()
End If
EventList(strEventBeingTimedName).lngStartCalls = EventList(strEventBeingTimedName).lngStartCalls + 1
End Sub
     '-------------------------------------------------------------------
     ' Stop
     ' If there is an EventBeingTimed with this name and the watch is running for it:
     '      PreviousRunTime = old previous + time from this run (current Tick Count - starting time)
     '      Stop the stopwatch by setting lngThisRunStartTime to zero for this EventBeingTimed.
     '-------------------------------------------------------------------
Sub Stop(strEventBeingTimedName As String)
If (Iselement(EventList(strEventBeingTimedName))) Then
If (EventList(strEventBeingTimedName).lngThisRunStartTime <> 0) Then
EventList(strEventBeingTimedName).lngPreviousRunTime = EventList(strEventBeingTimedName).lngPreviousRunTime + (GetTickCount() - EventList(strEventBeingTimedName).lngThisRunStartTime)
EventList(strEventBeingTimedName).lngThisRunStartTime = 0
End If
End If
End Sub
     '-------------------------------------------------------------------
     ' Reset
     ' If there is an EventBeingTimed with this name, reset the PreviousRunTime, ThisRunStartTime, and StartCalls variables.
     '-------------------------------------------------------------------
Sub Reset(strEventBeingTimedName As String)
If (Iselement(EventList(strEventBeingTimedName))) Then
EventList(strEventBeingTimedName).lngPreviousRunTime = 0
EventList(strEventBeingTimedName).lngThisRunStartTime = 0
EventList(strEventBeingTimedName).lngStartCalls = 0
End If
End Sub
     '-------------------------------------------------------------------
     ' GetTime
     ' If there is an EventBeingTimed with this name and the watch is running, GetTime = PreviousRunTime + time from this run (current Tick Count - ThisRunStartTime)
     ' If there is an EventBeingTimed with this name but the watch isn't running, GetTime =  PreviousRunTime
     ' If there is no EventBeingTimed with this name, GetTime = -1
     '-------------------------------------------------------------------
Function GetTime(strEventBeingTimedName As String) As Long
If (Iselement(EventList(strEventBeingTimedName))) Then
If (EventList(strEventBeingTimedName).lngThisRunStartTime <> 0) Then
                    'Stopwatch is running for this EventBeingTimed
GetTime = EventList(strEventBeingTimedName).lngPreviousRunTime + (GetTickCount() - EventList(strEventBeingTimedName).lngThisRunStartTime)
Else
                    'Stopwatch is stopped for this EventBeingTimed
GetTime = EventList(strEventBeingTimedName).lngPreviousRunTime
End If
Else
               'There is no EventBeingTimed with this name.
GetTime = -1
End If
End Function
     '-------------------------------------------------------------------
     ' GetStartCalls
     ' If there is an EventBeingTimed with this name, return the number of calls.
     ' If there is no EventBeingTimed with this name, return -1.
     '-------------------------------------------------------------------
Function GetStartCalls(strEventBeingTimedName As String) As Long
If (Iselement(EventList(strEventBeingTimedName))) Then
GetStartCalls = EventList(strEventBeingTimedName).lngStartCalls
Else
               'There is no EventBeingTimed with this name.
GetStartCalls = -1
End If
End Function
     '-------------------------------------------------------------------
     ' GetIsRunning
     ' If there is an EventBeingTimed with this name and the watch is running, return 1.
     ' If there is an EventBeingTimed with this name but the watch isn't running, return 0.
     ' If there is no EventBeingTimed with this name, return -1
     '-------------------------------------------------------------------
Function GetIsRunning(strEventBeingTimedName As String) As Integer
If (Iselement(EventList(strEventBeingTimedName))) Then
If (EventList(strEventBeingTimedName).lngThisRunStartTime <> 0) Then
                    'Stopwatch is running for this EventBeingTimed
GetIsRunning = 1
Else
                    'Stopwatch is stopped for this EventBeingTimed
GetIsRunning = 0
End If
Else
               'No EventBeingTimed with this name
GetIsRunning = -1
End If
End Function
     '-------------------------------------------------------------------
     ' GetAllWatchValues
     '-------------------------------------------------------------------
Function GetAllWatchValues As String
Dim intEventsBeingTimed As Integer     'number of EventsBeingTimed
Dim ReportRowArray() As ReportRowType     'Same information as EventList, but is an array so it can be sorted.
Dim intCount As Integer     'counter used to loop through all ReportRowArray elements
Dim intCompletelySorted As Integer     'flag used in bubble sort
Dim Temp As ReportRowType     'swap variable used in bubble sort
          'Set time on "Total run time" event
EventList("Total run time").lngPreviousRunTime = GetTickCount() - EventList("Total run time").lngThisRunStartTime
          'Build ReportRowArray with EventBeingTimed Name, StartCalls, and RunTime for each EventBeingTimed
intEventsBeingTimed = 0
Forall EventBeingTimed In EventList
intEventsBeingTimed = intEventsBeingTimed + 1
Redim Preserve ReportRowArray(1 To intEventsBeingTimed)
ReportRowArray(intEventsBeingTimed).strName = Listtag(EventBeingTimed)
ReportRowArray(intEventsBeingTimed).lngStartCalls = EventBeingTimed.lngStartCalls
ReportRowArray(intEventsBeingTimed).lngRunTime = EventBeingTimed.lngPreviousRunTime
End Forall
          'Sort ReportRowArray - simple bubble sort (descending order)
intCompletelySorted = False
While (Not intCompletelySorted)
intCompletelySorted = True
For intCount = 1 To intEventsBeingTimed-1
If (ReportRowArray(intCount).lngRunTime < ReportRowArray(intCount + 1).lngRunTime) Then
                         'Swap array(intCount) and array(intCount + 1)
Temp = ReportRowArray(intCount)
ReportRowArray(intCount) = ReportRowArray(intCount + 1)
ReportRowArray(intCount  + 1) = Temp
intCompletelySorted = False
End If
Next
Wend
          'Add titles to return string
GetAllWatchValues = "seconds     %        calls     secs/call   event" & Chr(13) & Chr$(10)
GetAllWatchValues = GetAllWatchValues & String$(75, "=") & Chr(13) & Chr$(10)
          'Add detail rows to return string
For intCount = 1 To intEventsBeingTimed
GetAllWatchValues = GetAllWatchValues & Format$((ReportRowArray(intCount).lngRunTime/1000), "00000.000") & "   "
GetAllWatchValues = GetAllWatchValues & Format$(ReportRowArray(intCount).lngRunTime / EventList("Total run time").lngPreviousRunTime, "000.0%") & "   "
GetAllWatchValues = GetAllWatchValues & Format$(ReportRowArray(intCount).lngStartCalls, "0000000") & "   "
If (ReportRowArray(intCount).lngStartCalls > 0) Then
GetAllWatchValues = GetAllWatchValues & Format$((ReportRowArray(intCount).lngRunTime/1000) / ReportRowArray(intCount).lngStartCalls, "00000.000") & "   "
Else
GetAllWatchValues = GetAllWatchValues & "00000.000" & "   "
End If
GetAllWatchValues = GetAllWatchValues & ReportRowArray(intCount).strName & Chr(13) & Chr$(10)
Next
End Function
     '-------------------------------------------------------------------
     ' MailAllWatchValues
     '-------------------------------------------------------------------
Sub MailAllWatchValues(strSendTo As String, strSubject As String)
%REM
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim item As NotesItem
Dim body As NotesRichTextItem
Dim style As NotesRichTextStyle     'delete this line if you are not running R4.6 or later
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
Set item = doc.ReplaceItemValue("Form", "Memo")
Set item = doc.ReplaceItemValue("SendTo", strSendTo)
Set item = doc.ReplaceItemValue("Subject", strSubject)
Set body = New NotesRichTextItem(doc, "Body")
Set style = session.CreateRichTextStyle     'delete this line if you are not running R4.6 or later
style.NotesFont = FONT_COURIER     'delete this line if you are not running R4.6 or later
Call body.AppendStyle(style)     'delete this line if you are not running R4.6 or later
Call body.AppendText(Me.GetAllWatchValues)
Call doc.Send(False)
%END REM
Dim session As NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set session = New NotesSession
Set db = session.CurrentDatabase
Set doc = New NotesDocument(db)
doc.Form = "LogTest"
doc.logtest = Me.GetAllWatchValues
Call doc.Save( True, True )
End Sub
End Class

Dazu kommt ein Agent "Test Agent" :

Aufbau :
Initialize

Call TestFunction(....)

Dat wars

TestFunction befindet sich in einer anderen Script Libary die heisst Test z.B.

dort hab ich nun viele kleine Funktionen drin wie z.B. auch die Funktion TestFunction aussehen -> Sub TestFunction .....

Aussehen tut das dann so

Code
Sub TestFunction()
Set stopwatch = New Stopwatch
Call stopwatch.Start("test")
dann kommt ne If Abfrage und Felder werden gesetzt
Call stopwatch.Stop("test")
Call stopwatch.MailAllWatchValues("test", "Main loop performance test")

Nicht zu vergessen das natürlich die Script Libary Stopwatch in der Script Libary Test mit eingebunden durch Use ... und die var stopwatch deklatiert wird als Dim stopwatch As Stopwatch

und das wars eigentlich schon ...

im agenten Funktioniert das alles

aber in der script Libary nicht :(


Offline Axel

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.658
  • Geschlecht: Männlich
  • It's not a bug, it's Notes
Re: Mal eine Standard Frage ;)
« Antwort #9 am: 15.02.06 - 15:59:49 »
Auf Anhieb sehe ich jetzt mal kein Fehler. Umi hat es schon gefragt. Was sagt der Debugger?

In welchem Dokument wird denn nicht gespeichert? Das aus der Routine MailAllWatchValues?


Axel
Ohne Computer wären wir noch lange nicht hinterm Mond!

Offline andrew22

  • Aktives Mitglied
  • ***
  • Beiträge: 126
  • Ich liebe dieses Forum!
Re: Mal eine Standard Frage ;)
« Antwort #10 am: 15.02.06 - 16:23:21 »
hmmm anscheindend stört ihn in der Routine MailAllWatchValues das doc.logtest = Me.GetAllWatchValues


doc.logtest = "TEST AUSGABE"

das macht er :(


hmmm warum nur  ???

Offline Axel

  • Moderator
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 8.658
  • Geschlecht: Männlich
  • It's not a bug, it's Notes
Re: Mal eine Standard Frage ;)
« Antwort #11 am: 15.02.06 - 16:36:48 »
Ist das wirklich ein String, den du da zurückbekommt?

Du kannst mal zwei Dinge probieren.

1.  doc.logtest = CStr(Me.GetAllWatchValues)

oder

2.  Dim strTemp As String

     strTemp = Me.GetAllWatchValues
     doc.logtest = strTemp

Punkt 1 hat in einigen Fällen bei mir schon Wunder bewirkt.

Bei Punkt 2 kannst du den Rückgabewert auch mal mit einer Messagebox ausgeben, bzw. mit dem Debugger besser untersuchen.

Axel
Ohne Computer wären wir noch lange nicht hinterm Mond!

 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz