----------------------------------------------------------------------
--- Knud van Eeden --- 17 August 2008 - 05:25 pm ---------------------
Computer: Editor: TSE: File: Set: Simple: Operation: Search: How to possibly search only in a fixed subset of files? Method: Filename: Change: Programmatically: Change filenames to search in source code
---
The goal is to search, within TSE, for some search text,
but only in a given fixed set of files.
---
Because your filenames to search in are stored
in the TSE macro itself,
you will have to recompile that TSE macro
if changing or adding filenames.
---
But using this method should lead to the simplest possible, minimal
quantity, source code.
---
To search only in a subset of your files,
add this filename(s) to the AddLines( "" ),
and recompile.
===
A simplest possible program with similar search functionality could be
--- cut here: begin --------------------------------------------------
PROC Main()
//
EditFile( "c:\mydirectory\myfile1.txt" )
LFind( "test", "ngiv" )
//
EditFile( "c:\mydirectory\myfile2.txt" )
LFind( "test", "ngiv" )
//
EditFile( "c:\mydirectory\mylibraryCplusPlus.cpp" )
LFind( "test", "ngiv" )
//
// and so on ...
//
END
--- cut here: end ----------------------------------------------------
===
A bit more worked out program could be the following:
===
Steps: Overview:
1. -E.g. create the following program:
--- cut here: begin --------------------------------------------------
// PROC PROCFileSearchFileSetAllSimple( STRING searchS, STRING searchOptionS )
// library: file: search: file: set: all: simple (filenamemacro=searfias.s) [kn, ri, su, 17-08-2008 15:27:37]
PROC PROCFileSearchFileSetAllSimple( STRING searchS, STRING searchOptionS )
// e.g. PROC Main()
// e.g. //
// e.g. STRING s1[255] = "test"
// e.g. STRING s2[255] = "ngiv"
// e.g. //
// e.g. IF ( NOT ( Ask( "file: search: file: group: all: simple: searchS = ", s1 ) ) )
// e.g. RETURN()
// e.g. ENDIF
// e.g. //
// e.g. //
// e.g. IF ( NOT ( Ask( "file: search: file: group: all: simple: searchOptionS = ", s2 ) ) )
// e.g. RETURN()
// e.g. ENDIF
// e.g. //
// e.g. PROCFileSearchFileSetAllSimple( s1, s2 )
// e.g. //
// e.g. END
// e.g.
// e.g. <F12> Main()
INTEGER bufferI = 0
//
INTEGER bufferCurrentI = 0
//
STRING s[255] = ""
//
INTEGER I = 0
INTEGER minI = 1
INTEGER maxI = 0
//
PushPosition()
//
bufferI = CreateTempBuffer()
//
EmptyBuffer( bufferI )
//
GotoBufferId( bufferI )
//
AddLine( "c:\mydirectory\myfile1.txt" )
AddLine( "c:\mydirectory\myfile2.txt" )
AddLine( "c:\mydirectory\mylibraryCplusPlus.cpp" )
//
// and so on...
//
// count the total of filenames in the AddLine( "..." )
//
maxI = NumLines()
//
// for all filenames which you added here using AddLine( "..." )
//
FOR I = minI TO maxI
//
// goto the next filename
//
GotoLine( I )
//
// get the filename at that line
//
s = GetText( 1, 255 )
//
// take off spaces from the filename
//
s = Trim( s )
//
// put the filename between double quotes, when it contains spaces
//
s = QuotePath( s )
//
// make sure you come back where you were at that line of the filename
//
PushPosition()
//
// search for your search text in that filename
//
IF ( NOT ( s == "" ) )
//
// check if that filename is already in the ring
//
bufferCurrentI = GetbufferId( s )
//
EditFile( s )
//
// when you did find your search text in that filename
//
IF ( NOT( LFind( searchS, searchOptionS ) ) )
//
// if your search text was not found at all in that filename, for unload that filename
//
// but only if that filename was not already loaded by you in the ring
//
IF ( bufferCurrentI == 0 )
//
QuitFile()
//
ENDIF
//
ENDIF
//
ENDIF
//
PopPosition()
//
ENDFOR
//
// close that temporary buffer, as it is not needed anymore
//
EmptyBuffer( bufferI )
//
// finally view the found text in all involved files all together
//
LFind( searchS, Format( searchOptionS, "a" ) )
//
PopPosition()
//
END
--- cut here: end ----------------------------------------------------
2. -Run the program
3. -Supply the text to search for
1. -E.g.
test
4. -Possibly change the searchoption (but the default should be OK)
5. -The search in the given filenames starts
6. -By pressing the <ESCAPE> key you will go to the next file to search in
7. -If the search text is found in the file, that file will be loaded in the
ring (for possible further investigation or search, e.g. by you)
===
Book: see also:
===
Diagram: see also:
===
File: see also:
===
Help: see also:
===
Image: see also:
===
Internet: see also:
===
Podcast: see also:
===
Screencast: see also:
===
Table: see also:
===
Video: see also:
---
----------------------------------------------------------------------