Kinook Software Forums

Kinook Software Forums (
-   [VBP] General Discussion (
-   -   Problem with LASTSTEP_OUTPUT and xml output (

mballou 05-15-2006 09:43 PM

Problem with LASTSTEP_OUTPUT and xml output
I'm using Vault 6.1 with the history command in my build script. Vault outputs the results in xml format which is perfect for my needs.

I'm writing a vbscript in Visual Build as the Stepdone event of the vault step, but it doesn't parse the xml correctly. I think I tracked the problem down to visual Build changing the xml text in the LASTSTEP_OUTPUT macro.

I use this line to get the text:
xmlText = vbld_AllMacros().Item("LASTSTEP_OUTPUT")

Instead of lines like this:

I get a line like this from the macro:

If you look closely, you will see that the double-quotes of the original output have been converted to single quotes. That by itself is still valid xml and can be loaded. My problem is that the output also contains single quotes which is not valid. the word "Can't" becomes invalid.

Is there some option that will let me get the real output of the command that hasn't been converted by Visual Build macro?

Mike Ballou

kinook 05-16-2006 02:07 PM

VBP converts double quotes in step output macros to single quotes so that if these macros are referenced in a script expression like "%LASTSTEP_OUTPUT%", double quotes within the value will not cause problems. But this can lead to the situation you're describing if the output actually contains XML attribute values with single quotes. We'll add an option in the next release to disable conversion of double to single quotes in the output macros. For now, you can work around it by converting back to double quotes in the script event before using:


' convert single quotes surrounding XML attribute values possibly
' containing single quotes back to double quotes
output = Application.ExpandMacrosAndScript("%LASTSTEP_OUTPUT%")
Set re = New RegExp
re.Pattern = "(\s*=\s*)'(([^']|'[^\s])*)'(\s)"
re.Global = True       
output = re.Replace(output, "$1""$2""$4")
' do stuff with output

mballou 05-16-2006 06:48 PM


Thank you for the quick response. I look forward to the next version.
I tried your work around for converting the single quotes back to double quotes and it also works great.

Mike Ballou

rmaines 08-02-2006 11:42 AM

We are also experiencing the same problem. The workaround works great for any comments containing a single quote followed by an s at the end of a word, but we've already had several comments containing single quotes in other parts of the comment field, ex: comment="Comment 'containing' single quotes"

We are building continuously, so if a comment contains a single quote, no changes are found because the xml does not load. Is there a timeframe when a new version will be available?

kinook 08-02-2006 02:06 PM

The v6.2 beta (released today) has this capability. More details on the beta are here:

rmaines 08-02-2006 07:01 PM

I installed the beta and it fixed our problem. However, it introduces a new one....

The problem introduced is that in a step done event, I have a Builder.LogMessage statement, but the statement is not finding it's way into the log file.

When I uninstall the beta and reinstall 6.1, it's working fine, but I still have the single quote issue. Any ideas? let me know and i can send you the build project if needed.

kinook 08-02-2006 10:52 PM

Another change (actually a bug fix) in this build is to not fire the vbld_StepStarted/vbld_StepDone events for a step that is skipped. Is that coming into play here?

rmaines 08-03-2006 10:40 AM

Nope, this step is getting executed and the logic w/in the event is being processed, but the Builder.LogMessage output is no longer getting logged

kinook 08-03-2006 02:33 PM

Can you ZIP and post or send a .bld file that demonstrates the problem, and the info from Help | About | Install Info? Thanks.

rmaines 08-07-2006 11:57 AM

1 Attachment(s)
Attached are the bld files. Basically, the MediLinksCIC.bld fires the ChainMaster.bld. The ChainMaster fires a bunch that do basically the same thing. We can focus in on the MediLinks.bld one to keep it simple. This one is an example of the Builder.LogMessage not getting fired. You probably won't need the first 2 .bld's, but just so you can see our process in its entirety.

kinook 08-07-2006 02:24 PM

I can't find a Builder.LogMessage call in any vbld_StepDone event in the attached files. Please pare things down to a reproducible sample we can build here. Thanks.

rmaines 08-07-2006 02:28 PM

So sorry, i should have pointed out that the StepDone calls a Global Function which contains the Builder.LogMessage, which you probably don't get by me sending you the .bld files.

In the Build Solution step of MediLinks.bld, there is a call to CreateReportLink (the global function). It is in this function that the message does not get logged. Below is the global function note that it is also calling a URLEncode function which i've also provided below):

Sub CreateReportLink(LinkHeader, ReportDir, FileName)

Dim strHTML
Dim file

Builder.LogMessage LinkHeader

strHTML = ""
strHTML = strHTML & ""
strHTML = strHTML & "" & FileName & ""
strHTML = strHTML & ""
strHTML = strHTML & ""


End Sub

Public Function URLEncode(sRawURL)
Const sValidChars = "1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmn opqrstuvwxyz:/.?=_-$(){}~&\"

If Len(sRawURL) > 0 Then
' Loop through each char
For iLoop = 1 To Len(sRawURL)
sTmp = Mid(sRawURL, iLoop, 1)

If InStr(1, sValidChars, sTmp, vbBinaryCompare) = 0 Then
' If not ValidChar, convert to HEX and prefix with %
sTmp = Hex(Asc(sTmp))

If sTmp = "20" Then
sTmp = "+"
ElseIf Len(sTmp) = 1 Then
sTmp = "%0" & sTmp
sTmp = "%" & sTmp
End If
End If
sRtn = sRtn & sTmp
URLEncode = sRtn
End If
End Function

kinook 08-07-2006 03:55 PM

LogMessage calls from script event code for a step with logging disabled were incorrectly suppressed. This is fixed in the latest beta download.

rmaines 08-07-2006 04:33 PM

Thank you very much. I don't see a new download though, just the same one (6.2). Will this be available soon?

kinook 08-07-2006 04:42 PM

It is, just download it again (it's still the v6.2 beta, only better). VisBuildBld.dll version (Help | About | Install Info) will be after installing.

All times are GMT -5. The time now is 06:53 PM.

Copyright 1999-2019 Kinook Software, Inc.