多个 .frm 文件的模式匹配处理 [英] pattern match processing of multiple .frm files

查看:24
本文介绍了多个 .frm 文件的模式匹配处理的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个 VB6 .frm 文件.请参见下面的示例.我想从代码中剥离函数和子组件,只留下表单设计.

I have multiple VB6 .frm files. See example below. I want to strip away the functions and subs from the code and leave only the form design.

我需要做的是找到以属性"开头的最后一行,因为在此行之后应该删除所有进一步的内容.

What I need to do is find the last line starting with "Attribute" because after this line everything further should be deleted.

使用模式匹配或类似的东西,如何处理 .frm 文件,以便删除最后一个 Attribute 行之后的所有内容?如果我正在遍历一个文件,我如何知道最后一个 Attribute 行在哪里?

Using pattern matching or something similar, how can I process the .frm files so that everything after the last Attribute line is deleted? If I am traversing through a file, how can I tell where the last Attribute line is?

.frm 文件示例:

VERSION 5.00
Begin VB.Form Form1
    Caption = "Form1"
    ClientHeight = 3195
    ClientLeft = 60
    ClientTop = 345
    ClientWidth = 4680
    LinkTopic = "Form1"
    ScaleHeight = 3195
    ScaleWidth = 4680
    StartUpPosition = 3 'Windows Default
    Begin VB.CommandButton Command1
        Caption = "Command1"
        Height = 495
        Left = 1800
        TabIndex = 1
        Top = 1320
        Width = 1215
    End
    Begin VB.TextBox Text1
        Height = 495
        Left = 360
        TabIndex = 0
        Text = "Text1"
        Top = 240
        Width = 1215
    End
End

Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Private Sub Command1_Click()
    Text1.Text = "Hello World"
End Sub
Private Sub Form_Load()
    Text1.BackColor = vbBlue
End 

推荐答案

你只需要两条规则:

1) 如果行以属性"开头,则不要删除.2) 如果行以 'Attribute' 开头,则设置一个标志以开始删除所有后续行.

1) If line starts with 'Attribute' then don't delete. 2) If line starts with 'Attribute' set a flag to start deleting all subsequent lines.

规则 #1 将阻止您删除后续的属性行,并且在遇到第一个属性之后应该没有任何内容要保留,除非它是一个属性.

Rule #1 will prevent you from deleting subsequent Attribute lines, and there should be nothing you want to keep after the first Attribute you encounter unless it's an Attribute.

这篇关于多个 .frm 文件的模式匹配处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆