• Anonymous Coward (unregistered)

    First Post.  Do I win a prize?

  • frosty (unregistered) in reply to Anonymous Coward

    No.
    <:o)

  • Mikademus (unregistered) in reply to Anonymous Coward
    Anonymous:
    First Post.  Do I win a prize?

    No, only the general loathing of everyone else
  • AKrotkov (unregistered)

    Why not LUROUC! Let us reinvent our own code. A heck of a lot more pronounceable.

  • Martin Carolan (unregistered)

    Haven't used any VB based languages for a while, but is it me or will line 2 cause the function to always return false? Could be your typo

    Function FrontPage_FileExists(fspath)
    On Error Resume Next
    FrontPage_FileExists = False
    Set fs = CreateObject("Scripting.FileSystemObject")
    Err.Clear
    Set istream = fs.OpenTextFile(fspath)
    If Err.Number = 0 Then
    FrontPage_FileExists = True
    istream.Close
    End If
    Set istream = Nothing
    Set fs = Nothing
    End Function

    														</span><br>
    
  • TheDan666 (unregistered)

    Brillant!  The FileSystem object in VB is actually very resource-intensive so its probably best to just always return false instead of actually checking.  Besides that, the complete reinventing of an already existing system function is nice as well.  Other key features are the fact that actually attempts to open the file to check to see if its open which will double processing time.  This thing probably works great on large files.

     

    --The Dan

  • (cs) in reply to Martin Carolan
    Anonymous:
    Haven't used any VB based languages for a while, but is it me or will line 2 cause the function to always return false? Could be your typo

    Function FrontPage_FileExists(fspath)
    On Error Resume Next
    FrontPage_FileExists = False
    Set fs = CreateObject("Scripting.FileSystemObject")
    Err.Clear
    Set istream = fs.OpenTextFile(fspath)
    If Err.Number = 0 Then
    FrontPage_FileExists = True
    istream.Close
    End If
    Set istream = Nothing
    Set fs = Nothing
    End Function


     

      In VB, the function name itself is used just like any other variable, so its value can be changed later in the code. In this case, the value is changed to true five lines down.

  • (cs)

    The name of the method is wrong; it does not only check if the file exists, but also if it can be opened. Opening an existing file can possibly fail for various reasons (missing privileges etc.)

  • (cs) in reply to Martin Carolan
    Anonymous:
    Haven't used any VB based languages for a while, but is it me or will line 2 cause the function to always return false? Could be your typo

    Function FrontPage_FileExists(fspath)
    On Error Resume Next
    FrontPage_FileExists = False
    Set fs = CreateObject("Scripting.FileSystemObject")
    Err.Clear
    Set istream = fs.OpenTextFile(fspath)
    If Err.Number = 0 Then
    FrontPage_FileExists = True
    istream.Close
    End If
    Set istream = Nothing
    Set fs = Nothing
    End Function
    														</span><br></div></BLOCKQUOTE><br><br>It's you...<br><br>The "FrontPage_FileExists = True" line will overwrite the false value if the file is found.<br><br>-ds<br>
    
  • Martin Carolan (unregistered) in reply to DisturbedSaint

    I sit corrected[:)]

  • GreatWhiteDork (unregistered)

    Suggestion:

    IHBLRIA ("Ih - bil - ree - uh")

    WTF: The code truly sucks.  Thanks.  Every time I think I suck, I like to look at these.  Then I think I'm awesome.

  • (cs)

    Shouldn't it be...


    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath) then
            FrontPage_FileExists = True
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function


    -ds
    <p>



  • (cs) in reply to DisturbedSaint

    Oh that's ugly...let me try again


    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath) Then
            FrontPage_FileExists = True
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function



    -ds
  • (cs) in reply to DisturbedSaint

    DAMMIT

    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath) Then
            FrontPage_FileExists = True
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function

  • (cs) in reply to DisturbedSaint

    DisturbedSaint:
    DAMMIT
    ...

    You almost had it...

    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath)) Then
            FrontPage_FileExists = True
        ElseIf IsTrue(fs.FileExists(fspath)) = False Then
            FrontPage_FileExists = False
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function

    $10 says this doesn't show up right in the forum...

  • Just replying (unregistered) in reply to TheDan666
    Anonymous:

    Brillant!  The FileSystem object in VB is actually very resource-intensive so its probably best to just always return false instead of actually checking.  Besides that, the complete reinventing of an already existing system function is nice as well.  Other key features are the fact that actually attempts to open the file to check to see if its open which will double processing time.  This thing probably works great on large files.

     

    --The Dan



    Doesn't always just return false, and isn't checking to see if a file is open...

    While it is a WTF, your response is just as bad if not worse.
  • (cs)
    Alex Papadimoulis:

    I think it's non-usage stems from the fact that IHBLRIA is completely unpronounceable. I don't know if I should be saying ib-le-ree-ah (rhyming with, appropriately, diarrhea) or just stumbling with a new pronunciation every time, like i-hib-el-ar-ee (your guess is as good as mine).



    Oddly enough, I was trying to come up with a pronunciation as I read it, before I got to the comments about pronunciation.

    I came up with   ib-LAIR-ee-ah, which sounds like hysteria.
  • Martin Carolan (unregistered) in reply to Manni

    $10 please

  • (cs) in reply to Just replying
    Anonymous:
    Anonymous:

    Brillant!  The FileSystem object in VB is actually very resource-intensive so its probably best to just always return false instead of actually checking.  Besides that, the complete reinventing of an already existing system function is nice as well.  Other key features are the fact that actually attempts to open the file to check to see if its open which will double processing time.  This thing probably works great on large files.

     

    --The Dan



    Doesn't always just return false, and isn't checking to see if a file is open...

    While it is a WTF, your response is just as bad if not worse.


    Perhaps the Anonymous poster meant to say 'Other key features are the fact that actually attempts to open the file to check to see if it exists which will double processing time.'  If that's the case, then their assessment isn't so bad.  The use of "its" instead of "it's," however, deserves a BLAM.

    Oh, and let's see if this post is

  • (cs) in reply to sinistral

    OK, no pizza for me.  Perhaps I shouldn't bother trying in Firefox on Linux.

  • Gerben Rampaart (unregistered) in reply to Just replying

    You are being a bit harsh here Alex. It isn't really a wtf, is it?

    I admit, it's just bad code, it's not efficient, it allready exists in the standard libraries, and so on, but a true wtf makes me want to drop my jaw on the desk and scream "What The Fuck!".

    If you guys have ever managed a vba or vb application at some time in the past, you have without a doubt encountered code like this. In fact, it's probably all over the place. This is sort of on par with the level of the vb programmers out there.

  • Anonymous lurker (unregistered) in reply to DisturbedSaint

    Actually, considering its FrontPage, I think your first two posts are more accurate.

  • (cs) in reply to sinistral

    sinistral:
    OK, no pizza for me.  Perhaps I shouldn't bother trying in Firefox on Linux.

    I have tried everything and can't get it to work.  It's one of the best kept secrets of the forum.  [pi]

  • (cs) in reply to Gerben Rampaart

    Gerben Rampaart: What more do you need to call this a WTF? You admitted it's bad code, inefficient, replaces a function that already exists in the object library that it accesses on its own... worst of all (for me anyways) is that this is auto-generated code! If some VB newbie punched this one out, then yeah maybe it's not so bad. But MS created FrontPage, and they aren't properly using the FileSystemObject library, which is also an MS creation!

  • (cs) in reply to Gerben Rampaart

    My memory is a bit hazy around old ASP, but I do remember pre-3.0 ASP did not have a lot of library methods implemented.  Some of the omissions were so glaring they left you scratching your head in disbelief.  I don't remember anything specific from those days beyond my daily bewilderment, so I couldn't say for sure.  But it is possible (albeit highly unlikely) that FileExists was not yet implemented when this piece of code was written.

  • ByteJuggler (unregistered) in reply to Manni

    I'm know this as NIH syndrome.. ("Not Invented Here" so we don't like/trust it...)

  • Rodpheus (unregistered) in reply to Manni
    Manni:

    DisturbedSaint:
    DAMMIT
    ...

    You almost had it...

    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath)) Then
            FrontPage_FileExists = True
        ElseIf IsTrue(fs.FileExists(fspath)) = False Then
            FrontPage_FileExists = False
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function

    $10 says this doesn't show up right in the forum...

    Doesnt FileExists = False meand the file doesnt exist? So its the same as FileNotFound?

    So..

    Function FrontPage_FileExists(fspath)
        Set fs = CreateObject("Scripting.FileSystemObject")
        FrontPage_FileExists = fs.FileExists(fspath)
        Set fs = Nothing
    End Function

  • Anonymous Coward's first cousin (unregistered)
    Alex Papadimoulis:

    ...I think it's non-usage stems from the fact that IHBLRIA is completely unpronounceable...

    ...that they pronounceable or, at a bare minimum, contain the letter X...



    ...I think its asdf non-usage stems from the fact that IHBLRIA is completely unpronounceable...

    and

    ...that they are pronounceable or, at a bare minimum, contain the letter X...

    please.
  • (cs)

    I don't see the problem.

    The only improvement I could suggest would be to rename the function:

    FrontPage_ <br>    FSOIsAccessible_<br>    AndFileExists_ <br>    AndFileIsReadableByThisUser_ <br>    AndFileIsNotLocked_ <br>    AndNothingElseIsWrongLikeTheNetworkBeingDownOrSomething <br>    (fspath)

  • Anonymous Coward's first cousin (unregistered) in reply to Anonymous Coward's first cousin

    Haha. No asdf there.

  • (cs) in reply to Rodpheus
    Anonymous:
    Doesnt FileExists = False meand the file doesnt exist? So its the same as FileNotFound?

    So..

    Function FrontPage_FileExists(fspath)
        Set fs = CreateObject("Scripting.FileSystemObject")
        FrontPage_FileExists = fs.FileExists(fspath)
        Set fs = Nothing
    End Function



    You must have missed yesterday's post.
  • (cs) in reply to Manni
    Manni:

    DisturbedSaint:
    DAMMIT
    ...

    You almost had it...

    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath)) Then
            FrontPage_FileExists = True
        ElseIf IsTrue(fs.FileExists(fspath)) = False Then
            FrontPage_FileExists = False
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function

    $10 says this doesn't show up right in the forum...

    Please send my $10 to the American Red Cross thanks!

    [pi]

  • (cs) in reply to Mung Kee
    Mung Kee:

    sinistral:
    OK, no pizza for me.  Perhaps I shouldn't bother trying in Firefox on Linux.

    I have tried everything and can't get it to work.  It's one of the best kept secrets of the forum.  [pi]

    It's as easy as... well... pie.

    [image]

    Seriously though, it requires IE for the way I figured it out.  Select the picture, or just right click on it and copy.  Then you can paste it into the posting text box.

  • (cs)
    Alex Papadimoulis:

    I was a bit disappointed that the acronym IHBLRIA (Invented Here, But Let's Reinvent It Anyway) did not seep into the general techo-nonsense-babble-buzzword lexicon. Rarity doesn't seem to be the problem: today's code (from Manni) is the third case of IHBLRIA I've posted. I think it's non-usage stems from the fact that IHBLRIA is completely unpronounceable. I don't know if I should be saying ib-le-ree-ah (rhyming with, appropriately, diarrhea) or just stumbling with a new pronunciation every time, like i-hib-el-ar-ee (your guess is as good as mine).



    Some people are easily offended if others try to pronounce acronyms. So I'd suggest a conservative "I age bee el err I 'ey".

  • (cs) in reply to Ytram
    Ytram:
    Mung Kee:

    sinistral:
    OK, no pizza for me.  Perhaps I shouldn't bother trying in Firefox on Linux.

    I have tried everything and can't get it to work.  It's one of the best kept secrets of the forum.  [pi]

    It's as easy as... well... pie.

    [image]

    Seriously though, it requires IE for the way I figured it out.  Select the picture, or just right click on it and copy.  Then you can paste it into the posting text box.

     

    You mean copy an "already posted" pizza icon?  That's a little klugey.  If that's the only way to do it, I'd love to know two things.  What's the purpose of this fancy list of icons it if you can't select from there and how did the first pizza poster get it to work?

     

     

  • (cs) in reply to Mung Kee

    pi

  • (cs) in reply to Scott B.

    Annoying, heh.  Well drag and drop seemed to work, but then I tried to insert some text and maybe messed it up, trying again.  (Preview would be a nice feature too)

  • (cs) in reply to bugsRus
    bugsRus:
    Manni:

    DisturbedSaint:
    DAMMIT
    ...

    ...

    $10 says this doesn't show up right in the forum...

    Please send my $10 to the American Red Cross thanks! [pi]

    I wasn't saying that I'm betting $10. Heavens no, gambling is illegal in my home state. I was just saying that I have a $10 bill with a negative attitude.

  • (cs) in reply to Mung Kee
    Mung Kee:
    You mean copy an "already posted" pizza icon?  That's a little klugey.  If that's the only way to do it, I'd love to know two things.  What's the purpose of this fancy list of icons it if you can't select from there and how did the first pizza poster get it to work?


    Yeah, it's a kludge.

    As far as how the first poster got it to work is kind of philosophical question, don't you think?  Kind of a chicken and egg question.  Some say that it gradually changed over millions of years from a simple punctuation mark like the period, while others propose that it sprang to life relatively recently.

    <font size="1">Or the first guy just used the <img src="pizza pic url"> hack.</font>
  • (cs)

    XWRL: eXtensible Wheel Reinvention Language.

    It's too bad these guys never knew about the FileNotFound paradigm, because I bet it could have saved them a lot of rewritten code. [I]

  • (cs) in reply to Manni
    Manni:

    $10 says this doesn't show up right in the forum...




    Please make it out to "CASH" and send to:

    PO Box 10012
    Jersey City NJ 07307

    Thanks,

       -dave-
  • (cs)

    or try Make Old New Everywhere Y'all...  (y'think frontpage was paid-by-the-line?)

  • (cs) in reply to vDave420
    vDave420:
    Manni:

    $10 says this doesn't show up right in the forum...




    Please make it out to "CASH" and send to:

    PO Box 10012
    Jersey City NJ 07307

    Thanks,

       -dave-


    Hrmm.  I suppose a quick glance at the scrollbar would have indicated that this probably wasn't the first post to make this joke. 

    My appologies =)

       -dave-

  • (cs) in reply to Scott B.

    good job!

    [pi][pi]

  • (cs) in reply to AndrewVos
    AndrewVos:

    good job!

    [pi][pi]



    nope, bad job, just like almost everyone else.
  • Al (unregistered) in reply to Gerben Rampaart

    This is not unique to vb programmers.  We had someone fresh out of  college writing several lines in C++ using istream because he never learned the access function in school.

  • (cs) in reply to Rodpheus

    Anonymous:

    Function FrontPage_FileExists(fspath)
        Set fs = CreateObject("Scripting.FileSystemObject")
        FrontPage_FileExists = fs.FileExists(fspath)
        Set fs = Nothing
    End Function

    I hate when people add the silly "set xx = Nothing" lines to their code one or two instructions before the variable goes out of scope .....

     

  • Lews (unregistered) in reply to DisturbedSaint
    DisturbedSaint:
    DAMMIT

    Function FrontPage_FileExists(fspath)
        FrontPage_FileExists = False
        Set fs = CreateObject("Scripting.FileSystemObject")
        If IsTrue(fs.FileExists(fspath) Then
            FrontPage_FileExists = True
        Else
            FrontPage_FileExists = FileNotFound
        End If
        Set fs = Nothing
    End Function

    Having seen pages made in FrontPage, I can safely say you were correct the first two times

  • Martin Carolan (unregistered) in reply to Jeff S

    In asp you need to set it to  nothing manually:

    <nobr style="font-family: tahoma; font-size: 17px;">When does ASP release COM objects? </nobr>
    [image]
    <nobr class="footer">    http://www.aspfaq.com/2031    <!-- &nbsp;&nbsp;&nbsp;11,989 requests to date&nbsp;&nbsp;&nbsp; -->    created: 2000-08-13        last updated: 2005-03-16 23:36       this article is printer friendly   </nobr>
    Page-level 
     
    If you have page-level objects and are running IIS 4.0, they are not released at the point in the page where you issue the following command: 
     
    <% 
        set object = nothing 
    %>
     
    Page-level objects are NOT released until the page goes out of scope. And, according to many reports, the memory is not released completely if the object is *not* explicitly destroyed, as per above. 
     
  • (cs)
    <FONT color=#0000ff>Function</FONT> FrontPage_FileExists(fspath As String) As Boolean
      On Error Resume Next   <FONT color=#006400>'not absolutely necessary</FONT>
      FrontPage_FileExists = <FONT color=#0000ff>(Len(Dir(</FONT><FONT color=#000000>fspath, vbNormal)) <> 0)</FONT>
    End Function

    <FONT face=Arial color=#000000>If the FileExists() method didn't exist, the simplest solution would </FONT><FONT face=Arial color=#000000>implement a native method, like Dir().  The shortest/simplest/fastest solution is supplied (above).  It avoids scripting object creation and deletion.</FONT>

Leave a comment on “The Return of IHBLRIA”

Log In or post as a guest

Replying to comment #:

« Return to Article