<?xml version="1.0" encoding="utf-16" standalone="yes"?>
<!--Created: 29.06.2015 17:14:15-->
<!--ACTOptimumVersion: 6.0.5581.26549-->
<AutoDataItems ACTOptimumVersion="6.0.5581.26549" Created="29.06.2015 17:14:15">
    <AutoDataControl Created="29.06.2015 17:14:15" ClassName="Melville_Schellmann.ACTOptimum3.Control.AutoData3.AutoData3" PrefClassVersion="1.0" ACTOptimumVersion="6.0.5581.26549">
        <Source>' #ScriptName: AutoSalutation
    ' #Description: DEUTSCH:
    '               Beschreibt in Abhängigkeit des (Kurz-)Anredefeldes das Feld Briefanrede
    '               
    '               ENGLISH:
    '               Describes a function how to fill the salutation depending on short salutation.
    ' #Author: Robert Schellmann, rs@act7.de
    ' #Copyright: © 2015 by Melville-Schellmann
    ' #Version: 1.0.0 (18.02.2015) s.o.
    '
    ' Deutsch: Der rot dargestellte Text innerhalb der Anführungsstriche kann ggfs. auf Ihren Bedarf angepasst werden.
    ' English: The red shown text within the "" can be changed to your wishes.
    

    Dim oSalutationList As New System.Collections.Generic.List(Of String)
    Dim sValueDefault As String
    Dim sFieldNameSource As String
    Dim sFieldNameDestination As String
    
    ' DEUTSCH: Feldname in dem die kurze Anrede steht
    ' ENGLISH: Field name containing the short salutation
    sFieldNameSource = "Anrede kurz"
    
    ' DEUTSCH: Feldname in dem lange Anrede steht
    ' ENGLISH: Field name containing the long salutation
    sFieldNameDestination = "Anrede"
    
    ' DEUTSCH: Liste der Anrede Formen. Der Aufbau lautet: "KurzeAnrede=LangeAnrede"
    ' ENGLISH: Liste of salutation forms is as follows: "salutation short=salutation long"
    
    oSalutationList.Add("Herr=Sehr geehrter Herr")
    oSalutationList.Add("Herr Dr.=Sehr geehrter Herr Dr.")
    oSalutationList.Add("Herr Prof.=Sehr geehrter Herr Prof.")
    oSalutationList.Add("Frau=Sehr geehrte Frau")
    oSalutationList.Add("Frau Dr.=Sehr geehrte Frau Dr.")
    oSalutationList.Add("Frau Prof.=Sehr geehrte Frau Prof.")
    oSalutationList.Add("=Sehr geehrte Damen und Herren") ' Platzhalter für weitere Anredeformen
    oSalutationList.Add("=") ' Platzhalter für weitere Anredeformen
    oSalutationList.Add("=") ' Platzhalter für weitere Anredeformen
    oSalutationList.Add("=") ' Platzhalter für weitere Anredeformen
      
    ' DEUTSCH: Dieser Wert wird genommen, wenn der Wert der kurzen Anrede nicht gefunden werden kann.
    ' ENGLISH: Default value if salutation short is empty.
    sValueDefault = "Sehr geehrte Damen und Herren"
    
    ' Ab hier bitte keine Änderungen mehr machen
    
    Dim sValueSource As String
    Dim sValueDestination As String
    
    ' Quellwert ermitteln
    sValueSource = AutoData.getFieldValue(sFieldNameSource)
    If AutoData.hasAnError Then
      Msgbox(Autodata.ErrorMessage, MsgBoxStyle.Exclamation, m_sScript)
      GoTo Abbruch
    End If
    
    '    ' Ist der Quellwert leer?
    '    If String.IsNullOrEmpty(sValueSource) Then
    '      Msgbox(String.Format("Bitte geben Sie zuvor in das Feld '{0}' einen Wert ein.", sFieldNameSource), MsgBoxStyle.Information, m_sScript)
    '      GoTo Abbruch
    '    End If
  
    ' Liste durchsuchen um Zielwert zu erhalten
    Dim i As Integer
    Dim aPair() As String
    For i = 0 To oSalutationList.Count - 1
      ' Listenwert aufteilen in Quell- und Zielwert Array
      aPair = oSalutationList(i).Split(New Char(){"="c})
      If aPair.Length &lt;&gt; 2 Then
        Msgbox(String.Format("Der im '{0}'-Script hinterlegte Listenwert '{1}' hat nicht das benötigte Format.", m_sScript, oSalutationList(i)), MsgBoxStyle.Exclamation, m_sScript)
        GoTo Abbruch
      End If
      If String.Compare(aPair(0), sValueSource.Trim, True) = 0 Then
        sValueDestination = aPair(1)
        Exit For
      End If      
    Next
    ' Wenn nicht in Liste gefunden, dann Standardwert nehmen
    If i = oSalutationList.Count Then
      sValueDestination = sValueDefault
    End If
    
    ' Zielfeld befüllen
    AutoData.setFieldValue(sFieldNameDestination, sValueDestination)
    If AutoData.hasAnError Then
      Msgbox(Autodata.ErrorMessage, MsgBoxStyle.Exclamation, m_sScript)
      GoTo Abbruch
    End If
    
    Abbruch:
    Return String.Empty
  End Function 
  
  Private Shared m_sScript As String = "AutoSalutation"
  
  Private Function Dummy() As String</Source>
        <SourceComment>Begriff: {0}</SourceComment>
        <TargetFields></TargetFields>
        <MsgText>{0}</MsgText>
        <Picklist></Picklist>
        <Multiple>False</Multiple>
        <Expandable>True</Expandable>
        <OverwriteAlways>True</OverwriteAlways>
        <CopyToClipboard>False</CopyToClipboard>
        <ShowMsgBox>False</ShowMsgBox>
        <PositionMode>1</PositionMode>
        <FlatStyle>Standard</FlatStyle>
        <AutoDataText>Anrede lang</AutoDataText>
        <TextAlign>MiddleCenter</TextAlign>
        <AutoDataFormSize>160; 270</AutoDataFormSize>
        <TooltipText>Füllt die Briefanrede  automatisch aus.</TooltipText>
        <RefreshLoadedViews>False</RefreshLoadedViews>
    </AutoDataControl>
</AutoDataItems>