TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: SKIP GORE
date: 1997-08-22 04:51:00
subject: Re: Help on a Macro

From: Skip Gore 
Comment to Carlo,
I really appreciate your help and the macro you provided:
snip===============================================================snip
 proc main()
   replace("^", "replace(", "gx")
   replace("$", ")", "gx")
   begfile()
   insertline("proc main()")
   endfile()
   addline("end")
end
snip===============================================================snip
It takes a file of:
snip===============================================================snip
"{[a-z]}U{[a-z]}", "\1u\2", "x"
"{[a-z]}T'", "\1?"+chr(34), "ix"
"die", " the", "w"
"took", "look", "w"
snip===============================================================snip
and puts it in the format of:
snip===============================================================snip
Replace("{[a-z]}U{[a-z]}", "\1u\2", "x")
Replace("{[a-z]}T'", "\1?"+chr(34), "ix")
Replace("die", " the", "w")
Replace("took", "look", "w")
snip===============================================================snip
That is exactly what I apparently asked for.  However, I am not good at
making myself clear and do not know how to write specs for a macro.
I am currently using the following macro, but it will not allow the "x"
option to be used correctly:
snip===============================================================snip
constant _FIRST = 1, _NEXT = 2, _PREVIOUS = 3
integer lBuff = 0
string FindStr[255] = "", ReplStr[255] = "", OptStr[255] = ""
integer proc GetListFile()
    integer cBuff = GetBufferId()
    if lBuff == 0
        lBuff = CreateTempBuffer()
    else
        EmptyBuffer(lBuff)
        GotoBufferId(lBuff)
    endif
    if not InsertFile(SplitPath(CurrMacroFilename(), 
_DRIVE_|_PATH_)+"exchange.lst", _DONT_PROMPT_)
        if NumLines() < 1
            Warn("No File - Quitting")
            GotoBufferId(cBuff)
            EmptyBuffer(lBuff)
            return(FALSE)
        endif
    else
        UnMarkBlock()
    endif
    GotoBufferId(cBuff)
    return(lBuff)
end
integer proc GetFindSet(integer direction)
    integer cBuff = GetBufferId()
    GotoBufferId(lBuff)     // Goto the list buffer
    case direction
        when _FIRST
            BegFile()       // Goto beginning of file
        when _NEXT
            if not Down()   // Goto next line
                GotoBufferId(cBuff)
                return(FALSE)
            endif
        when _PREVIOUS
            if not Up()     // Goto previous line
                GotoBufferId(cBuff)
                return(FALSE)
            endif
    endcase
    BegLine()
    if 
lFind(Chr(34)+"{.*}"+Chr(34)+".*"+Chr(34)+"{.*}"+Chr(34)+".*"+Chr(34)+"{.*}"+C
hr(34),"gxc")
        FindStr = GetFoundText(1)
        ReplStr = GetFoundText(2)
        OptStr = GetFoundText(3)
    else
        GotoBufferId(cBuff)
        return(FALSE)
    endif
    GotoBufferId(cBuff)
    return(TRUE)
end
proc WhenLoaded()
    if not GetListFile()
        Warn("Couldn't load list file - aborting!")
        AbandonFile(lBuff)
        PurgeMacro(CurrMacroFilename())
        return()
    endif
    if not GetFindSet(_FIRST)
        Warn("Couldn't find initial set in list file - aborting!")
        AbandonFile(lBuff)
        PurgeMacro(CurrMacroFilename())
        return()
    endif
end
proc ReplaceString()
    MarkFoundText()
    DelBlock()
    InsertText(ReplStr)
end
proc GetNextSet()
    if not GetFindSet(_NEXT)
        warn("No more sets in list file!")
    else
        BegFile()
        BegLine()
        if not Find(FindStr, OptStr)
            warn("Find string not found in "+CurrFileName())
        endif
    endif
end
proc GetPrevSet()
    if not GetFindSet(_PREVIOUS)
        warn("No previous set in list file!")
    else
        BegFile()
        BegLine()
        if not Find(FindStr, OptStr)
            warn("Set not found in "+CurrFileName())
        endif
    endif
end
proc mFindNext()
    if not Find(FindStr, OptStr+"+")
        GetNextSet()
    endif
end
 mFindNext()
 ReplaceString()
 GetNextSet()     // From the exchange.lst file
 GetPrevSet()     // From the exchange.lst file
   Message(FindStr;",";ReplStr;",";OptStr)
snip===============================================================snip
Is there a way to make the "x" option to be used correctly as in the
following:
snip===============================================================snip
"{[a-z]}U{[a-z]}", "\1u\2", "x"
snip===============================================================snip
Everytime I try to modify the macro I get a replacement string of:
snip===============================================================snip
\1u\2
snip===============================================================snip
which is inserted into the file currently being edited.
I hope I haven't confused everyone.   Any ADDITIONAL help will be
greatly appreciated.
Thanks in advance,
Skip
---
---------------
* Origin: apana>>>>>fidonet [sawasdi.apana.org.au] (3:800/846.13)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.