#131076 - 2004-12-10 07:58 PM
Re: Ascan() and Readfile()
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
I do not see where you open the file to read it. Chack the manual for "OPEN"
Ascan works on Arrays. I do not see where you have an array. $array in your example would normally be an ELEMENT of an ARRAY.
----------------
Scratch above as I misread ReadFile to be Readline. Still looking...
Edited by Howard Bullock (2004-12-10 07:59 PM)
|
Top
|
|
|
|
#131077 - 2004-12-10 08:04 PM
Re: Ascan() and Readfile()
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
This should be more correct.
Code:
$PATCHLIST="%temp%\patchlist"
$PNF="Scan"
If AScan(ReadFile($patchlist),$PNF) >= 0
Shell "notepad.exe"
EndIf
|
Top
|
|
|
|
#131080 - 2004-12-10 08:41 PM
Re: Ascan() and Readfile()
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Time to perform more debugging and providing answers.
Code:
$PATCHLIST="%temp%\patchlist" $aLines = ReadFile($patchlist) ? "Number of elements = " + (Ubound($aLines) + 1) ? "Ascan = " + AScan($aLines,$PNF)
for each $line in $aLines ? "'" + $line + "'" next ; Is 'Scan' output? ; Do you have CaseSensitivity turned on?
$PNF="Scan"
If AScan($aLines,$PNF) >= 0 Shell "notepad.exe" EndIf
|
Top
|
|
|
|
#131082 - 2004-12-10 10:08 PM
Re: Ascan() and Readfile()
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Then try this... Code:
$PATCHLIST="%temp%\patchlist" $aLines = ReadFile($patchlist) $TextOfFile = join($aLines, @CRLF) $PNF="Scan"
If instr($TextOfFile,$PNF) >= 0 Shell "notepad.exe" EndIf
|
Top
|
|
|
|
#131084 - 2004-12-10 10:35 PM
Re: Ascan() and Readfile()
|
brewdude6
Hey THIS is FUN
Registered: 2000-10-21
Posts: 280
Loc: Nashville, TN
|
I better include the whole script I'm testing with.
test.txt Code:
test this on a system
Code:
$PATCHLIST="c:\temp\test.txt" $aLines = ReadFile($patchlist) $TextOfFile = Join($aLines, @CRLF) $PNF="test" If InStr($TextOfFile,$PNF) >= 0 Shell "notepad.exe" EndIf
Function ReadFile($file) Dim $lf, $f, $_, $t $lf=Chr(10) $f=FreeFileHandle $_=Open($f,$file) If @error Exit @error EndIf Do $t=$t+$lf+ReadLine($f) Until @error $_=Close($f) $ReadFile=Split(SubStr($t,2),$lf) EndFunction
Even if I use a word not in text.txt, notepad will execute. I'm obviously in over my head, but it's only waist deep.
_________________________
I could have made a neat retort but didn't, for I was flurried and didn't think of it till I was downstairs. -Mark Twain
|
Top
|
|
|
|
#131086 - 2004-12-10 10:38 PM
Re: Ascan() and Readfile()
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
My mistake.
If InStr($TextOfFile,$PNF) >= 0
should be
If InStr($TextOfFile,$PNF) > 0
Instr returns 0 if not found. That code was a holdover from the ASCAN where you needed zero.
|
Top
|
|
|
|
#131088 - 2004-12-10 10:45 PM
Re: Ascan() and Readfile()
|
Howard Bullock
KiX Supporter
Registered: 2000-09-15
Posts: 5809
Loc: Harrisburg, PA USA
|
Simpler is indeed better. Not sure why I wrote it that way.
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(Allen)
and 382 anonymous users online.
|
|
|