[SOLVED] <> and =0 filtering broken

Just starting out? Need help? Post your questions and find answers here.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

[SOLVED] <> and =0 filtering broken

Post 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???
Last edited by Randy Walker on Tue Sep 24, 2024 10:01 pm, edited 1 time in total.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
User avatar
spikey
Enthusiast
Enthusiast
Posts: 778
Joined: Wed Sep 22, 2010 1:17 pm
Location: United Kingdom

Re: <> and =0 filtering broken

Post 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
Last edited by spikey on Tue Sep 24, 2024 9:53 pm, edited 1 time in total.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: <> and =0 filtering broken

Post 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.
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Randy Walker
Addict
Addict
Posts: 1109
Joined: Sun Jul 25, 2004 4:21 pm
Location: USoA

Re: <> and =0 filtering broken

Post 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:
- - - - - - - - - - - - - - - -
Randy
I *never* claimed to be a programmer.
Post Reply