📄 ccommandsupportmodule.cls
字号:
VERSION 1.0 CLASS
BEGIN
MultiUse = -1 'True
Persistable = 0 'NotPersistable
DataBindingBehavior = 0 'vbNone
DataSourceBehavior = 0 'vbNone
MTSTransactionMode = 0 'NotAnMTSObject
END
Attribute VB_Name = "CCommandSupportModule"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
' DataMonkey Data Conversion Application. Written by Theodore L. Ward
' Copyright (C) 2002 AstroComma Incorporated.
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
' The author may be contacted at:
' TheodoreWard@Hotmail.com or TheodoreWard@Yahoo.com
Option Explicit
' Values dealing with commands.
Enum eCmdTypes
cmdExecute = 1
cmdif
cmdGetValue
cmdConvertData
cmdSkipLines
cmdLookup
cmdGetFieldValue
cmdReadConstantValue
cmdCalculateValue
End Enum
Private Const NUM_COMMANDS = 9
' Boolean values to describe what structures a command applies to.
Enum eCmdApplications
appAll = &HFFFF
appDataItem = 1
appIMPORT = 2
appACTION = 4
appCheckPoint = 8
End Enum
' Dimension offsets into the CmdID array.
Private Const CMD_NAME = 1
Private Const CMD_DESCRIPTION = 2
Private Const CMD_APPLIESTO = 3
' Array to hold names, descriptions and applications of Commands.
Private mCmdID(1 To NUM_COMMANDS, 1 To 3) As Variant
Private Sub Class_Initialize()
FillInCommandArray
End Sub
Public Function CommandNameFromType(CmdType As eCmdTypes) As String
On Error GoTo eHandler
CommandNameFromType = mCmdID(CmdType, CMD_NAME)
Exit Function
eHandler:
LogError "CCommandSupportModule", "CommandNameFromType", Error(Err), False
End Function
Public Function CommandTypeFromName(name As String) As eCmdTypes
Dim i As Integer
CommandTypeFromName = -1
For i = 1 To NUM_COMMANDS
If name = mCmdID(i, CMD_NAME) Then
CommandTypeFromName = i
Exit Function
End If
Next i
Exit Function
End Function
Public Function CommandDescriptionFromType(CmdType As eCmdTypes) As String
On Error GoTo eHandler
CommandDescriptionFromType = mCmdID(CmdType, CMD_DESCRIPTION)
Exit Function
eHandler:
LogError "CCommandSupportModule", "CommandDescriptionFromType", Error(Err), False
End Function
Private Sub FillInCommandArray()
mCmdID(eCmdTypes.cmdExecute, CMD_NAME) = "Execute"
mCmdID(eCmdTypes.cmdExecute, CMD_DESCRIPTION) = _
"Process children items of this item"
mCmdID(eCmdTypes.cmdExecute, CMD_APPLIESTO) = _
eCmdApplications.appCheckPoint Or eCmdApplications.appIMPORT
mCmdID(eCmdTypes.cmdif, CMD_NAME) = "Decision"
mCmdID(eCmdTypes.cmdif, CMD_DESCRIPTION) = _
"Perform a comparison"
mCmdID(eCmdTypes.cmdif, CMD_APPLIESTO) = eCmdApplications.appAll
mCmdID(eCmdTypes.cmdGetValue, CMD_NAME) = "Insert Input Value"
mCmdID(eCmdTypes.cmdGetValue, CMD_DESCRIPTION) = _
"Insert a value from the current line of input"
mCmdID(eCmdTypes.cmdGetValue, CMD_APPLIESTO) = eCmdApplications.appDataItem
mCmdID(eCmdTypes.cmdConvertData, CMD_NAME) = "Convert Data"
mCmdID(eCmdTypes.cmdConvertData, CMD_DESCRIPTION) = _
"Convert this field to a specific data type"
mCmdID(eCmdTypes.cmdConvertData, CMD_APPLIESTO) = eCmdApplications.appDataItem
mCmdID(eCmdTypes.cmdGetFieldValue, CMD_NAME) = "Insert Field Value"
mCmdID(eCmdTypes.cmdGetFieldValue, CMD_DESCRIPTION) = _
"Insert a value from another field into this field"
mCmdID(eCmdTypes.cmdGetFieldValue, CMD_APPLIESTO) = eCmdApplications.appDataItem
mCmdID(eCmdTypes.cmdReadConstantValue, CMD_NAME) = "Insert Constant Value"
mCmdID(eCmdTypes.cmdReadConstantValue, CMD_DESCRIPTION) = _
"Insert a constant value into this field"
mCmdID(eCmdTypes.cmdReadConstantValue, CMD_APPLIESTO) = eCmdApplications.appDataItem
mCmdID(eCmdTypes.cmdCalculateValue, CMD_NAME) = "Calculate Value"
mCmdID(eCmdTypes.cmdCalculateValue, CMD_DESCRIPTION) = _
"Perform a mathematical operation on this field"
mCmdID(eCmdTypes.cmdCalculateValue, CMD_APPLIESTO) = eCmdApplications.appDataItem
mCmdID(eCmdTypes.cmdSkipLines, CMD_NAME) = "Skip Lines"
mCmdID(eCmdTypes.cmdSkipLines, CMD_DESCRIPTION) = _
"Skip some records from the input source"
mCmdID(eCmdTypes.cmdSkipLines, CMD_APPLIESTO) = eCmdApplications.appAll
mCmdID(eCmdTypes.cmdLookup, CMD_NAME) = "Conversion Table"
mCmdID(eCmdTypes.cmdLookup, CMD_DESCRIPTION) = _
"Get a new value for this field from a conversion table"
mCmdID(eCmdTypes.cmdLookup, CMD_APPLIESTO) = eCmdApplications.appAll
End Sub
Public Function GetNumCommands() As Integer
GetNumCommands = NUM_COMMANDS
End Function
Public Function GetName(cmd As Integer) As String
GetName = mCmdID(cmd, CMD_NAME)
End Function
Public Function GetDescription(cmd As Integer) As String
GetDescription = mCmdID(cmd, CMD_DESCRIPTION)
End Function
Public Function CMDGetApplications(cmd As Integer) As Integer
CMDGetApplications = mCmdID(cmd, CMD_APPLIESTO)
End Function
' Returns a 2 dimensional array containing command names/descriptions for
' commands meeting the criteria passed in. This also allows us to specify
' the order in which the commands will appear in a listbox.
Public Function GetCommandList(CmdApp As eCmdApplications) As String()
Dim index As Integer
Dim retArray() As String
ReDim retArray(3, GetNumCommands())
AddToArray retArray, index, CmdApp, eCmdTypes.cmdExecute
AddToArray retArray, index, CmdApp, eCmdTypes.cmdif
AddToArray retArray, index, CmdApp, eCmdTypes.cmdGetValue
AddToArray retArray, index, CmdApp, eCmdTypes.cmdLookup
AddToArray retArray, index, CmdApp, eCmdTypes.cmdGetFieldValue
AddToArray retArray, index, CmdApp, eCmdTypes.cmdReadConstantValue
AddToArray retArray, index, CmdApp, eCmdTypes.cmdCalculateValue
AddToArray retArray, index, CmdApp, eCmdTypes.cmdConvertData
AddToArray retArray, index, CmdApp, eCmdTypes.cmdSkipLines
ReDim retArray(3, index)
End Function
' This function is called by the function above only.
Private Sub AddToArray( _
arr() As String, ByRef index As Integer, _
CmdApp As eCmdApplications, CmdType As eCmdTypes _
)
If mCmdID(CmdType, CMD_APPLIESTO) & CmdApp Then
arr(0, index) = CmdType
arr(1, index) = mCmdID(CmdType, CMD_NAME)
arr(2, index) = mCmdID(CmdType, CMD_DESCRIPTION)
index = index + 1
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -