'================================================== 'METHOD: PrjAutoTest_Initialize 'SUMMARY: 自動試験の工事の初期化 'PARAMETER: strname As String 仕向けとテストケースの情報 'RETURN: true :初期化成功 ' false:初期化失敗 '================================================== PublicFunction PrjAutoTest_Initialize()Function PrjAutoTest_Initialize(strname AsString) AsBoolean OnErrorGoTo ErrHandler Dim objVBComponent As VBComponent Dim fso As FileSystemObject Dim count AsInteger Dim lineP0 AsLong Dim lineP1 AsLong Dim lineP2 AsLong Dim lineP3 AsLong Dim lineP4 AsLong Dim lineP5 AsLong Dim lineP6 AsLong Dim i AsInteger Dim j AsInteger Dim strTemp AsString Dim tmpStr AsString Set fso =CreateObject("Scripting.FileSystemObject") '自動試験プロジェクトパース名の取得 tmpStr = VBInstance.VBProjects.Item(PRJTESTAUTO).FileName path = getFolderName(tmpStr) count = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.count If fso.FileExists(path & LOG_VHDL2VB) Then '転換したモジュールの情報をファイルに記憶する Open path & LOG_VHDL2VB ForInputAs #1 DoWhileNotEOF(1) Line Input #1, strTemp Call DelMod(strTemp) Loop Close #1 'ログファイルの削除 CallKill(path & LOG_VHDL2VB) EndIf '試験項目一覧名の追加と関連コードの追加、まずマークのサーチを行います Set objVBComponent = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item("basMain") lineP0 =1 find = objVBComponent.CodeModule.find("@@##$$-0", lineP0, 0, 0, 0) lineP1 =1 find = find And objVBComponent.CodeModule.find("@@##$$-1", lineP1, 0, 0, 0) lineP2 =1 find = find And objVBComponent.CodeModule.find("@@##$$-2", lineP2, 0, 0, 0) lineP3 =1 find = find And objVBComponent.CodeModule.find("@@##$$-3", lineP3, 0, 0, 0) lineP4 =1 find = find And objVBComponent.CodeModule.find("@@##$$-4", lineP4, 0, 0, 0) lineP5 =1 find = find And objVBComponent.CodeModule.find("@@##$$-5", lineP5, 0, 0, 0) lineP6 =1 find = find And objVBComponent.CodeModule.find("@@##$$-6", lineP6, 0, 0, 0) IfNot find ThenGoTo ErrHandler '既に入っている試験項目の削除する For i = lineP0 +1To lineP1 -1 IfLeft(Trim(objVBComponent.CodeModule.Lines(i, 1)), 7) ="frmMain"Then Call objVBComponent.CodeModule.ReplaceLine(i, "") EndIf Next i '既に入っている試験項目の削除する For i = lineP1 +1To lineP2 -1 IfLeft(Trim(objVBComponent.CodeModule.Lines(i, 1)), 7) ="frmMain"Then Call objVBComponent.CodeModule.ReplaceLine(i, "") EndIf Next i '既に入っているロードVHDLを削除する For i = lineP3 +1To lineP4 -1 IfLeft(Trim(objVBComponent.CodeModule.Lines(i, 1)), 4) ="Case"Then Call objVBComponent.CodeModule.ReplaceLine(i, "") EndIf Next i '既に入っている試験関数を削除する For i = lineP5 +1To lineP6 -1 IfLeft(Trim(objVBComponent.CodeModule.Lines(i, 1)), 4) ="Case"Then Call objVBComponent.CodeModule.ReplaceLine(i, "") EndIf Next i '自動試験の仕向け情報を追加する lineStr =" frmMain.labCaseName.Caption ="""& strname &"""" Call objVBComponent.CodeModule.ReplaceLine(lineP1 -1, lineStr) PrjAutoTest_Initialize =True Exit Function ErrHandler: Call log_Output(path +""+ LOG_COMPILER, "自動試験プロジェクトの初期化する時,エラーが発生しました。") PrjAutoTest_Initialize =False End Function
删除一个摸块
'================================================== 'METHOD: DelMod 'SUMMARY: 既に入っているモジュール削除する関数 'PARAMETER: strname As String モジュールの名前 'RETURN: true 削除成功 ' false 削除失敗 '================================================== PrivateFunction DelMod()Function DelMod(strname AsString) AsBoolean OnErrorGoToError: Dim count AsInteger Dim i AsInteger count = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.count If count >0Then For i =1To count If VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item(i).name = strname Then 'モジュールの削除 VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Remove VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item(i) EndIf Next i EndIf DelMod =True Exit Function Error: DelMod =False End Function
转化的一部分代码
'コンパイルしたVBファイルをプロジェクトに追加します。 Set objVBComponent = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.AddFile(path & strVhdlpath &".bas") '重複追加名前同じの場合 count = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.count If count >0Then For i =1To count If VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item(i).name ="vhdl_"& entity Then Call DelMod("Module1") gComplierNGCount = gComplierNGCount +1 Call log_Output(path +""+ LOG_COMPILER, shortName &": Entity名重複。") Exit Sub EndIf Next i objVBComponent.name ="vhdl_"& entity EndIf OnErrorGoTo SkipRet '共通関数かどうかのチェック。共通関数モジュールであれば、メイン関数がないです。 'この場合、試験項目一覧名の追加と関連コードの追加がいらないです、SkipRetに飛びます。 lineP0 = objVBComponent.CodeModule.ProcBodyLine("Test_"& entity, vbext_pk_Proc) lineP0 = objVBComponent.CodeModule.ProcBodyLine("Load_"& entity, vbext_pk_Proc) OnErrorGoTo ErrHandler4 '試験項目一覧名の追加と関連コードの追加、まずマークのサーチを行います Set objVBComponent = VBInstance.VBProjects.Item(PRJTESTAUTO).VBComponents.Item("basMain") lineP0 =1 find = objVBComponent.CodeModule.find("@@##$$-0", lineP0, 0, 0, 0) lineP1 =1 find = find And objVBComponent.CodeModule.find("@@##$$-1", lineP1, 0, 0, 0) lineP2 =1 find = find And objVBComponent.CodeModule.find("@@##$$-2", lineP2, 0, 0, 0) lineP3 =1 find = find And objVBComponent.CodeModule.find("@@##$$-3", lineP3, 0, 0, 0) lineP4 =1 find = find And objVBComponent.CodeModule.find("@@##$$-4", lineP4, 0, 0, 0) lineP5 =1 find = find And objVBComponent.CodeModule.find("@@##$$-5", lineP5, 0, 0, 0) lineP6 =1 find = find And objVBComponent.CodeModule.find("@@##$$-6", lineP6, 0, 0, 0) 'マークのサーチが失敗する場合、エラーメッセージを出して、処理中止。 IfNot find ThenGoTo ErrHandler4 '既に入っている試験項目の集計 count =0 For i = lineP1 +1To lineP2 -1 IfLeft(Trim(objVBComponent.CodeModule.Lines(i, 1)), 7) ="frmMain"Then count = count +1 EndIf Next 'コンボボックスに試験項目名の追加 lineStr =" Case "& count &": Test_"& entity Call objVBComponent.CodeModule.InsertLines(lineP6, lineStr) 'VHDLスクリプト表示のため、イベント処理コード追加 lineStr =" Case "& count &": Load_"& entity Call objVBComponent.CodeModule.InsertLines(lineP4, lineStr) '自動試験を行うため、イベント処理コード追加 lineStr =" frmMain.Combo1.AddItem """& shortName &"""" Call objVBComponent.CodeModule.InsertLines(lineP2 - count, lineStr) '転換したモジュールの情報をファイルに記憶する Open path & LOG_VHDL2VB For Append As #1 Print #1, "vhdl_"& entity Close #1 gComplierOKCount = gComplierOKCount +1 Call log_Output(path +""+ LOG_COMPILER, shortName &": OK。")
connect.dsrPublic VBInstance As VBIDE.VBEsub show Set Main_Form.VBInstance = VBInstance Set Main_Form.Connect = Me 自動試験プロジェクトパース名の取得 tmpStr = VBInstance.VBProjects.Ite