[Date: 3 April 1995]
[Time: 2:03am]
The previous fix did not work right upon further paranoid testing.
This annoyed me enough that I've thoroughly fixed the logic once and
for all. It works perfectly now, at the cost of some slowdown for the
additional overhead. You may wish to use the original version that I
posted if you know for a fact that the line length will never reach
exactly 2032 characters (the maximum line length under TSEditor 2.00)
AND have a non-white character at the end of the line. That original
version is noticeably faster and may be suitable for any application
for which you may have it in mind.
There is an additional macro required to make this fixed routine
work right. This additional macro may be used as a standalone macro
bound to a key. Ordinarily, a marked word cannot be copied or moved
over existing text as can be a marked column block. This additional
macro marks a word as a column block, so that it can be copied or
moved over another part of your text. It returns the same values as
MarkWord() and can be used as a drop-in replacement for MarkWord().
Here is the entire macro set again, but fixed and thoroughly
debugged:
/* --------------------------88------------------------- */
constant yes = True, no = False,
zero = 0, one = 1, two = 2, ten = 10,
maxeditorcolumn = 2032
string emptystring[0]
integer proc mMarkWord() /* mark word as column block */
integer success = no
if isWord()
MarkWord()
MarkColumn(CurrLine(), Query(BlockBegCol),
CurrLine(), Query(BlockEndCol))
success = yes
endif
return(success)
end
string proc iGetWordAtCursor()
string wordatcursor[127] = emptystring
PushPosition()
PushBlock()
if MarkWord() or (Left() and MarkWord())
wordatcursor = GetMarkedText()
endif
PopBlock()
PopPosition()
return(wordatcursor)
end
string proc iGetOrdinalWordInLine(integer linenum, integer ordinal)
string ordinalwordinline[127] = emptystring
integer wordnum = zero
PushPosition()
GotoLine(linenum)
if (PosFirstNonWhite() >= one)
GotoPos(PosFirstNonWhite())
PushBlock()
repeat
if isWord()
mMarkWord()
GotoBlockEnd()
UnMarkBlock()
wordnum = wordnum + one
endif
until (wordnum == ordinal)
or (CurrCol() == maxeditorcolumn)
or not WordRight()
or not isWord()
PopBlock()
if isWord() and (wordnum == ordinal)
ordinalwordinline = iGetWordAtCursor()
endif
endif
PopPosition()
return(ordinalwordinline)
end
proc mTest(integer line, integer words)
string wordcapture[127] = emptystring
integer counter = one
repeat
wordcapture = "Word (" + Str(counter, 10) + "): "
+ iGetOrdinalWordInLine(line, counter)
AddLine(wordcapture)
counter = counter + one
until not (counter <= words)
end
mTest(one, ten)
/* --------------------------88------------------------- */
--- FidoPCB v1.4 [ff151/a]
---------------
* Origin: SemWare Support BBS * 404-641-8968 * (1:133/314)
|