Tag search & replace with command line

Discussion in 'Microstation' started by Greg Carlill, Oct 25, 2004.

  1. Greg Carlill

    Greg Carlill Guest

    Hi,

    Can anyone see my error below? I think it fails in the following lines

    if tag.value= OldValue then
    tag.value= NewValue

    I want to run the macro like this

    macro tagreplace abc xyz

    The majority of the code I copied from an earlier post on this group.
    Any suggestions?

    using V7

    ' tagreplace.bas
    '
    ' ===================================================================
    Const ENDofFILE% = -1
    Const STARTofFILE% = 0

    Sub main
    Dim tag as New MBEtag
    Dim element as New MBEelement
    Dim tagelement as New MBEelement
    Dim filepos as Long
    Dim OldValue as String
    Dim NewValue as String
    Dim cmd As String
    ' parse command line

    cmd= Command$

    OldValue = (word$(cmd,1)) 'gets the old value
    NewValue = (word$(cmd,2)) 'gets the new value

    elcounter = 0%
    filePos = element.fromFile(STARTofFILE)

    While filePos <> ENDofFILE

    'if an element has a tag attached, then retrieve it.
    if element.getMbeTag(tag)=MBE_success then

    if tag.value= OldValue then
    tag.value= NewValue

    'get the underlying tag element
    stat=tag.getMBEelement(tagelement)

    'so we can rewrite it with it's new value
    stat=tagelement.rewrite()

    end if

    end if
    filePos = element.fromFile(filePos + element.fileSize)
    Wend
    END SUB
     
    Greg Carlill, Oct 25, 2004
    #1
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.