'----- 構造体定義 -----
Type CommandOption_t
TransType As String
InputFile As String
OutputFile As String
Layer As String
DelSurf As String
DelAntiSurf As String
Opoint As String
Solid2Surf As String
Reboot As String
End Type
'----- コマンドライン引数の文字列と数を取得 -----
Public Sub VBC_GetCommand(strCommand() As String, intCommand As Long)
'各要素ごとに区切られた文字列から 1 次元配列を作成し、返す。
strCommand = Split(Command)
'配列の指定された次元で使用できる添字の最大値を、長整数型 (Long) の値で返す。
intCommand = UBound(strCommand)
End Sub
'----- 擬似的にエラーを発生させる -----
Public Sub VBC_OccurError(Mess As String)
Err.Raise 1, , Mess
End Sub
'----- コマンドライン解析 -----
Public Sub CommandLineAnalysis(CO_t As CommandOption_t)
Dim i As Long
'コマンドライン
Dim nCommand As Long
Dim strCommand() As String
Dim bOption As Boolean
'初期化
CO_t.Layer = "-notlayer"
CO_t.DelSurf = "-notdelsurf"
CO_t.Opoint = "-notopoint"
CO_t.DelAntiSurf = "-notdelantisurf"
CO_t.Solid2Surf = "-notsold2surf"
CO_t.Reboot = "-notreboot"
'初期化
bOption = False
'コマンドライン引数の文字列と数を取得
Call VBC_GetCommand(strCommand, nCommand)
'
For i = 0 To nCommand '------- (1)start
Debug.Print strCommand(i)
If (strCommand(i) = "-iges_mdt") Or _
(strCommand(i) = "-step_mdt") Then '変換処理選択 '------- (2)-1
bOption = True
CO_t.TransType = strCommand(i)
CO_t.InputFile = strCommand(i + 1)
CO_t.OutputFile = strCommand(i + 2)
i = i + 2
ElseIf (strCommand(i) = "-layer") Or _
(strCommand(i) = "-notlayer") Then 'ファイル名のレイヤに要素を移動 '------- (2)-2
CO_t.Layer = strCommand(i)
ElseIf (strCommand(i) = "-delsurf") Or _
(strCommand(i) = "-notdelsurf") Then '面データ削除オプション '------- (2)-3
CO_t.DelSurf = strCommand(i)
ElseIf (strCommand(i) = "-opoint") Or _
(strCommand(i) = "-notopoint") Then '原点作成オプション '------- (2)-4
CO_t.Opoint = strCommand(i)
ElseIf (strCommand(i) = "-delantisurf") Or _
(strCommand(i) = "-notdelantisurf") Then '面データ以外の要素の削除 '------- (2)-5
CO_t.DelAntiSurf = strCommand(i)
ElseIf (strCommand(i) = "-reboot") Or _
(strCommand(i) = "-notreboot") Then 'MDT再起動 '------- (2)-6
CO_t.Reboot = strCommand(i)
ElseIf (strCommand(i) = "-sold2surf") Or _
(strCommand(i) = "-notsold2surf") Then 'ソリッドをサーフェスに変換 '------- (2)-7
CO_t.Solid2Surf = strCommand(i)
Else '------- (2)-8
'擬似的にエラーを発生させる
Call VBC_OccurError("コマンド エラー")
End If '------- (2)end
Next i '------- 1)end
'コマンド エラー
If bOption = False Then
'擬似的にエラーを発生させる
Call VBC_OccurError("コマンド エラー")
End If
End Sub