⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ccmdif.cls

📁 Data monkey是一个强大的是数据传输和转换应用程序。使用DataMonkey用户可以把复杂的文本文件格式
💻 CLS
📖 第 1 页 / 共 2 页
字号:
End Property

Public Function ParseDataItemName(str As String, cpName As String, diName As String)
    ParseDataItemName = False
    Dim i As Integer
    i = InStr(1, str, ",")
    If i = 0 Then Exit Function
    
    cpName = left$(str, i - 1)
    diName = right$(str, Len(str) - i)
    ParseDataItemName = True
End Function

Public Function Execute(ByRef value As Variant, Optional CnvType As Integer = -1) As Boolean

    On Error GoTo eHandler
    
    Dim lhsValue As Variant
    Dim rhsValue As Variant
    Dim cp As CInputRecord
    Dim di As CInputField
    Dim i As Integer
    
    '********************
    ' Default to failure.
    '********************
    
    Execute = False
    
    '******************************************************
    ' Get the value for the Left Hand Side of the equation.
    '******************************************************
    
    Select Case mLHSType
        Case eCmdValueTypes.cvtConstant
            lhsValue = mLHS
            
        Case eCmdValueTypes.cvtDataItem
            Set cp = GImport.GetCheckPointByName(mLHSCheckPointName)
            If cp Is Nothing Then Exit Function
            
            Set di = cp.GetDataPointByName(mLHSDataItemName)
            If di Is Nothing Then Exit Function
            
            lhsValue = di.value
        
        Case eCmdValueTypes.cvtLineOfInput
            If mLHSGetValue.Execute(lhsValue) = False Then
                Exit Function
            End If

        Case eCmdValueTypes.cvtMe
            lhsValue = value
            
        Case Else
            lhsValue = ""
            LogError "CCmdIf", "Execute", "Invalid LHS value"
    
    End Select
    
    '*******************************************************
    ' Get the value for the Right Hand Side of the equation.
    '*******************************************************
    
    Select Case mRHSType
        Case eCmdValueTypes.cvtConstant
            rhsValue = mRHS
        Case eCmdValueTypes.cvtDataItem
            Set cp = GImport.GetCheckPointByName(mRHSCheckPointName)
            If cp Is Nothing Then Exit Function
            
            Set di = cp.GetDataPointByName(mRHSDataItemName)
            If di Is Nothing Then Exit Function
            
            rhsValue = di.value
        
        Case eCmdValueTypes.cvtLineOfInput
            
            If mRHSGetValue.Execute(rhsValue) = False Then
                Exit Function
            End If

        Case eCmdValueTypes.cvtMe
            rhsValue = value
        
        Case eCmdValueTypes.cvtNumeric
            If mOperator = "=" Then
                Execute = isNumeric(lhsValue)
            Else
                Execute = Not isNumeric(lhsValue)
            End If
            Exit Function
            
        Case Else
            rhsValue = ""
            LogError "CCmdIf", "Execute", "Invalid RHS value"
    End Select
    
    '*********************************
    ' Perform the required comparison.
    '*********************************

    ' Attempt to do a string comparison.
    If VarType(lhsValue) = vbString And _
        VarType(rhsValue) = vbString Then

        i = StrComp(lhsValue, rhsValue, _
                IIf(mCaseSensitive, vbBinaryCompare, vbTextCompare))
        Select Case mOperator
            Case "="
                If i = 0 Then Execute = True
            Case "<>"
                If i <> 0 Then Execute = True
            Case ">"
                If i > 0 Then Execute = True
            Case "<"
                If i < 0 Then Execute = True
            Case Else
                LogError "CCmdIf", "Execute", "Invalid operator '" + mOperator + "'"
        End Select

    Else
        ' Perform a non-text comparison.
        Select Case mOperator
            Case "="
                If lhsValue = rhsValue Then Execute = True
            Case "<>"
                If lhsValue <> rhsValue Then Execute = True
            Case ">"
                If lhsValue > rhsValue Then Execute = True
            Case "<"
                If lhsValue < rhsValue Then Execute = True
            Case Else
                LogError "CCmdIf", "Execute", "Invalid operator '" + mOperator + "'"
        End Select
    End If
    Exit Function
    
eHandler:
    LogError "CCmdIf", "Execute", Error(Err)
    
End Function
Public Function Load(arc As CArchive) As Boolean

    On Error GoTo eHandler
    
    Load = False
    Dim item As String, value As Variant, retVal As Integer
    
    '***************************************
    ' Get the next line from the input file.
    '***************************************
    
    Do
        retVal = arc.GetNextItem(item, value)
        
        ' Error, log it, then exit with error.
        If retVal = ArcRetType.cERROR Then
            arc.AddError
            GoTo done
            
        ' We are done with this object, leave.
        ElseIf retVal = ArcRetType.cENDITEM Then
            Exit Do
        End If
        
        Select Case retVal
            Case ArcRetType.cVALUE
            
                '*******************************
                ' Restore our internal settings.
                '*******************************
                
                Select Case item
                    Case "INDEX"
                        mIndex = value
                    Case "LHS"
                        mLHS = value
                    Case "LHSTYPE"
                        mLHSType = value
                    Case "LHSCPNAME"
                        mLHSCheckPointName = value
                    Case "LHSDINAME"
                        mLHSDataItemName = value
                    Case "LHSPOSITION"
                        LHSInputLinePosition = value
                    Case "LHSDELIMITED"
                        LHSDelimited = value
                    Case "LHSDELIMITER"
                        LHSDelimiter = value
                    Case "LHSLENGTH"
                        LHSLength = value

                    Case "RHS"
                        mRHS = value
                    Case "RHSTYPE"
                        mRHSType = value
                    Case "RHSCPNAME"
                        mRHSCheckPointName = value
                    Case "RHSDINAME"
                        mRHSDataItemName = value
                    Case "RHSPOSITION"
                        RHSInputLinePosition = value
                    Case "RHSDELIMITED"
                        RHSDelimited = value
                    Case "RHSDELIMITER"
                        RHSDelimiter = value
                    Case "RHSLENGTH"
                        RHSLength = value

                    Case "OPERATOR"
                        mOperator = value
                    Case "CASESENSITIVE"
                        mCaseSensitive = value
                    Case Else
                    
                        '*****************************************
                        ' This line contains an unrecognized item.
                        '*****************************************
                        
                        arc.AddError
                        
                End Select
        End Select
    Loop While True
    
    Dim i As Integer
    
    '*****************************************************
    ' If one of the things we are going to compare is the
    ' value from another data item, we need to parse out
    ' the name of the DataItem and it's CheckPoint from
    ' the format given: "CheckpointName.DataitemName"
    '*****************************************************
    
    If mLHSType = cvtDataItem Then
        i = InStr(mLHS, ",")
        mLHSCheckPointName = left$(mLHS, i - 1)
        mLHSDataItemName = right$(mLHS, Len(mLHS) - i)
    End If
    
    If mRHSType = cvtDataItem Then
        i = InStr(mRHS, ",")
        mRHSCheckPointName = left$(mRHS, i - 1)
        mRHSDataItemName = right$(mRHS, Len(mRHS) - i)
    End If
    
    Load = True
    
done:
    Exit Function
    
eHandler:
    LogError "CCmdIf", "Load", Error(Err)
End Function

Public Function Save(arc As CArchive) As Boolean
    
    On Error GoTo eHandler
    
    Save = False

    arc.SaveItem aiBEGINACTION, GCmdHelper.GetName(CmdType())
    arc.SaveItem aiVALUE, "INDEX", mIndex
    
    arc.SaveItem aiVALUE, "LHS", mLHS
    arc.SaveItem aiVALUE, "LHSTYPE", mLHSType
    arc.SaveItem aiVALUE, "LHSCPNAME", mLHSCheckPointName
    arc.SaveItem aiVALUE, "LHSDINAME", mLHSDataItemName
    arc.SaveItem aiVALUE, "LHSDELIMITED", LHSDelimited
    arc.SaveItem aiVALUE, "LHSDELIMITER", LHSDelimiter
    arc.SaveItem aiVALUE, "LHSPOSITION", LHSInputLinePosition
    arc.SaveItem aiVALUE, "LHSLENGTH", LHSLength
    
    arc.SaveItem aiVALUE, "RHS", mRHS
    arc.SaveItem aiVALUE, "RHSTYPE", mRHSType
    arc.SaveItem aiVALUE, "RHSCPNAME", mRHSCheckPointName
    arc.SaveItem aiVALUE, "RHSDINAME", mRHSDataItemName
    arc.SaveItem aiVALUE, "RHSDELIMITED", RHSDelimited
    arc.SaveItem aiVALUE, "RHSDELIMITER", RHSDelimiter
    arc.SaveItem aiVALUE, "RHSPOSITION", RHSInputLinePosition
    arc.SaveItem aiVALUE, "RHSLENGTH", RHSLength
    
    arc.SaveItem aiVALUE, "OPERATOR", mOperator
    arc.SaveItem aiVALUE, "CASESENSITIVE", mCaseSensitive
    
    arc.SaveItem aiENDITEM, GCmdHelper.GetName(CmdType())

    Save = True
    Exit Function
    
eHandler:
    LogError "CCmdIf", "Save", Error(Err)
    Exit Function
    
End Function

Private Sub Class_Initialize()
    mRHSType = cvtNONE
    mLHSType = cvtNONE
    mOperator = "="
    mUniqueID = GetUniqueID
    mCaseSensitive = False
    Set mLHSGetValue = New CCmdGetValue
    Set mRHSGetValue = New CCmdGetValue
End Sub

Private Sub Class_Terminate()
    Set mLHSGetValue = Nothing
    Set mRHSGetValue = Nothing
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -