Inventive use of Select Case



  • Some representative vbscript code from this little app i have to maintain.

    Every report in there starts like this and in none of them ever is given a value to the action variable

    	Session.LCID = 1043
    
    	Dim intRol
    	Dim intAction
    	
    	intRol		= Session("intRol")
    	intAction	= Request.QueryString("action")
    		
    	Select Case intAction
    	
    		' ???
    		Case 1:
    		
    		' ???
    		Case 2:
    							
    		' Toon pagina
    		Case Else:
    			Call ShowPage()
    
    	End Select
    


  • Possibly the remains of some refactoring. On the side note, my bet is that the language is dutch.



  • @DrJokepu said:

    Possibly the remains of some refactoring.

    Part of that would be 'removing dead code', and replacing '???' comments with something useful.

    @DrJokepu said:

    my bet is that the language is dutch

    It is, translates to "Show Page".



    Dim intRol

    Dim intAction



    Are those integers? Since when does VBScript understand Hungarian Notation? Isn't this a variant, until declared otherwise?



  • @eddyvluggen said:

    Are those integers? Since when does VBScript understand Hungarian Notation? Isn't this a variant, until declared otherwise?

    Yes, but a variant can *contain* an integer. Naming it like that shows that you expect it to be used for integers (without actually requiring it, which is indeed A Bad Thing™).

    Of course, TRWTF is Systems Hungarian, more so in a langauge with a strict type system.



  • Strings can contain integers too :)

    Looks like a Dutch VB-programmer. Probably academic code.



  • @eddyvluggen said:

    Isn't this a variant, until declared otherwise?

    AFAIK, VBScript doesn't let you to give explicit types to variables.



  • @Spectre said:

    AFAIK, VBScript doesn't let you to give explicit types to variables

    You're right! Everything is a variant, just like JavaScript..

    WTF?!?



  • @eddyvluggen said:

    @Spectre said:

    AFAIK, VBScript doesn't let you to give explicit types to variables

    You're right! Everything is a variant, just like JavaScript..

    WTF?!?

     

    On the rare occasions I've had todo VBscript I've found myself doing the same thing - I'm a Hungarian Notation user and just carry on naming my variables the same way in javascript and VBscript.

     No, it doesn't make a blind bit of difference to the actual type of the var: but why waste time correcting yourself every time habit kicks in and you give the var a typed name, when you could just get on with writing the actual code?

    So, was there a WTF other than the fact that, tee hee, the vars had typed names, guffaw, even though the language doesn't supported typed vars?



  • @eddyvluggen said:

    WTF?!?
     

    Why the WTF?



  • @sfmans said:

    So, was there a WTF other than the fact that, tee hee, the vars had typed names, guffaw, even though the language doesn't supported typed vars?

     

     

    Isn't it the fact that the select case does nothing and has comments that say nothing? 



  • @sfmans said:

    @eddyvluggen said:

    @Spectre said:

    AFAIK, VBScript doesn't let you to give explicit types to variables

    You're right! Everything is a variant, just like JavaScript..

    WTF?!?

     

    On the rare occasions I've had todo VBscript I've found myself doing the same thing - I'm a Hungarian Notation user and just carry on naming my variables the same way in javascript and VBscript.

     No, it doesn't make a blind bit of difference to the actual type of the var: but why waste time correcting yourself every time habit kicks in and you give the var a typed name, when you could just get on with writing the actual code?

    So, was there a WTF other than the fact that, tee hee, the vars had typed names, guffaw, even though the language doesn't supported typed vars?

    Indicating the expected usage of a variable is never a bad idea.  I do the same thing in Javascript simply to make sure maintainers know that, for example, during form validation some things are expected to be numbers and others are expected to be strings.

    So, yeah, I think I'm going along with the odd Select Case usage as the real WTH.  Yeah, it doesn't even rate an 'F.'



  • @coentje said:

    ... in none of them ever is given a value to the action variable

    ...
    	intAction	= Request.QueryString("action")
    ...

    And what is this?

    So if you call the page with '?action=1' or '?action=2', the vbscript should not run. Maybe it's somebody's WTFy idea of a debug tool.


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.