Lotus Notes / Domino Sonstiges > Projekt Bereich

@Formula-Befehle in Lotus Script abbilden

<< < (5/21) > >>

TMC:
@Trim


--- Code: ---Function atTrim(src, Byval options As Integer)
' src is either a string, or an array of strings.
' options is a set of bit flags corresponding to the constants defined above.  If the ATTRIM_TAB flag is set,
' we will treat tabs as whitespace, replacing them with spaces.  If ATTRIM_NEWLINE is set, newlines will
' be treated as whitespace.  And if ATTRIM_KEEP_NULL is set, null elements will not be removed from the
' array.
   Dim cc$, result$, i&, pos&
   If Isarray(src) Then
 ' recursively process each array element.
      Dim lim%
      lim = Lbound(src)
      Redim retval(lim To Ubound(src)) As String
      pos = lim
      For i = Lbound(src) To Ubound(src)
         result = atTrim(src(i), options)
         If result <> "" Or (options And ATTRIM_KEEP_NULL) Then
            retval(pos) = result
            pos = pos + 1
         End If
      Next
      Redim Preserve retval(lim To max(lim, pos-1))
      atTrim = retval
   Else
      Dim state%, whitespace%
      For i = 1 To Len(src)
         cc = Mid(src, i, 1)
' The string is scanned with a state machine.
'  State 0 means we have not yet encountered a non-whitespace character.
'  State 1 means the last character was non-whitespace.
'  State 2 means the last character was whitespace but there have been some non-whitespace.
         If (cc = " ") Then
            whitespace = True
         Elseif cc = Chr$(9) Then
            whitespace = (options And ATTRIM_TAB)
         Elseif cc = Chr$(10) Or cc = Chr$(13) Then
            whitespace = (options And ATTRIM_NEWLINE)
         Else
            whitespace = False
         End If
         Select Case state
         Case 0:
            If whitespace Then
            Else
               result = cc
               state = 1
            End If
         Case 1:
            If whitespace Then
               state = 2
            Else
               result = result + cc
            End If
         Case Else:
            If whitespace Then
            Else
               result = result + " " + cc
               state = 1
            End If
         End Select
      Next
      atTrim = result
   End If ' src is an array.
End Function
--- Ende Code ---

TMC:
@EasyWord

Watt issn das? Poste es trotzem mal  ;D


--- Zitat ---Function EasyWord(Byval Source$, Byval Seekk$, Byval pos%) As String
   ' source: a string from which a word is to be extracted.
   ' Seekk: a string containing the character used as word divisions.
   ' pos: which word out of 'source' you want. positive counts frol left to right; negative from right to left (e.g. -1 returns last word). 0 is illegal.
   Dim cpos&, tmp$
   If Pos > 0 Then
      ' if they've asked for other than word 1, throw away all prior to the pos-1st occurrence.
      If pos > 1 Then Source = Strright(Source, Seekk, 0, pos-1)
      cpos = Instr(Source, Seekk)
      ' if the search string occurs again, return all to the left of the search string. Else return entire string.
      If cpos = 0 Then
         EasyWord = Source
      Else
         EasyWord = Left(Source, cpos)
      End If
   Else
      If pos < -1 Then Source = Strleftback(Source, Seekk, 0, 1-pos)
      
      EasyWord = Strrightback(Source, Seekk)
      If EasyWord = "" And Source <> "" Then EasyWord = Source
   End If
End Function
--- Ende Zitat ---

TMC:
@Begins


--- Code: ---Function atBegins(Byval a$, b)
   If Isarray(b) Then
      Dim i%
      For i = Lbound(b) To Ubound(b)
         If atBegins(a, b(i)) Then
            atBegins = True
            Exit Function
         End If
      Next
   Else
      atBegins = (Left(a, Len(b)) = b)
   End If
End Function
--- Ende Code ---

TMC:
@Word


--- Code: ---Function Word(Byval source$, Byval delims$, Byval wordnum%) As String
   ' source: a string from which a word is to be extracted.
   ' delims: a string containing one or more characters used as word divisions. Unlike EasyWord,
   '   this may contain multiple single-character delimiters.
   ' wordnum: which word out of 'source' you want. positive counts frol left to right; negative from right to left (e.g. -1 returns last word). 0 is illegal.
   Dim pos&, tmppos&, lastpos&, i&
   If wordnum > 0 Then
      pos = 1
      Do Until wordnum = 0 Or pos = 0
         lastpos = pos
         pos = 1
         For i = 1 To Len(delims)
            tmppos = Instr(pos, source, Mid$(delims, i, 1))
            If tmppos > 0 And tmppos < pos Then pos = tmppos+1
         Next
         wordnum = wordnum - 1
      Loop
      If pos = 1 Then
         word = Mid$(source, lastpos)
      Else
         word = Mid$(source, lastpos, pos-lastpos-1)
      End If
   Elseif wordnum < 0 Then
      Dim tmpstr$, remst$, laststr$
      remst = source
      Do Until wordnum = 0
         laststr = remst
         remst = ""
         For i = 1 To Len(delims)
            tmpstr = Strleftback(laststr, Mid$(delims, i, 1))
            If Len(tmpstr) > Len(remst) Then remst = tmpstr
         Next
         wordnum = wordnum + 1
      Loop
      pos = Len(laststr) - Len(remst)
      If pos > 0 Then Word = Strright(laststr, pos)
   End If
End Function
--- Ende Code ---

TMC:
So :-)

Nun habe ich mal alles gepostet was so rumlag.....  ;D


Saubere Dokumentation: Da stimme ich voll und ganz mit Euch überein !!!

Diskussions-Stuff haben wir ja erst mal  ;)

TMC

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln