From: Larry Serflaten on

"Karl E. Peterson" <karl(a)mvps.org> wrote

> > I would think you could simplfy that all to some boolean
> > expression....
>
> Serious? I'd like to see that.

Well it would be a complex boolean expression, but less code than
what you've shown. To start you'd set up the truth table and look for
patterns. Surprisingly enough, there are a few easy patterns that
emerge. Using the code below against your VBDirInclude function
will build that truth table (skipping over any occurance of the volume
lable attribute).

The first thing you'd notice is that the top half is exactly the same as
the bottom half, so you can mask both inputs to &H1F. Then,
If the found input is less than 2, it doesn't matter what was sought,
you can return true right away. Also, there is a horizontal pattern
that repeats for all blocks that have a true response, so you could
colapse (mask) those out to develop further tests for just one block.
etc. It would be something to ponder on a rainy day.....

Add a textbox to a new form, set the IDE properties and add
the code below, and your own VBDirInclude function to see
the table....

LFS

Option Explicit

Private Sub Form_Load()
Dim fnd&, sot&, vb As Boolean

' Set in IDE
' Text1.MultiLine = True
' Text1.ScrollBars = 2

Text1.Font.Name = "Lucida Console"
Text1.Text = "FND SOT --> 10 20 30" & vbCrLf
Text1.SelStart = 100
For fnd = 0 To &H3F
If (fnd And 8) <> 8 Then
Text1.SelText = Right$("00" & Hex(fnd), 2) & " "
For sot = 0 To &H3F
If (sot And 8) <> 8 Then
vb = VBDirInclude(fnd, sot)
Text1.SelText = IIf(vb, "X", ".")
If (sot And 7) = 7 Then Text1.SelText = " "
End If
Next
Text1.SelText = vbCrLf
If (fnd And 7) = 7 Then Text1.SelText = vbCrLf
End If
Next

End Sub

Private Sub Form_Resize()
Text1.Move 0, 0, ScaleWidth, ScaleHeight
End Sub





From: Karl E. Peterson on
Larry Serflaten wrote:
> "Karl E. Peterson" <karl(a)mvps.org> wrote
>
>> > I would think you could simplfy that all to some boolean
>> > expression....
>>
>> Serious? I'd like to see that.
>
> Well it would be a complex boolean expression, but less code than
> what you've shown.

I guess the code I had there was sort of laying out how I arrived at what was
included and what wasn't. Not the best algorithm, perhaps, but maybe one that best
paints the picture for others of what's happening?

> To start you'd set up the truth table and look for
> patterns. Surprisingly enough, there are a few easy patterns that
> emerge. Using the code below against your VBDirInclude function
> will build that truth table (skipping over any occurance of the volume
> lable attribute).
>
> The first thing you'd notice is that the top half is exactly the same as
> the bottom half, so you can mask both inputs to &H1F. Then,
> If the found input is less than 2, it doesn't matter what was sought,
> you can return true right away. Also, there is a horizontal pattern
> that repeats for all blocks that have a true response, so you could
> colapse (mask) those out to develop further tests for just one block.
> etc. It would be something to ponder on a rainy day.....

Very intriguing! I'll have to play around with that.

How do you suppose that'd cope with attributes introduced after VB's demise? For
instance, pagefile.sys is -1&, and "System Volume Information" is &h2016.
--
..NET: It's About Trust!
http://vfred.mvps.org


From: Larry Serflaten on

"Karl E. Peterson" <karl(a)mvps.org> wrote in message news:%239X7sSS4IHA.3484(a)TK2MSFTNGP05.phx.gbl...
> Larry Serflaten wrote:
> > "Karl E. Peterson" <karl(a)mvps.org> wrote
> >
> >> > I would think you could simplfy that all to some boolean
> >> > expression....
> >>
> >> Serious? I'd like to see that.
> >
> > Well it would be a complex boolean expression, but less code than
> > what you've shown.
>
> I guess the code I had there was sort of laying out how I arrived at what was
> included and what wasn't. Not the best algorithm, perhaps, but maybe one that best
> paints the picture for others of what's happening?
>
> > To start you'd set up the truth table and look for
> > patterns. Surprisingly enough, there are a few easy patterns that
> > emerge. Using the code below against your VBDirInclude function
> > will build that truth table (skipping over any occurance of the volume
> > lable attribute).
> >
> > The first thing you'd notice is that the top half is exactly the same as
> > the bottom half, so you can mask both inputs to &H1F. Then,
> > If the found input is less than 2, it doesn't matter what was sought,
> > you can return true right away. Also, there is a horizontal pattern
> > that repeats for all blocks that have a true response, so you could
> > colapse (mask) those out to develop further tests for just one block.
> > etc. It would be something to ponder on a rainy day.....
>
> Very intriguing! I'll have to play around with that.
>
> How do you suppose that'd cope with attributes introduced after VB's demise? For
> instance, pagefile.sys is -1&, and "System Volume Information" is &h2016.
> --
> .NET: It's About Trust!
> http://vfred.mvps.org
>
>


From: Larry Serflaten on

"Karl E. Peterson" <karl(a)mvps.org> wrote

> Very intriguing! I'll have to play around with that.
>
> How do you suppose that'd cope with attributes introduced after VB's demise? For
> instance, pagefile.sys is -1&, and "System Volume Information" is &h2016.

Not to mention compressed or encrypted....

As you saw, I stopped the count at &H3F because anything sought above that
would produce an error from Dir(). Obviously atrributes sought that throw an error
when used for VB's Dir() could not be included. It would be OK to have found
items with higher attribute values, which should pass or fail based on those lower
order bits. (< &H40)

Interesting that pagefile.sys returns -1 for you when I get an Error 5 from VB5's
GetAttr function. Are you sure that's not some sort of artifact?

LFS





From: Karl E. Peterson on
Larry Serflaten wrote:
> "Karl E. Peterson" <karl(a)mvps.org> wrote
>
>> Very intriguing! I'll have to play around with that.
>>
>> How do you suppose that'd cope with attributes introduced after VB's demise? For
>> instance, pagefile.sys is -1&, and "System Volume Information" is &h2016.
>
> Not to mention compressed or encrypted....
>
> As you saw, I stopped the count at &H3F because anything sought above that
> would produce an error from Dir(). Obviously atrributes sought that throw an
> error
> when used for VB's Dir() could not be included. It would be OK to have found
> items with higher attribute values, which should pass or fail based on those lower
> order bits. (< &H40)

Yeah, that's pretty much how I'm handling it too, albeit more verbosely. <g>

> Interesting that pagefile.sys returns -1 for you when I get an Error 5 from VB5's
> GetAttr function. Are you sure that's not some sort of artifact?

I override the native GetAttr:

Private Declare Function GetFileAttributes Lib "kernel32" Alias
"GetFileAttributesW" (ByVal lpFileName As Long) As Long

Public Function GetAttr(ByVal FileName As String) As Long
' Override VBs lame GetAttr function, because it cannot cope
' with attributes introduced after 1998.
GetAttr = GetFileAttributes(StrPtr(FileName))
End Function

(Yeah, I'm just about through worrying over 9x support, too.)
--
..NET: It's About Trust!
http://vfred.mvps.org