scanning strings

BlitzPlus Forums/BlitzPlus Programming/scanning strings

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Try this:

Global errors

Dim filelinearray(1000000);This should store the entire file contents - enlarge as needed
Dim filevulnarray(1000000);This holds any "vulnerabilities" found


Function ScanFile(sourcefile,outputfile)


file = ReadFile(sourcefile);The file to be scanned

i = 0

While Not Eof(file);Keep going until the file ends

filelinearray(i) = readline(file)
i = i + 1;Next iteration & array element

Wend

CloseFile file

For i = 0 to 1000000;Check the entire file line array
    For letter = 1 To Len(filelinearray(i));Scan each line letter by letter
        If Mid(filelinearray(i),letter,1) = Chr([num]);Replace [num] with the character to scan for
            filevulnarray(errors) = filelinearray(i)
            errors = errors + 1
        EndIf
    Next
Next

file = WriteFile(outputfile)

For i = 0 To errors
    WriteLine(file,filevulnarray(i))
Next

CloseFile file


End Function

This is just a ten-minute thing off the top of my head, I've never actually even thought of it before now - hope it works for ya!