| TIP: Click on subject to list as thread! | ANSI |
| echo: | |
|---|---|
| to: | |
| from: | |
| date: | |
| subject: | Re: Testing for String in File ? |
Erstellt : Donnerstag dem 22.10.98 Erhalten am 26.10.98
von : *Tony Pater{at}3:712/848* an *All*
Hallo Tony,
why don't you use a FFind to find out which file contains the information you
need. Just write Filenames (of found files) to a file you use for input to
your fileopen part?
TP> Using 'FindFirst' can use wildcards & attributes - would
TP> that be the way to tackle the search for a file to be
TP> opened given that it is a randomnly generated filename ?
Otherwise you have to do a Findfirst/findnext to get a filename that can be
processed by fileopen.
TP> . check that a file(s) within a folder(s) contain
TP> a string (ie. I wish to test for 'BFE' in the first
TP> line of the file(s) ..... before using a 'goto' ?
ffind /bt"BFE" *.* >> $$dx
for %a in ({at}$$dx) do gosub dowhatever
del /q $$dx
quit 0
:dowhatever
set dx=%{at}fileopen[%a,read]
.....
%{at}fileclose[%dx]
return
TP> An example of how you handle/check/test for a string in
TP> an opened file would be much appreciated.
If I would do it with the commands findfirst/findnext, fileopen, fileread,
stringcompare, fileclose it should look like the following:
set dx=%{at}findfirst[*.*,n]
iff .%dx != . then
gosub checkfile
do
set dx=%{at}findnext[*.*,n]
if .dx == . leave
gosub checkfile
enddo
endiff
set dx=%{at}findclose[*.*]
:checkfile
set hnd=fileopen[%dx,r]
iff "%hnd" != "-1" then
set rline=%{at}fileread[%hnd]
iff "%rline" != "**EOF**" then
iff "%{at}index[%rline,"BFE"]" != "-1" then
gosub dowhatever
endiff
set dx=%{at}fileclose[%hnd]
endiff
endiff
return
:dowhatever
....
return
but if you do not have a newer 4dos version with the ffind implemented I
would use a:
dir /b >>$$dx
for %dx in ({at}$$dx) do gosub checkfile
del /q $$dx
quit 0
:checkfile
rem use the code as above under checkfile
return
Now it's your turn again.
- mfg *Claus* -
... Pedestrians don't realize they are a threat to the safety of cars.
--- CrossPoint v3.11 R
* Origin: Life is the victory of hope over mind. (2:2433/1204.32)SEEN-BY: 396/1 632/0 371 633/260 267 270 371 635/506 728 639/252 @PATH: 2433/1200 225 270/101 396/1 633/260 635/506 728 633/267 |
|
| SOURCE: echomail via fidonet.ozzmosis.com | |
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™.