Page 1 of 1

[SOLVED] <> and =0 filtering broken

Posted: Tue Sep 24, 2024 9:36 pm
by Randy Walker
I get a file listing and try to filter out all ".LOG" files but cannot so I am highly inclined to report this as a pair of bugs.

Code: Select all

;Simulate list of filenames and exclude all "LOG" files.
Debug "Begin by excluding all files that contain 'LOG'"
For n = 1 To 30
  x = Random(4294967295,1)
  If Random(1,0)
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".LOG"
    EndIf
  Else
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".ARC"
    EndIf
  EndIf
  ;DO NOT list files that have "log" in name!!!
  If FindString(check$,"log",#PB_String_NoCase) = 0
    Debug s$
  EndIf
Next n

Debug "Try again by checking last 3 characters"

For n = 1 To 30
  x = Random(4294967295,1)
  If Random(1,0)
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".LOG"
    EndIf
  Else
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".ARC"
    EndIf
  EndIf
  ;DO NOT list files that end with "log" in name!!!
  If LCase(right(check$,3)) <> "log"
    Debug s$
  EndIf
Next n
Either way I get same inaccurate results. So . . . What am I doing wrong???

Re: <> and =0 filtering broken

Posted: Tue Sep 24, 2024 9:50 pm
by spikey
1) In both examples, you're building a string called s$ - but testing a string called check$.
2) In the first section you're supplying the #PB_String_NoCase argument to the StartPosition parameter not the Mode parameter.

Code: Select all

;Simulate list of filenames and exclude all "LOG" files.
Debug "Begin by excluding all files that contain 'LOG'"
For n = 1 To 30
  x = Random(4294967295,1)
  If Random(1,0)
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".LOG"
    EndIf
  Else
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".ARC"
    EndIf
  EndIf
  ;DO NOT list files that have "log" in name!!!
  If FindString(s$,"log", 0, #PB_String_NoCase) = 0
    Debug s$
  EndIf
Next n

Debug "Try again by checking last 3 characters"

For n = 1 To 30
  x = Random(4294967295,1)
  If Random(1,0)
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".LOG"
    EndIf
  Else
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".ARC"
    EndIf
  EndIf
  ;DO NOT list files that end with "log" in name!!!
  If LCase(Right(s$,3)) <> "log"
    Debug s$
  EndIf
Next n

Re: <> and =0 filtering broken

Posted: Tue Sep 24, 2024 9:51 pm
by Randy Walker
AHH HAH!!! I think I found the root of the problem.
Cannot even read last 3 characters. String comes up blank:

Code: Select all

For n = 1 To 30
  x = Random(4294967295,1)
  If Random(1,0)
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".LOG"
    EndIf
  Else
    If Random(1,0)
      s$ = Hex(x) + ".PDF"
    Else
      s$ = Hex(x) + ".ARC"
    EndIf
  EndIf
  ;List last 3 characters of ALL files.
  Debug LCase(Right(check$,3))
  ;Show the whole filename.
  Debug s$
Next n
Should NOT be seeing any blank lines in this listing.

Re: <> and =0 filtering broken

Posted: Tue Sep 24, 2024 10:00 pm
by Randy Walker
spikey wrote: Tue Sep 24, 2024 9:50 pm 1) In both examples, you're building a string called s$ - but testing a string called check$.
2) In the first section you're supplying the #PB_String_NoCase argument to the StartPosition parameter not the Mode parameter.
:lol: Hahaha, I'm such an idiot. Full of I/O errors. Thank you very much Spikey!!!
( I/O ) = "Idiot Operator" :oops: