Lotus Notes / Domino Sonstiges > Projekt Bereich

@Formula-Befehle in Lotus Script abbilden

<< < (3/21) > >>

TMC:
@Name([abbreviate]...)


--- Code: ---Function UIDAbbr(ids As Variant)
' This function performs roughly the same task as @Name([abbreviate]...);
' i.e., given an argument which is a string or array of strings, it returns
' the same string or array with the CN=, OU=, etc. stripped off of every
' hierarchical level of what is assumed to be a Notes username.
'
' Example: UIDAbbr("CN=Andre P. Guirard/OU=Nav/O=Hoptoad/C=US")
'   returns "Andre P. Guirard/Nav/Hoptoad/US"
   If Isarray(ids) Then
      Dim i%
      Redim r(Lbound(ids) To Ubound(ids)) As String
      For i = Lbound(ids) To Ubound(ids)
         r(i) = UIDAbbr(ids(i))
      Next
      UIDAbbr = r
   Else
      UIDAbbr = Fulltrim(atReplaceSubstring(atImplode(atWord(atExplode(atWord(Cstr(ids), "<@", 1), "/"), "=", -1), "/"), """", ""))
   End If
End Function
--- Ende Code ---

@Name([CN]...)


--- Code: ---Function UIDCn(ids)
' This function performs roughly the same task as @Name([CN]...);
'
' Example: UIDCn("CN=Andre P. Guirard/OU=HiRollers/O=Gossamer/C=US")
'   returns "Andre P. Guirard"
'
' If passed an array, it will process each element separately and return an
' array as a result.
   If Isarray(ids) Then
      Dim i%
      Redim r$(Lbound(ids) To Ubound(ids))
      For i = Lbound(ids) To Ubound(ids)
         r$(i) = UIDCn(ids(i))
      Next
      UIDCn = r$
   Else
      UIDCn = Trim(atReplaceSubstring(atWord(atWord(Cstr(ids), "/<@", 1), "=", -1), """", ""))
   End If
End Function
--- Ende Code ---

TMC:
Weiterer Code zu @Unique

Ich hau jetzt erstmal alle Functions rein die ich so finde als Diskussionsbasis :-)

Könnte auch was doppelt werden .......



--- Code: ---Function atUnique(a, Byval caseflag%) As Variant
' a is an array. The return value is the same array with duplicate elements removed.
' Note: this is a case sensitive comparison. A non-case sensitive version of this
' function is available in the @NCFunctions script library. Non-text elements are
' considered to be duplicates if their text representations match another element,
' e.g. the number 5 is considered a duplicate of the string "5".
' The caseflag argument is True for a case-sensitive comparison, False for case sensitive
   Dim data List As Integer
   Dim i%, n%
   
   For i=Lbound(a) To Ubound(a) ' don't assume that the array starts at index 0.
      If caseflag Then data( Cstr(a(i)) ) = i Else data( Lcase(Cstr(a(i))) ) = i
       ' remember array index of original element.
   Next
   
' Take the new list and put it into a new array
   Redim newarray(0 To Ubound(a)-Lbound(a)) ' initially dimension array to maximum size we might need.
   Forall z In data
      newarray(n) = a(z) ' copying from the original array instead of the list tags lets us preserve the original datatype of the elements.
      n = n + 1
   End Forall
   Redim Preserve newarray(0 To n-1) ' redimension the array only once, after we know how large it should be.
   
   atUnique = newarray
End Function
--- Ende Code ---

TMC:
@Left


--- Code: ---Function atLeft(str_or_list, position, Byval flags%)
 ' This reproduces the @Left function of the Notes macro language.
 'Syntax: atLeft(str_or_list, position)
' where:
'   str_or_list is a string or string array.
'   position is either a number or a string.
'  
'  If  'position' is a number and str_or_list is a string, the first 'position' characters
'  of the str_or_list are returned, or if str_or_list contains fewer than 'position'
'  characters, the entire string.
'
'  If  'position' is a string and str_or_list is a string, the result is the portion of
'  str_or_list that precedes the first occurence of the string 'position' (case sensitive
'  search).  If 'position' is not found, the empty string is returned.
'
'  If str_or_list is an array, the return value is an array where each element contains
'  the result of the Left function on that element.
   
   ' arguments: str_or_list: string or array of strings to search in.
   ' position: integer or string: position in str_or_list if numeric, else string to search for in str_or_list
   ' flags option added for R5 - case/pitch sensitivity (see Strright function in developer help).
   ' return value: same type as str_or_list, containing the portion (of each element, if an array) to the left of 'position'
   Dim seekval, c%
   If Isarray(position) Then
      seekval = position(Lbound(position))
   Else
      seekval = position
   End If
   
   If Isarray(str_or_list) Then
      Redim result(Lbound(str_or_list) To Ubound(str_or_list))
      If Vartype(seekval) <> 8 Then
         For c = Lbound(result) To Ubound(result)
            result(c) = Left(str_or_list(c), seekval)
         Next
      Else
         For c = Lbound(result) To Ubound(result)
            result(c) = Strleft(str_or_list(c), seekval, flags)
         Next
      End If
      atLeft = result
   Elseif Vartype(seekval) <> 8 Then
      atLeft = Left(str_or_list, seekval)
   Else
      ' change for R5: use Strleft instead of Instr and Right
      atLeft = Strleft(str_or_list, seekval, flags)
   End If
End Function
--- Ende Code ---

TMC:
@Repeat


--- Code: ---Function atRepeat(s, Byval count As Integer)
' Given a string and a count, Repeat returns a string which is
' the argument value repeated "count" times.  Passed an array,
' it returns an array where each element is the corresponding
' source element repeated "count" times.
   Dim i%
   If Isarray(s) Then
      Redim hark(Lbound(s) To Ubound(s)) As String
      For i = Lbound(s) To Ubound(s)
         hark(i) = atRepeat(s(i), count)
      Next
      atRepeat = hark
   Elseif Vartype(s) = 8 Then
      Select Case Len(s)
      Case 0:
         atRepeat = "" ' empty string repeated any number of times is still empty.
      Case 1:
         atRepeat = String(s, count) ' This is much faster than using a loop.
      Case Else
         atRepeat = ""
         For i = 1 To count
            atRepeat = atRepeat & s
         Next
      End Select
   Else
      atRepeat = atRepeat(Cstr(s), count)
   End If
End Function
--- Ende Code ---

Semeaphoros:
Bernhard: Ist schon klar, wollte nur drauf hinweisen, dass es diese Funktionen gibt, viele Leute haben das eben übersehen, und wenn die eingebaute Funktion die geforderte Leistung erbringt (was nicht bei allen der Fall ist), ist sie zu bevorzugen, weil meilenweit schneller als irgendwas nachgebautes. Aber Du hast schon recht, es sind nicht immer Gleichsetzungen, sondern nur Teiläquivalente, aber dafür gibt es ja die Hilfe ......

Navigation

[0] Themen-Index

[#] Nächste Seite

[*] Vorherige Sete

Zur normalen Ansicht wechseln