2

I am currently trying to figure out how to add comment within a line continuation statement on ASP classic. Our code management requirement requires us to write a Start block and End block to mark the place where we did a change. For example.

Old code

arrayName = Array("FIRST_NAME", _
                  ,"LAST_NAME" _
                  ,"ADDRESS"
                  )

New code

arrayName = Array("FIRST_NAME" _
                  ,"LAST_NAME" _
                  ,"ADDRESS" _
                  ' 2011/09/27 bob Added new column for XYZ support Start
                  ,"NEW_COLUMN" _
                  ' 2011/09/27 bob Added new column for XYZ support End
                  )

The new code is causing an error since the underbar cannot be placed within the comment. Are there anyway to place code management comment between such lines? Just want to see if I may have missed other options. I think there is none but what do you guys/gals think?

Nap
  • 8,096
  • 13
  • 74
  • 117

2 Answers2

1

Use this comment instead:

' 2011/09/27 bob Added "NEW_COLUMN" for XYZ support
arrayName = Array("FIRST_NAME" _
                  ,"LAST_NAME" _
                  ,"ADDRESS" _
                  ,"NEW_COLUMN" _
                  )

Your version control system will take care of showing the differences so there's little use for the start and end comments.

Austin Salonen
  • 49,173
  • 15
  • 109
  • 139
1

If the comment line position is very important for you, you may need to write your own array push procedure.
So, you have not missed anything. This is the cause of VBScript syntax.
With underscore, actually runs following:

Array("FIRST_NAME", "LAST_NAME", "ADDRESS", 'comment, "NEW_COLUMN", 'comment)

And this will cause an error too.

I wrote this to giving idea about push into arrays.

Sub [+](arrT, ByVal val)
    Dim iIdx : iIdx = 0
    If IsArray(arrT) Then
        iIdx = UBound(arrT) + 1
        ReDim Preserve arrT(iIdx)
    Else
        ReDim arrT(iIdx)
    End If      
    arrT(iIdx) = val
End Sub

'Start push

[+]arrayName, "FIRST_NAME"
[+]arrayName, "LAST_NAME"
[+]arrayName, "ADDRESS" 
'2011/09/27 bob Added new column for XYZ support Start
[+]arrayName, "NEW_COLUMN"
'2011/09/27 bob Added new column for XYZ support End

'Test
Response.Write Join(arrayName, "<br />")
Shadow The GPT Wizard
  • 66,030
  • 26
  • 140
  • 208
Kul-Tigin
  • 16,728
  • 1
  • 35
  • 64
  • 2
    -1 mutating what should be super simple code into this just to support some in-house commenting style requirements is mad. Using clever tricks like `[+]` is just insane. The fact that three people thought that this was a good idea is shocking. Its a good job I only get to one vote ;) – AnthonyWJones Sep 27 '11 at 19:37