• Elvis (unregistered)

    So was the var "Work" used because the developer got pissed?

    Damnt I didnt get 3 points.

  • hrm (unregistered)

    I'm pretty sure not trying to understand what the code really does is what allows us to keep reading without our heads exploding.

  • Phil Scott (unregistered)

    I think you could probably fill a couple months worth of DailyWTF where people are trying to properly escape SQL statements from classic ASP. Bless their hearts for at least trying. They know HtmlEncode and UrlEncode, it seems odd there wouldn't be a SqlEncode.

  • blameMike (unregistered)

    What was this cat thinking? What about Replace(stringToSearch, "'", "")?

    Although, as Alex pointed out -- this function is not stripping out the quotation marks anyway.

    God only knows what the author's intent really was here.

    Oh, and what up with using the + operator for concatenation in one place, and using the & operator in another. I know they are both legal for string concatenation, but what about consistency?

  • Anonymous (unregistered)

    Part of it may be due to people not knowing the tools at their disposal. I worked with a guy once in ASP design whose background was - and I shit you not - embedded systems. So if he needed to do something, like check to see if a string was a properly formatted string (namely, a one line regex), he'd write about 50 lines of code that would end up parsing the string character by character.

    His code worked perfectly, mind you, it just wasn't the most updateable or readable, as you could likely guess.

  • [email protected] (Hassan Voyeau) (unregistered)

    The thing that bugs me the most about this code is THE ALL CAPS :(

  • Qubert (unregistered)

    ALL CAPS?? HoW aBouT thE mixTURE of SomE CAPS and SoME Not...


    Yeah I didn't take the time to really see what the code was doing till the how now' brown' cow" example...

    Sorry about your luck!!!

  • Rugglesby (unregistered)

    "THE ALL CAPS"

    He apparently didn't write in a VB/ASP aware editor or it wouldn't have left them that way. Plus the funny syntax colorizing.

    How about the 8 space indents? Ick, but not really a WTF.

    How about the "blank" comments? Why not something like:

    ' this comment intentionally left blank

    Looks like the guy was a FORTRAN or COBOL programmer who had to make his ASP code look like a "normal" language.

    How about the incomplete line?

    'Response.Write (instr(txt

    It seems he wrote in these "debugging" lines as comments, but never used them. If so, he would have seen the one in the most internal If block printing WORK as a sequence of quotes.

    If he had brought the "WORK=WORK+ACHAR" outside of the If block it would have worked, assuming of course that his intention was to double the quotes.

    "what up with the + ... and the & ..."

    Obviously & implies greater redundancy (more letters to signify the same thing) thus it is better for making redundant copies of characters in a strings.

    But why does one need to escape both single and double quotes? And with the first InStr test, if it only contains double-quotes, the input string will be returned as is.

    As is, this function should be called "UnLetter()"!

    RB

  • KoFFiE (unregistered)

    Quote:
    >I worked with a guy once in ASP design whose background was - and I shit
    >you not - embedded systems. So if he needed to do something, like check
    >to see if a string was a properly formatted string (namely, a one line
    >regex), he'd write about 50 lines of code that would end up parsing the
    >string character by character.
    >
    >His code worked perfectly, mind you, it just wasn't the most updateable
    >or readable, as you could likely guess.

    Well - my work also happens to be embedded systems, and I wrote a very basic regex for that purpose in about 50 lines of C, so 50 lines for a hardcoded check would be a lot :)

    Anyway - I'm not gonna defend this guy over-here in any way, even he probably doesn't know what it should do.

    The guys bitchin' about the caps - VB/ASP and variants perfectly allow that - welcome to the perfect world of MS...

    >Looks like the guy was a FORTRAN or COBOL programmer who had to make his
    >ASP code look like a "normal" language.
    1) Neither Cobol or Fortran could be classified under "normal" languages
    2) VB/ASP also can't be classified under a "normal" language imho.

    What really amazes me is that everytime I see VB code I see things like this. This can't be a coincidence can it? I mostly see C/C++, Java and PHP, and rarely see such horrible constructions in those languages... What is it? VB attracts stupid people? ( no offence to all smart people here using VB :p ) To be honest - I don't like VB at all, I can't understand how someone can even think of starting a big project in VB...
    I once got one in my hands that I had to debug, it had taken 2 VB developers (who were supposed to have 2 years exp.) over 6 months to write, and the end-result just didn't work, well at least it didn't do what was expected from it, took too long before the results were there - and I was put on it - with basic VB knowledge.
    After opening the VB-project I saw the most horrible project-organisation ever possible... Form1, Form2 and so on, and then Module1, Module2, ... Not even a single thing with a meaningfull name... The main organisation rule of the project seemed to be "put the function wherever there is free space", which ended up in about 40 modules with 10 times the same functions rewritten, each time in another clever, most inefficient and buggy way, put on the most illogical places (as far as possible in such an "organized" project). The whole project could be considered one big WTF. I don't know if I still have this - but I can tell you, it would be worth months of WTF submissions.
    After a week messing in that shit, a collegue and me decided it would be faster to rewrite the whole damn thing from scratch in C++ (both not fond VB) - which is also a bit more versioning/multi-developer-friendly than VB (bad experiences with VB+ Vis SourceShredder). We were very amazed that we got a basic alpha-version working in 1,5 month - and took another month to get it stable. Result: a project that had been estimated on 6 months had taken 8,5 months, 2 people fired, and my collegue and me got a raise :)

  • Matthew W. Jackson (unregistered)

    Ugh...Form1, Module1.

    Sometimes I wish GUI designers would assign random words as default names for forms and controls.

    Better yet, the designer should assign combinations of swear words. Perhaps the programmer would be so embarrased at having to type: #$^@&#$!.Show

    Then again, not all programmers would change them. I once judged a high-school programming contest where on team named all of their variable and functions with swear words. It was kind of funny at points, but part of me was hoping that their program was even 0.0001% wrong so I could tear into them. Fortunately for them, their program executed flawlessly, even with a purposely bad input file.

  • Pope Terry (unregistered)

    What does the "B" in BASIC stand for? ;-)

  • Aiax (unregistered)

    Didn't he ever notice his original string was never being returned?

  • TheF0o1 (unregistered)

    This gives me the heebie-jeebies. It looks like FORTRAN code that has been morphed into VB. And it obviously doesn't do what was intended. Ick.

  • JohnnieC (unregistered)

    Of course there are some hangers-on scraping the bottom of the barrel that use VB. A flat learning curve brings that on. But VB is definitely a tool used by serious professional quality programmers.

    Horrible constructions are found in all languages. Holy crap I’ve seen some nasty work in C/C++. The quantity is just higher in VB because of the low bar to entry, and the amount of work done in it.

  • [email protected] (Hassan Voyeau) (unregistered)

    Koffie, your reasons for knocking VB are unfounded. First of all you have more experience in C++, if you had enough experience with VB you would have been able to redo the entire app in about the same time or less. And bad experiences with one source control tool just means you need to try another tool or learn how to use the tool properly.

  • Frijoles (unregistered)

    >What really amazes me is that everytime I see VB code I see things like this.

    VBScript is very forgiving. You don't have to declare variables, case doesn't matter.. hell, you can use + or & to concatinate strings. Try doing any of that in another language and you'll get bitchslapped for it. You don't even need a compiler for an ASP page, just start plugging away and upload it to a host. As JohnnieC said, there's a low bar of entry for VB/VBScript.

  • fogelman (unregistered)

    In a Zen kind of way, this function actually does what it says.
    It takes the variable txt and devoids it of quotes. If it has no quotes it is released, otherwise, the variable WORK magnetizes all the quotes from it, and abandons txt to neverland..

    I call it poetry!

  • Will Lotto (unregistered)

    I hate to say it, but this code is one line off being 90% operational.

    What the programmer is trying to do, is duplicate any ' chars, if they exist.

    It should read is:

    if ACHAR = "'" then
    WORK = WORK & ACHAR & ACHAR
    else
    WORK = WORK & ACHAR
    end if

    still, I'd be using Replace()

  • MrGenericComment (unregistered)

    Here's the spec:

    "Please produce any old tosh and charge us for it!

    If it works that's alright, but don't worry, we can always get royalties for appearing on the dailywtf."

  • Distilled Software Hate (unregistered)

    I've seen some of the VB and VBscript the MSDN team put in their tutorials, and I have yet to see an example that didn't indicate a fundamental misunderstanding on how software works.

    So I assume that there's lots of screwed up VB* code out there because there's people who really think that the way to tell if a file has an extension is to see if the fourth-last character in the filename is a period.

  • (cs) in reply to Distilled Software Hate

    And what is it with Basic programmers who use CHR(34) instead of """"?

  • Scrub (unregistered) in reply to Will Lotto

    Anonymous:
    I hate to say it, but this code is one line off being 90% operational.

    What the programmer is *trying* to do, is duplicate any ' chars, if they exist.

    It should read is:

    if ACHAR = "'" then
    WORK = WORK & ACHAR & ACHAR
    else
    WORK = WORK & ACHAR
    end if

    still, I'd be using Replace()

     

    It would even be sufficient to move a line outside the if-statement:

    If ACHAR=Chr(34) Or ACHAR = "'" Then 
       ACHAR = ACHAR & ACHAR
    end if

    WORK = WORK & ACHAR

     

  • cbhacking (unregistered)

    For such hideous and un-readable code* it's actually only a couple of small changes from being right. Moving the WORK = WORK + ACHAR line outside the If has already been pointed out, and you'd probably want to check for the " character in the initial test too (currently it will return verbatim any string without single quotes, even if it has double-quotes).

    • Partially the fault of the language and the fact that I've learned more VBScript reading a few hours on TDWTF than in my prior 15 years of coding.
  • (cs) in reply to KoFFiE
    KoFFiE:
    1) Neither Cobol or Fortran could be classified under "normal" languages

    If by abnormal you mean, "older than the C", then I would agree with you.

Leave a comment on “UnQuote()”

Log In or post as a guest

Replying to comment #:

« Return to Article