最終更新: twoflat1017 2012年10月29日(月) 23:58:03履歴
- エラー処理などまだまだ手を入れないとならない部分が沢山あるのため、汎用的に使うにはもう少し改良を要するが、自分的な用途では必要な機能を備えたので公開してみる。
- Googleで検索したものの、日本語のサイトでは見当たらなかったので、とりあえず作ってみた。
- 機能は、コマンドライン引数のうち/hoge:fugaのフォーマットで指定されたものの中から、ユーザ指定されたものだけを対象に、fugaの部分をカンマで区切って配列を生成し、それをユーザに返却する
引数を解析するクラス本体
Option Explicit Class Argument Private argumentOptions Private Sub Class_Initialize() Set argumentOptions = Nothing End Sub Private Sub Class_Terminate() Set argumentOptions = Nothing End Sub Function analyzeBy(ByVal validArguments) Dim ret ret = True Set argumentOptions = CreateObject("Scripting.Dictionary") Dim tempArg For Each tempArg In validArguments If WScript.Arguments.Named.Exists(tempArg) = True Then Dim argumentOption argumentOption = WScript.Arguments.Named.Item(tempArg) If argumentOption <> "" Then Dim optionList optionList = Split(argumentOption, ",", -1, vbTextCompare) argumentOptions.Add tempArg, optionList End If Else ret = False End If Next If ret = False Then Set argumentOptions = Nothing End If analyzeBy = ret End Function Function getArgumentOption(ByVal arg) Dim ret ret = Null If Not argumentOptions Is Nothing Then If argumentOptions.Exists(arg) = True Then ret = argumentOptions.Item(arg) End If End If getArgumentOption = ret End Function End Class
タグ
コメントをかく