"If <condition> Then" block makes no sense

Asked

Viewed 46 times

2

I am in charge of maintaining a Vbscript application, but my main programming languages are Java (7+), Javascript and PHP (5.4+).

During code review to refactoring the horrifying lines macaroni that I found, I came across the following line, which, I confess, I had never seen in any other code.

If 1 = 2 And IsNull(NO_ARQUIVO) And IC_ATIVO Then

I’d like help understanding what this snippet of code is doing.

What If 1 = 2 that is to say?

There is some nuance of the Vbscript language that corroborates with that line?

1 answer

1


This is the same in any language, it’s checking if 1 is equal to 2, which is obviously false and will If be false since the other conditions are linked by a And. So it was probably a way for the person not to enter this block without erasing the code, typical gambiarra.

  • What is the best way to correct this atrocity? If Not IsNull(NO_ARQUIVO) And IC_ATIVO Then is appropriate?

  • 2

    No, this would run under certain conditions, the correct solution is to erase the whole block because now it no longer runs, ever. Other than that just asking who did it for why you created this freak.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.