home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Frozen Fish 1: Amiga
/
FrozenFish-Apr94.iso
/
bbs
/
alib
/
d7xx
/
d770
/
uedit.lha
/
Uedit
/
Jenkins2.LZH
/
IdentifierSearch
< prev
next >
Wrap
Text File
|
1991-04-08
|
9KB
|
245 lines
===== IdentifierSearch ======================================
(c) 1990 Robert A. Jenkins, Ph.D.
22901 Shagbark Lane
Miller Woods, IL 60411
(708) 758-7063
ALL RIGHTS RESERVED
Rick Stiles can distribute as he pleases
=============================================================================
These three commands are for Modula-2 programming.
The standard configuration search is insensitive to the surrounding. That can
make a search for an indentifier quite a pain, if it happens to occur inside
other identifiers, as in searching for "tempLoc" when you have also used
"tempLocPtr". Worse yet, try searching for an index identifier like "i" with
the standard search. Also, it is confusing to have to type in the search
string. If you do not find a match, it might be because you mistyped the
string.
There are two simple id search commands: shftCtl-f and shftCtl-b. Put the
cursor on an identifier and shftCtl-f will copy the identifier to the usual
search buffer (buf49) in case you want to do ordinary searching with F9 and
shft-F9. Then it searches forward for an identical identifier. The search is
case sensitive, but it restores the searchCaps flag to whatever value it had.
ShftCtl-b searches backward.
If it finds a match it inverts it just like the standard search command does,
but if it doesn't find a match somewhere else, the one under the cursor
remains inverted. So if you hit shftCtl-f or shftCtl-b again it will pick up
the word or phrase again. So the two commands work just like f9 and shft-f9,
except that they search for identifiers, not just any string that matches, and
they don't cancel the invert when no match is found.
The commands also enable you to search for complex phrases without fear of
typing errors. Invert the phrase for which you want to search and place the
cursor in the invert region. Then hit shftCtl-f or shftCtl-b and it will pick
up the invert and search for it. Quite handy for looking for
transactionPtr^.numberOfShares Traded :=
and the like when you are trying to find out whether and where a variable got
initiated. Including the := makes sure that you find only those places where
a value is assigned, not where the value was used.
There is another command which greatly assists with cleaning up your import
lists. Put the cursor on an identifier, or in an invert of a phrase, and hit
shftCtl-i. It will pick up the identifier (or phrase) and search forward,
then drop you into a loop where hitting f or b will search forward or
backward. Hitting s or e will move to the start of the file and search
forward or the the end of the file and search backward. Exit the loop with q.
When it fails to find another occurrence it returns you to the next identifier
in the list and drops out of the loop. So if the identifier is never used you
just jump to the next identifier. If it is used, you can walk around forward
and backward looking at where it is used. The s and e options give you some
control over the walking. If you tire of walking around, just hit q and you
will pop back to the next identifier in the list. If you want to stay where
you are, hit some other key (like mouse down) and you will drop out of the
loop with the cursor positioned on the last occurrence you found.
This command is handy for searching around for other uses of the identifier,
after which you can always return to where you were when you started browsing.
There are two awkwardnesses. If you happen to start with the last occurrence
you automatically drop out of the loop because the search forward fails. If
you use the e option you will miss the last occurrence if it happens to be
absolutely the last thing in the file, which will never happen in a Modula-2
file.
buf49 = search string
buf50 = message
n50 = flag(0=false,1=searchCapsTrue)
n51 = flag(-1=backward,1=forward)
n52 = flag(0=else,1=shftCtl-i)
n53 = flag(0=first search,1=else)
n54,
n55 = fbq input in shftCtl-i loop
n56 = flag(0=search FALSE,1=search TRUE)
locI = location of next identifier in the list (bookmark d)
=============================================================================
Pick up word or hilited phrase and search forward
<shftCtl-f:
equateNum(n51,1)
equateNum(n52,0)
runKey(14)
>Sunday 24-Feb-91 14:26:34
Pick up word or hilited phrase and search backward
<shftCtl-b:
equateNum(n51,-1)
equateNum(n52,0)
runKey(14)
>Sunday 24-Feb-91 12:39:15
Scan for identifier using fb loop, starting at sFile
<shftCtl-i:
equateNum(n51,1) ..n51=1=search forward
equateNum(n52,1) ..n52=1=fb loop
equateNum(n53,0) ..n53=0=first search
LABEL(0) ..fb loop
runKey(14)
if (eqNum(n56,0)) return
putMsg("f=forward, b=backward, s=sFile, e=eFile, q=quit")
getKeyVAL(n54,n55)
switch(n55) {
case("f") {equateNum(n51,1) }
case("b") {equateNum(n51,-1) }
case("s") {moveCursor(curFile,sFile)
equateNum(n51,1) }
case("e") {moveCursor(curFile,eFile)
moveCursor(curFile,sChar)
equateNum(n51,-1) }
case("q") {putMsg("Quit fb id search, returned to next id")
moveCursor(curFile,locI)
vScroll(atCursor)
return}
default {putMsg("Quit fb id search")
vScroll(atCursor)
return} }
goto label(0)
>Sunday 24-Feb-91 18:43:21
Identifier search
<14:
..if fbq loop search, but not first time, skip ahead and use old id
if (eqNum(n52,1) & eqNum(n53,1)) goto label(0)
..make search case sensitive
if (not getFlag(curFile,searchCaps)) {
equateNum(n50,1)
flipFlag(curFile,searchCaps) }
..get identifier or phrase
if (!((eqLoc(curFile,atCursor,sInvert)) |
((gtLoc(curFile,atCursor,sInvert) &
gtLoc(curFile,eInvert,atCursor))))) {
..find identifier under cursor
..in Modula an identifier is strictly alphanumeric
..note that sWord-eWord includes alpha, digits, and "'"
if (is(curFile,"'") | !(is(curFile,alpha) | is(curFile,digit))) {
putMsg("CURSOR IS NOT ON AN IDENTIFIER")
return }
while ((is(curFile,alpha) | is(curFile,digit)) & !is(curFile,"'")) incLoc(curFile,atCursor)
..alertUser ("right end of id")
equateLoc(curFile,eInvert,atCursor)
decLoc(curFile,atCursor)
while ((is(curFile,alpha) | is(curFile,digit)) & !is(curFile,"'")) decLoc(curFile,atCursor)
incLoc(curFile,atCursor)
..alertUser ("left end of id")
equateLoc(curFile,sInvert,atCursor) }
..before searching find next word in file (import list?), for next search
moveCursor(curFile,eWord)
moveCursor(curFile,eWord)
moveCursor(curFile,sWord)
..set bookmark d in case we want to return
equateLoc(curFile,locI,atCursor)
if (eqNum(n51,1)) .. searching fwd
moveCursor(curFile,eInvert)
else
moveCursor(curFile,sInvert)
..alertUser("ready to search")
LABEL(0)
if (eqNum(n52,1)) { ..in fb loop
..putMsg(n51) alertUser("fb loop LABEL(0): see n51")
if (eqNum(n53,0)) { ..first search, pick up id
equateNum(n53,1)}
else ..not first, use old id
goto label(1) }
..store id in search buffer
freeBuf(buf49)
insertRgn(buf49,sFile,curFile,invert)
label(1)
setSearch(buf49)
..putMsg(buf49)
..alertUser("got search")
while(gtLoc(curFile,eFile,atCursor)) {
if (search (curFile,sInvert,eInvert,n51)) {
putMsg(buf49)
..alertUser("found candidate")
..check for whole word
equateLoc(curFile,locA,sInvert)
equateLoc(curFile,locB,eInvert)
decLoc(curFile,atCursor)
..alertUser("checking left")
if (is(curFile,alpha) | is(curFile,digit)) {
..alertUser("alpha|numeric on left")
goto label(2) } ..look for another candidate
moveCursor(curFile,eInvert)
..alertUser("checking right")
if (is(curFile,alpha) | is(curFile,digit)) {
..alertUser("alpha on right")
goto label(2) } ..look for another candidate
decLoc(curfile,atCursor)
if (eqNum(n50,1)) flipFlag(curFile,searchCaps)
refreshDisplay
freeBuf(buf50)
insertRgn(buf50,sFile,"Next occurrance",all)
putMsg(buf50)
equateNum(n56,1) ..search=TRUE
return }
else {
equateNum(n56,0) ..search=FALSE, quit fb loop
if (eqNum(n52,1)) { ..in fb loop
putMsg("SEARCH FAILED returned to next id in list")
moveCursor(curFile,locI) }
else { ..simple search fwrd or bkwrd
if (eqNum(n51,-1)) {
putMsg("SEARCH FAILED, no match above here")
moveCursor(curFile,sInvert) }
else {
putMsg("SEARCH FAILED, no match below here")
moveCursor(curFile,eInvert)
moveCursor(curFile,sChar) } }
vScroll(atCursor)
return }
LABEL(2) ..found embedded candidate, go to next word and search again
if (eqNum(n51,1))
moveCursor(curFile,eWord)
else
moveCursor(curFile,sWord)
}
>Sunday 24-Feb-91 18:40:10
Test suite
============
solo
it
digit
digitize
digit
Test Case and it is a Test Case
test case and it is the test case
test this case test too
blah blah test case
TraceSTRING ('word', word);
TraceSTRING ('word', word);
INC(var34);
INC(var)
INC(var2)
INC(var)
DEC(var2)
DEC(var3)
DEC(var2)
Test Case and it is a Test Case