How to concatenate conditions into multiple lines?

Asked

Viewed 185 times

6

I am working with a legacy system and it has some IF’s with many conditions, with the intention of improving the readability of the code tried to break these conditions in several lines..

If rs(0) = "Visualizar NF" 
  And Session("idPerfil") <> "19" 
  And Session("idPerfil") <> "10" 
Then

The above section generates the following error:

Erro de compilação do Microsoft VBScript erro '800a03f9' 

'Then' esperado 

I would like to know how in ASP 3.0 we can concatenate various conditions into decision structures or loops?

1 answer

3


The Classic ASP awaits the Then at the end of the same line to interpret the end of the condition, to concatenate the conditions into several lines we need to use the _.

Adding the underline _ at the end of each line the code will be interpreted correctly.

Example:

If rs(0) = "Visualizar NF" _
  And Session("idPerfil") <> "19" _
  And Session("idPerfil") <> "10" 
Then
  • Is that a question with a self answer? What’s the point? Medal winning?

  • Well I had this doubt researched and I thought it could be the doubt of others, I think the purpose of the stack is to share knowledge and not win medals..

  • 2

    @Ricardopunctual is perfectly acceptable (and the site even encourages) that you answer your own question, if you don’t get answers, or that the answers, even if useful, do not lead to a direct resolution of the problem. I recommend reading of this link.

  • Yes @Articuno this I know, now ask and answer at the same time is at least "strange". When I saw, the question had side made 15 minutes before and the answer too, I think not even time, but as I said, the site allows.

  • 1

    @Ricardopunctual what’s the problem? If you have a useful question that already knows the answer, why wait to answer it? Here’s an example here, I asked this question that I already knew the solution, so I posted them together. There’s no problem in that, AS LONG AS there’s really something useful to share. :)

  • No problem @Articuno, is that in this case seems more documentation than a question, since I already have the answer. I think that would be cool from the Documentation of Stackoverflow, pity that unfortunately at the moment this functionality only has in English :-(

Show 1 more comment

Browser other questions tagged

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