- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
Admin
Uh, even VB can handle this easy to understand oneliner. Hate the = for both comparison and assignment but what can you do?
ActiveSheet.Shapes("Option Button 22").Visible = (Range("a!Q7").Value=1)
TRWTF lies thoroughly with the developers for not understanding even the most basic patterns of the language.
Admin
Admin
http://en.wikipedia.org/wiki/COME_FROM
Close enough?
Other gems are the "maybe" and "please do" flow control words.
http://en.wikipedia.org/wiki/INTERCAL#Control_structures
Admin
Actually True is 0xffffffff. And is &. Or is |.
Admin
A more idiomatic VBA sub would look more like:
Note the line continuation operator _
Admin
The game of "leapfroggin' line numbers" in the code example isn't very good practice in assembly, either -- at least, if you're favoring raw performance over readability, and if you're not why are you writing assembly code anyway?
Admin
Looks like Dijkstra died in vain then...
Admin
Admin
Nice use of transposing the constant and the variable so the = sign can only compare values instead of accidentally assigning a value.
Admin
Well, VBA requires GoTos to some extent for error handling ("On Error GoTo [label]"), but that's the only place I'd ever think of using it.
As for the VB haters, while I'll happily agree that it's not my favorite language (I'd rather be working in one of the three or four other languages I know), it does have one undeniable advantage - it's baked in to Office, which makes it an easy choice when you need a smarter Excel sheet. And since the user still sees Excel, you don't get that "I don't want to learn something" pushback.
Admin
I usually prefer the "SSDD" keyword for setting up an infinite loop.
Admin
What about ALTER in COBOL? This one was a real feature of a "serious" languange...
Admin
I dislike the sound "to" for both two (2) and too (also). Yet, I can always tell them apart by parsing the grammar!
Admin
some serious WTFs could come about from ALTERs, especially when you had a 'GO TO DEPENDING ON XXX' in the program where the targets were also targets of other ALTERs.
It made for some hairy debugging.
Admin
Admin
I like the GODO, as in "GODO 300,10" It goes to line 300, executes 10 statements, then returns here. Looking at the code at lines 300 and following, there's no hint that line 311 wouldn't be executed, or that some places may "GODO 300,10" while others would "GODO 300,5". wO0t.
Admin
does the job completely without any if-statement... I am so sad that most of the so-called software developers cannot handle simple boolean expressions.
Admin
looks just like some of the old (originally fortran 66) numerical modelling system I maintain every now and then. Much fun to be had with replacing similar code with if-then-else constructs that you get in fortran 77 (and no fortran 95 isn't allowed....)
Admin
Reminds me of the days when I wrote my first program on an Apple II...
Except for the "else" part it was too advanced for basic. :)
Admin
Where I work we have to maintain a multi thousand line excel monstosity. Essentially it allows fast maintenance of records in an oracle system. It has web connections to a servlet which returns xml which is parsed dumped into sheets, then formatted and placed on other sheets for people to edit. It also does the reverse.
Some of the "cooler" features include a homemade XML parser which breaks if you pass it valid XML and full AD integration.
I once found a comment in the code base along the lines of
' Be Afraid
To which I added,
' I am. Very!
Admin
10 PRINT "WHAT" 20 PRINT "THE" 30 PRINT "FUCK?" 40 GOTO 10 RUN
Admin
"for whatever reason, [IF x GOTO n] are preferred to a simple If-Else block"
Because how would you indent the blocks without the line numbers looking messy?
Admin
"I know we're all adults here..." - I'm not sure on what evidence you based that statement. It is not at all clear from the actual discussion.
Admin
Today's WTF is somewhat subtle, but don't worry if you've missed it:
an end-user who knew too much
Enjoy your Thanksgiving holiday.
Admin
Admin
why use a switch afer all?
int x = 3; if (x==0) { // do something with 0 } if (x==1 || x==0) { // do something in common with 0 } // do something in common with 0, 1, and anything else
Admin
in reply for
Admin
BBC BASIC had ELSE (as long as it was on the same line as the IF), and its REPEAT ... UNTIL is basically a backwards WHILE loop. And it had real named subroutines (PROCs and FNs), which is more than you can say for pretty much any other 8-bit BASIC.
I expect a full retraction, or I shall be forced to demand satisfaction.
Admin
Ok! Lt's continue anti VB hollywar! It's so professional and funny!
Admin
Once upon a time in Microsoft BASIC (definitely for QuickBasic, not sure about pre-.NET VB), if your compiled program crashed, it would display the last line NUMBER that had been encountered by the runtime. Line labels didn't work.
As such, if you found a piece of code where every line was numbered, rather than feeling some nostalgia for the days of the VIC-20, you would shiver in fear. It meant that a programmer had been trying to debug an intermittent crash that only occurred in the compiled executable.
Admin
Maybe someone's already said this above, but this is actually a decent alternative to convoluted Case-Switch statements I have had to use in VBA. Cleaner and you don't have to worry about how the statements might fall through. Goes to show that you can learn something from everything.
Admin
Block? What is this "block" you mention?
Admin
Admin
That's clever. Wrong, but clever. The cleverness kind of hides the wrongness, doesn't it?
Although actually, if we want to go for wrong, we could save even more typing, and achieve less cleverness and better clarity:
Admin
Yep, C64 and with its build in BASIC - well remembered. All line numbers plus GOTO and GOSUB - no control structures, not even an ELSE. And then there were these dreaded constructs: ON X GOTO 100, 200, 300 .... or even "better" ON X GOOSUB 100, 200, 300 .... Jumping in and out of sub-routines? Yes no problem, no problem at all. :)
Along came the ATARI ST and the all new GFA-BASIC. Remember anyone? What a joy! GFA did away with line numbers all together. They added PASCAL like control stuctures and propper PROCEDUREs with declared parameters and return values. Was there a GOTO or a GOSUB? I don't remember, I never missed any of them - never. Not in any language I have encountered since.
Admin
Actually, no it doesn't. You use 'On Error Resume Next' instead, and test for the error inline.
Not quite Try..Catch but it sure beats those stupid GoTo error blocks.
Admin
You can implement your own CAMEFROM like this:
Admin
Oh, the scope for abuse was virtually limitless:
10 ...dostuff... 20 gosub 100 30 ...bla
100 ...more...
110 if a = 42 goto 10
120 return
or:
10 for i=1 to 10 20 .. somt code 30 if a = 42 goto 100 40 next i .... 100 ... more nonsense 150 if x = 0 goto 20 ... (oh joy!)
So the million dollar questions are: How long will it take before the stack overflows? When it happens, how to find the root cause and how to fix it? How can one be sure to spot something like that during "testing" - apart from running the program an infinite period of time?
Hint: Lack of scope, lack of context.
Admin
A real programmer can write FORTRAN in any language ...
Admin
TRWTF is C#
Admin
IIRC, BBC BASIC was a grown-up version which was evolving away from line numbers. There were techniques for writing it line-less. It also had better-structured IF and FOR.
Bear in mind that all these constructs evolved ultimately from the Old Fortran (4?) construct "IF (condition) label1, label2, label3" where the labels were where the flow went to if condition was less than, equal to, greater than (in some combination, can't remember the details) the result of the condition.
So I can easily understand where the code construct came from - someone had taught him/herself against an archaic programming manual from the days before these new-fangled structures had been invented.
Also bear in mind that languages have evolved rapidly enough that someone whose career started way before the currently accepted structures were invented may not have had the time or opportunity to keep up with the industry. Kudos for anyone not a professional programmer for getting anything to work - may they be applauded.
That being said, it ought to go without saying that when a professional programmer encounters such code, it is mandatory to replace such constructs as instanced in today's WTF with something a little more "contemporary". It's part of your maintenance remit. Go on, get on with it, stop whingeing about it. If you don't like what you've been requested to do, that's what Monster's for.
Admin
If you're trying to emulate try..catch in VB then "On Error Goto <label>" is much closer than "On Error Resume Next"!
I hope your boss doesn't see what you wrote!
Admin
Which version?
(I started on BASIC II on an Acorn Electron)
I'm pretty sure line numbers were required, but am ready to be corrected - it is a VERY long time ago!
Admin
Nothing much changed from BBC BASIC 1 to 2:
http://en.wikipedia.org/wiki/BBC_BASIC
(I happen to start on the much earlier Acorn Basic, which was somewhat more primitive)
There's a whole website dedicated to BBC BASIC:
http://www.bbcbasic.co.uk/bbcbasic.html
Line numbers were part of the editor and thus automatically inserted, but you didn't have to rely on them.
Admin
In case you can’t tell, BBC BASIC already was a grown-up language. The fact that you insist on supporting line numbers in your VBA clearly shows that you’re too young and too stupid to be offering software.
Go away and grow up.
Sincerely, Bert Glanstron
Admin
Interestingly, nobody's complained about "Option Button 22" yet. Let me be frist. Would it not make sense for it to be renamed to something more descriptive? IMO this is more of a concern than the use of GOTOs, which are easily (in theory) replaced with something more compact and maintainable.
CAPTCHA: quibus: question about public transport.
Admin
Data? Rewind tape? (remember rewinding and adjusting the volume?!)
Admin
Actually my first programs were written on a TI59 around 1978 and a bit later some version of BASIC (on a technical school via acoustic modem).
But yeah, I remember all that tape stuff. Actually my old BBC model B is still working but packed away somewhere. Thought about getting rid of it last year, but didn't do it (probably for nostalgic reasons). No tapes, but I still have some 5 1/4" disks somewhere...
Admin