Posts Tagged: ‘Formelsprache’

Syntax einer Formel mit LotusScript prfen

3. Dezember 2005 Posted by Manfred Meise

Sub CheckFormulaSyntax(Byval sFormulaField As String)  
' *********************************************************************************
' FUNCTION Header
' *********************************************************************************        
'        Purpose:
'        Check the value in a field for using as formula
'        
'        Parameter:
'        sFormulaField - Fieldname where the formula was written
'        
'        Return Value:
'        -none-
'        
'        Dependencies:
'        -none-
' *********************************************************************************        

     
' ------------------------------------------------------------------------------------------------------------        
' Constants
' ------------------------------------------------------------------------------------------------------------

      REM MsgBox Icons
      Const MB_ICONSTOP = 16                        ' Critical message
      Const MB_ICONINFORMATION = 64                ' Information message
     
      REM Constance with message texts for communication with user
      Const COMPILE_SUCCESS_TITLE = "Compiled Successfully"
      Const COMPILE_SUCCESS_BODY = "There are no syntax errors, the formula compiled successfully."
      Const COMPILE_FAILURE_TITLE = "Syntax Error"
      Const COMPILE_FAILURE_BODY = "There is at least one syntax error in the formula.  It did not compile."
      Const COMPILE_FAILURE_SAVE_BODY = "There is at least one syntax error in the formula.  This document could not be saved."
     
' END Constants

     
     
' ------------------------------------------------------------------------------------------------------------
' Declarations
' ------------------------------------------------------------------------------------------------------------

      REM Object vars
      Dim ws As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      Dim doc As NotesDocument
     
      REM Message box vars
      Dim sMB_Prompt As String
      Dim nMB_Info As Long
      Dim sMB_Title As String
     
      REM additional vars
      Dim sFormula As String
      Dim vEval As Variant
     
' END Declarations

     
     
' ------------------------------------------------------------------------------------------------------------
' Initialize
' ------------------------------------------------------------------------------------------------------------

      REM Objects
      Set uidoc = ws.CurrentDocument
      Set doc = uidoc.Document
     
' END Initialize

     
     
' *********************************************************************************
' MAIN PROGRAM
' *********************************************************************************        

      sFormula = | @CheckFormulaSyntax( | & sFormulaField & | ) |
      vEval = Evaluate(sFormula, doc)
     
      If vEval(0) = "1" Then
              Messagebox COMPILE_SUCCESS_BODY,  MB_ICONINFORMATION, COMPILE_SUCCESS_TITLE
      Else
              Msgbox COMPILE_FAILURE_BODY & Chr(13) & "Error type: " & vEval(0) & Chr(13) & "Error message: " & vEval(5)_
              ,  MB_ICONSTOP, COMPILE_FAILURE_TITLE
      End If
End
Sub


Hinweis:


Ein eigenstndiges Tool zum Testen ("Formula Validator") findet sich auch in unserem Downloadbereich.....

@Formeln schnell testen

24. November 2005 Posted by Manfred Meise

Sie wollen eine erstellte Formel schnell testen? Dann bentigen Sie 4 Tastaturanschlge ...
  • kopieren Sie die Formel in die Zwischenablage (CTRL-C),
  • rufen Sie ein neues Memo auf (CTRL-M),
  • fgen den Inhalt der Zwischenablage in die "Betreff"-Zeile ein (CTRL-V)
  • und fhren sie dort aus (SHIFT-F9)

Ist doch einfach!!