TIP: Click on subject to list as thread! ANSI
echo: qedit
to: ALL
from: SKIP GORE
date: 1997-09-02 01:08:00
subject: Help me understand

From: Skip Gore 
I use the following macro, but can't seem to understand its workings.
Could someone, please explain the buffers to me and how they are used in
the following:
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()
Replace(FindStr, ReplStr,OptStr)
//    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)
Message("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() WordRight()
 GetNextSet()     // From the exchange.lst file
 GetPrevSet()     // From the exchange.lst file
   Message(FindStr;",";ReplStr;",";OptStr)
---
---------------
* 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™.