• (cs)

    Actually in the UK it's Happy Spring Bank Holiday!

    Captcha: First! (not)

  • my name (unregistered)

    shesh, slow day!

    captcha - doom

  • sig (unregistered)

    At least it's kind enough to beep when it's done :)

  • Nick (unregistered)

    So......many......Variants......

  • Look at me! I'm on the internets (unregistered)

    Poor Amy.

  • gygax (unregistered)

    Something inside me just hurts when I look at it.

  • Yarr (unregistered)

    Oh god, what happens if Amy leaves the company?

  • Shinobu (unregistered)

    "TO BE SPECIFEID" - the real WTF is that he can't spell. If Amy leaves the company, they'll just search-and-replace her name for her replacement. Ah... business logic.

  • (cs)

    CHeck with the Vatican: It's Whit Monday

  • Stiggy (unregistered)

    The real WTF has gotta that no-one's yet ripped into the use of VB(A) again, for a change.

    A good programmer can code well in any langauge, just as surely as a bad one can write c&^p like this...

  • Alexander Dzhoganov (unregistered)

    The interesting side is that this is probably part of some in-house programming language they built for parsing documents. Think of the mind-boggling HORROR! I fear this system :/

    Captcha: (a) pointer (misuse is better than this)

  • Brad (unregistered)

    I really want to know what this was used for...

    Captcha: craaazy...yeah, no kidding

  • (cs)

    Yet another failed attempt at job security...

  • fcardenas (unregistered)

    This function is used only from Monday to Thursday. On Fridays the system calls another similar funcion with the text "Pass to Amy next Monday"

  • bumblebeeman (unregistered)

    No way. I'm flabbergasted that someone would put that into production. I wonder if they feel bad about what they've done?

  • Vincent (unregistered)

    How about happy pentecost?

  • gotem (unregistered) in reply to Otterdam
    Otterdam:
    Yet another failed attempt at job security...

    Hey, this secures the job of both the programmer and Amy

  • DW (unregistered)

    I sure hope he wrote unit tests

  • bobbo (unregistered)

    Can somebody tell me how I set Firefox's Adblock extension to block lines of comment text which start with 'Captcha' please?

  • Failure Than Worse (unregistered) in reply to bobbo

    Anyone want to rewrite this in a C-style pseudocode for those of us who don't speak this language?

  • Eugene (unregistered)

    How do you know Amy isn't the programmer?

  • T$ (unregistered) in reply to Failure Than Worse
    Failure Than Worse:
    Anyone want to rewrite this in a C-style pseudocode for those of us who don't speak this language?

    It's really not that bad: Select Case works like a switch statement. The Excel.Worksheet.RoundUp is using Microsoft Excel for some reason. If statements are the same. calculatethenumbers = "whatever" is equivalent to return "whatever" And beep as you may have guessed is a reserved word in VBA that beeps.

    That series of if statements confuses me though, I didn't know you could have if without an end if for one line statements, good to know.

  • (cs)

    Cool. Truly classic, and truly a WTF?!!

  • Strilanc (unregistered)

    No variable naming, no function naming, no typing (the function's return type changes!!), hard coding customer names... looks like a classic case of function-does-too-much

    I really, really hope this isn't used deep down in the system.

  • Thomas (unregistered)

    Oh, crap. Now, this is a nice one....

  • Anonymous Coward (unregistered) in reply to bobbo
    bobbo:
    Can somebody tell me how I set Firefox's Adblock extension to block lines of comment text which start with 'Captcha' please?

    You can do that with Greasemonkey.

    ...

    CAPTCHA: onomatopoeia

  • Shinobu (unregistered) in reply to T$
    T$:
    I didn't know you could have if without an end if for one line statements, good to know.
    Otherwise you wouldn't be able to write things like
    If A Then If B Then DoA Else DoB Else If B Then DoC Else DoD
    on one line.
  • Joel (unregistered)

    It's a great day for us Canadians too. We had last Monday off, and this Monday we have no customers calling.

  • Mario (unregistered)

    Well, it's the 7th monday after easter: http://en.wikipedia.org/wiki/Public_holidays_in_Belgium.

    Of note is that the official founding of the Christian church was yesterday.

  • MK (unregistered) in reply to T$
    T$:
    calculatethenumbers = "whatever" is equivalent to return "whatever"
    No, not unless Microsoft has changed the semantics of the language recently. Assigning to the function name sets the return value of the function, but the function does not actually exit until it reaches the end OR an "Exit Function" statement.

    In Delphi there's the "Result" implied variable for any function that does the same thing, it's just more obvious especially in recursive functions.

    Result := Result + ThisFunction(Number - 1);

    is a lot more obvious than the VB equivalent:

    ThisFunction = ThisFunction + ThisFunction(Number - 1)

    And even more so for functions that take no input parameters (which I'd almost say are a WTF all on their own, but do have their uses sometimes). In both languages, if you want to actually return that value right then, you have to say so explicitly.

  • MK (unregistered) in reply to T$
    T$:
    calculatethenumbers = "whatever" is equivalent to return "whatever"
    No, not unless Microsoft has changed the semantics of the language recently. Assigning to the function name sets the return value of the function, but the function does not actually exit until it reaches the end OR an "Exit Function" statement.

    In Delphi there's the "Result" implied variable for any function that does the same thing, it's just more obvious especially in recursive functions.

    Result := Result + ThisFunction(Number - 1);

    is a lot more obvious than the VB equivalent:

    ThisFunction = ThisFunction + ThisFunction(Number - 1)

    And even more so for functions that take no input parameters (which I'd almost say are a WTF all on their own, but do have their uses sometimes). In both languages, if you want to actually return that value right then, you have to say so explicitly.

  • (cs) in reply to bobbo
    bobbo:
    Can somebody tell me how I set Firefox's Adblock extension to block lines of comment text which start with 'Captcha' please?

    Bobbo -- if you missed this, please see http://userscripts.org/scripts/show/7631 (something sjs posted to another thread). Works a charm, and uses the Greasemonkey extension. Bow before sjs (if it's his work)

  • Watson (unregistered) in reply to Shinobu
    Shinobu:
    T$:
    I didn't know you could have if without an end if for one line statements, good to know.
    Otherwise you wouldn't be able to write things like
    If A Then If B Then DoA Else DoB Else If B Then DoC Else DoD
    on one line.
    DoB DoB Do
  • Dark (unregistered) in reply to Yarr

    Silly Yarr. Amy isn't a person. Amy is the name of another function!

  • BillyBob (unregistered) in reply to Shinobu
    Shinobu:
    "TO BE SPECIFEID" - the real WTF is that he can't spell. If Amy leaves the company, they'll just search-and-replace her name for her replacement. Ah... business logic.

    Out of all that, you decided the spelling was the biggest issue?

  • csrster (unregistered)

    I am sure this Whitsuntide wtf is evidence that the Holy Spirit has come among us. Such coding is surely beyond the capabilities of one not inspired by Divine Grace.

  • (cs)

    My best guess is that x and y are Excel spreadsheet coordinates and that depending on what field we're in, it'll return some output... v, w and z probably some values from the same spreadsheet (w looks like a dropdown to me).

    I think it's called from inside a loop where it's running thru all the fields (all the possible x and y values). If I were Amy I'd change that "Pass to Amy tomorrow" phrase to "Pass to Amy when hell freezes over"....

  • Dube (unregistered)

    What i really like is the "beep" at the end! I hope this function is called multiple times to drive the user into madness

  • ajw (unregistered)

    This probably isn't as bad as it looks. My guess is that calculatethenumbers() gets called for each cell of an Excel spreadsheet, and does different things based on the coordinates.

    It's probably a way of taking a really convoluted legacy spreadsheet that Marie in Accounts has produced in exactly the same way since 1992 and refuses to change, and turning it into something usable. A custom function used in exactly one place for exactly one purpose.

  • dkf (unregistered) in reply to ajw
    ajw:
    It's probably a way of taking a really convoluted legacy spreadsheet that Marie in Accounts has produced in exactly the same way since 1992 and refuses to change, and turning it into something usable. A custom function used in exactly one place for exactly one purpose.
    My guess is that it started that way, but has now transmogrified itself into a hairy monster that rules the company, simply because nobody anywhere dares touch it.
  • sanitarium (unregistered) in reply to Daniel Beardsmore
    Daniel Beardsmore:
    bobbo:
    Can somebody tell me how I set Firefox's Adblock extension to block lines of comment text which start with 'Captcha' please?

    Bobbo -- if you missed this, please see http://userscripts.org/scripts/show/7631 (something sjs posted to another thread). Works a charm, and uses the Greasemonkey extension. Bow before sjs (if it's his work)

    Cool, ta

  • M L (unregistered)
    Ray Suker sends in a function from a system he inherited from the Guru who designed it before him. Ray mentions that this is in fact the best named function in the entire system.
    I like how the text referred to this obvious VBA script in an Excel spreadsheet as "the system", as if it were a core application running on a mainframe. I guess it just doesn't sound like much of WTF if Alex had written "Ray Suker sends in a function from an Excel spreadsheet he inherited from some guy in accounting."
  • (cs) in reply to Failure Than Worse
    Failure Than Worse:
    Anyone want to rewrite this in a C-style pseudocode for those of us who don't speak this language?

    Here goes:

    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    char *
    calculatethenumbers(int v, const char *w, int x, int y, int z)
    {
        static char buf[64];
        if (strcmp(w, "x1") == 0 || strcmp(w, "x2") == 0 || strcmp(w, "zz") == 0 || v == 0) {
            if (x == 8 || x == 60 || x == 16 ||  x == 13 ||  x == 23 ||  x == 38) sprintf(buf, "%f", ceil(z / 15000) * 2);
            if (x == 40 && y == 0) sprintf(buf, "%f", ceil(z / 15000) * 3);
            if (x == 75 && y == 24) sprintf(buf, "%f", ceil(z / 15000) * 4);
            if (x == 71) {
                if (y == 6) strcpy(buf, "not done");
                if (y == 9) strcpy(buf, "to be done");
                if (y == 8) strcpy(buf, "query");
                if (y == 4) sprintf(buf, "result %d", x);
                if (y == 10) strcpy(buf, "Pass to Amy tomorrow");
            }
            if (x == 70 && y == 1) {
                if (z < 501) strcpy(buf, "1.5");
                if (z > 500) strcpy(buf, "3");
            }
            if (x == 61) strcpy(buf, "CUSTOMER_1");
            if (x == 68) strcpy(buf, "CUSTOMER_2");
            if (x < 1) strcpy(buf, "Pass to Amy tomorrow");
            if (x == 6) strcpy(buf, "CUSTOMER_3");
            if (x == 30 || x == 7) sprintf(buf, "%f", ceil(z / 15000) * 14);
            if (x == 1 && y == 0) sprintf(buf, "%f", ceil(z / 15000) * 9);
            if (x == 1 && y == 9) strcpy(buf, "72");
            if (x == 1 && y == 3) sprintf(buf, "%f", ceil(z / 15000) * 14);
            if (x == 40 && y == 12) sprintf(buf, "%f", ceil(z / 15000) * 3);
            if (x == 24 && z < 150001) sprintf(buf, "%f", ceil(z / 15000) * 14);
            if (x == 24 && z > 150000) strcpy(buf, "Pass to Amy tomorrow");
            if (x == 0) strcpy(buf, "TO BE SPECIFEID");
        }
        if (v > 0) {
            if (strcmp(w, "3") == 0 || strcmp(w, "INTERNAL") == 0 || strcmp(w, "EXTERNAL") == 0 || strcmp(w, "OTHER") == 0 || strcmp(w, "MISC") == 0 || strcmp(w, "") == 0) {
                /* Nope, you've got me here ... */
            }
        }
        if (strcmp(w, "a1") == 0) strcpy(buf, "Reviews! Get paperwork!!");
        system("beep");
        return buf;
    }
    

    I think that preserves the insanity of the VB code, although I don't understand what that switch like statement does.

  • (cs) in reply to M L
    M L:
    Ray Suker sends in a function from a system he inherited from the Guru who designed it before him. Ray mentions that this is in fact the best named function in the entire system.
    I like how the text referred to this obvious VBA script in an Excel spreadsheet as "the system", as if it were a core application running on a mainframe. I guess it just doesn't sound like much of WTF if Alex had written "Ray Suker sends in a function from an Excel spreadsheet he inherited from some guy in accounting."

    You'd be surprised to learn how many critical applications in the finance sector are actually appalling hacks written in VBA. It seems every bank tries to avoid writing standalone applications by getting a semi-IT person to knock up something with Excel or Access. In fact, that's what the highly paid consultant sitting opposite me does. With a copy of "Excel VBA For Dummies" on his desk I might add.

  • don't forget those who died (unregistered)

    'Happy' Memorial Day?

  • Harrow (unregistered) in reply to Yarr
    Yarr:
    Oh god, what happens if Amy leaves the company?
    Amy probably has long since departed the company been successively replaced several times. The operator of this program is responsible for knowing the identity of the current "logical Amy".

    -Harrow.

  • (cs)

    Are you sure you didn't take that code from one of the OMG WTF entries?

  • iToad (unregistered) in reply to java.lang.Chris;
    java.lang.Chris;:
    Failure Than Worse:
    Anyone want to rewrite this in a C-style pseudocode for those of us who don't speak this language?

    Here goes:

    #include <math.h>
    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    char *
    calculatethenumbers(int v, const char *w, int x, int y, int z)
    
    snip...
    
    }
    

    I think that preserves the insanity of the VB code, although I don't understand what that switch like statement does.

    This example demonstrates that it is possible to write bad VBA code in any language.

  • Shinobu (unregistered) in reply to Harrow
    Harrow:
    the current "logical Amy".
    Brilliant! You made my day.
  • James Steiner (unregistered) in reply to java.lang.Chris;
    java.lang.Chris;:
    Failure Than Worse:
    Anyone want to rewrite this in a C-style pseudocode for those of us who don't speak this language?

    [snip the awesome code]

    I think that preserves the insanity of the VB code, although I don't understand what that switch like statement does.

    As has been suggested, this code is an Excel macro, in VBA.

    As you guessed, "Select Case" is like a switch block. The Range function reports the value of the given spreadsheet cell. So, there you go.

    This function probably is called by one cell at the end of the row in in each row of a selection of rows. The variables are from cells from that row (some specific columns, of course), and it takes the bizzare pattern of input in those cells, and produces a column of values that (once the rows are sorted) might very well speed up or make easier the work of some poor clerical worker (a subord of Amy, no doubt).

    Its very likely that the source input is some "MUST NEVER BE CHANGED" mainframe database report, cut-and-pasted via 3270 emulator text screen-captures into a text file (possibly by a macro written in the 3270 emulator package's own macro language), then manually imported into Excel, then munged further with this macro.

    You probably can't believe that before caculatethenumbers, their jobs were even harder. I can. I've been there, done that, and made some pretty bizzare, but utterly useful and utterly specific-purpose spreadsheets to help the poor bastards out.

    You see, (customer facing) production is one thing. That's where the money is, all the spit and polish and unit testing. But then there's what some poor clerical worker in the basement has to do. Nobody cares about the clericals, or how to make their jobs easier with the fancy tools they have. They all have Excel, but none of them really knows how to use it. So, some sympathetic IT support fellow spends a few hours whipping up some monstrosity macro/template to try to ease their burden. It probabaly knocks 3 hours off the job every day. Then, they in the basement happily use that bizzare, single-purpose tool for the next 7 years, and hail the IT guy as a genius for ever after. ( At least, until the forced upgrade to the next version of Excel that breaks the macro, and the IT guy hasn't touched Excel macros in 7 years deserts them, and they go back to the old, hard, slow way, that nobody remembers how to do)

    Poor, piteous things.

Leave a comment on “Classic WTF: calculatethenumbers(v,w,x,y,z)”

Log In or post as a guest

Replying to comment #:

« Return to Article