eScript Property Set Printing Tool

During script debugging, for example, when developing a Virtual Business Component, it is useful to be able to print out the contents of a property set. This Technical Note lists eScript code that can be added to a business service to print out the contents of a property set.

When debugging script code, it is useful to write out values to a file, or to examine them in the debugger watch window. The eScript code in this Technical Note will handle multiple level property sets. It is not limited to one or two layers of child property sets; rather, it is recursive and handles any depth of child property sets.
 
The listing also shows the child depth so you can see at a glance how deep in the hierarchy you are. The indent amount is configurable, so for property sets with several children you can choose a smaller indent.
 
The script provided in this Technical Note writes out to a text file, but all the printed output is written through the LogMe() routine so it is easy to redirect it if required.

To add the code to a Business Service, follow these steps:
 
1.Paste the code listed in the eScript Code section below  into the General Declarations section of the business service. Start with the functions and save after each one, so they become new functions below the General Declarations section.
 
2.After the new functions appear, there will be a few lines of script code remaining in the General Declarations Section. You can make the following optional changes:
 
a.Modify the output filename assigned to OutPutFileName if you wish to write to a different file. Remember that in eScript a backslash must be escaped, so a path name like C:\TEMP\LOGS\output.txt becomes C:\\TEMP\\LOGS\\output.txt.
 
b.Change the indent level. It is two spaces by default.
 
3.Now when you want to print out the values in a property set, simply call it like this:
 
DumpPropSet(MyPropertySet);


eScript Code
 

// Add to General Declarations section
 
// Change this to the file and pathname you want the report to appear in.
var OutPutFileName = 'C:\\PropertySet_Dump.txt';
 
var IndentAmount = 2; // Indent child prop sets listing this many spaces
                     // to the right for each level down.
var PSDepth = 0; // How deep in the property set tree, what level
 
 
// Add to General Declarations section
 
function LogMe(LogThis)
{
  // Writes a line out to a text file. All printed output is routed
  // through this routine, so add HTML or popup writes here to redirect
  // the printed output.
 
  var MyFile = Clib.fopen(OutPutFileName, 'at');
  var sTime = Clib.ctime(Clib.time());
  sTime = sTime.replace('\n',' '); // Remove trailing Newline.
  Clib.fputs(sTime + ': ' + LogThis + '\n', MyFile);
  Clib.fclose(MyFile);
}
 
function DumpPropSet(Inputs)
{
// Print out the contents of a property set.
 
PSDepth++; // We have just dived down a level
 
var InpValue;
var InpType;
var InpChildCount;
var inprop;
var inpropval;
var inpropcnt;
var BlankLine = ' ';
 
// Build a string to indent the Listing.
 
var IndentSpaces = ''; // Number of spaces to indent to
for (var SpaceCount = 0; SpaceCount < IndentAmount * PSDepth; SpaceCount++)
  {
  IndentSpaces = IndentSpaces + ' ';
  }
var IndentLevel = ToString(PSDepth);
if (PSDepth < 10)
  {IndentLevel = '0' + IndentLevel;}
 
// Indent by a number of indents, then level number as nn, then two spaces
var Indent = IndentSpaces + IndentLevel + '  ';
 
 
LogMe(BlankLine);
LogMe(BlankLine);
LogMe(Indent + '---- Starting a new property set ----');
LogMe(BlankLine);
 
 
// Now do main value and type
 
InpValue = Inputs.GetValue();
InpType  = Inputs.GetType();
 
InpChildCount = Inputs.GetChildCount();
LogMe(Indent + 'Value is ........ : "' + InpValue + '"');
LogMe(Indent + 'Type is  ........ : "' + InpType + '"');
LogMe(Indent + 'Child count ..... : ' + ToString(InpChildCount));
 
// Dump the properties of this property set
 
var PropCounter = 0;
inprop = Inputs.GetFirstProperty();
while (inprop != "")
  {
  PropCounter++;
  inpropval = Inputs.GetProperty(inprop);
 
  LogMe(BlankLine);
  var PropCountStr = ToString(PropCounter);
  if (PropCounter < 10)
    { PropCountStr = '0' + PropCountStr; }
    
  LogMe(Indent + 'Property ' + PropCountStr + '  name : "' + inprop + '"');
  LogMe(Indent + 'Property ' + PropCountStr + ' value : "' + inpropval + '"');
 
  inprop = Inputs.GetNextProperty();
  }
 
// Dump the children of this PropertySet
 
if (InpChildCount == 0)
  {
  LogMe(BlankLine);
  LogMe(Indent + '(No children exist below this property set.)');
  }
else  
  {
  for (var ChildNumber = 0; ChildNumber < InpChildCount; ChildNumber++)
    {
    LogMe(BlankLine);
    LogMe(Indent + 'Child Property Set ' + ToNumber(ChildNumber + 1) + ' of ' + ToNumber(InpChildCount) + ' follows below.');
    LogMe(Indent + 'This child is on level ' + ToNumber(PSDepth));
 
    // Recursive call for children, grandchildren, etc.
    DumpPropSet(Inputs.GetChild(ChildNumber));
    }
  }
 
PSDepth--; // We are about to pop up a level
}
 
Sample Output
 

Here is sample output from the property set printing tool.
 
Wed Jun 16 16:36:47 2004 :   01  ---- Starting a new property set ----
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Value is ........ : ""
Wed Jun 16 16:36:47 2004 :   01  Type is  ........ : ""
Wed Jun 16 16:36:47 2004 :   01  Child count ..... : 2
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Property 01  name : "search-string"
Wed Jun 16 16:36:47 2004 :   01  Property 01 value : "([Date] = "06/18/2004" AND [Description] ~LIKE "A test description*" AND [House_ID] ~LIKE "779*")"
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Property 02  name : "Business Component Name"
Wed Jun 16 16:36:47 2004 :   01  Property 02 value : "Alvin VBC Business Component"
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Property 03  name : "Business Component Id"
Wed Jun 16 16:36:47 2004 :   01  Property 03 value : "4"
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Property 04  name : "Parameters"
Wed Jun 16 16:36:47 2004 :   01  Property 04 value : "C:\temp\nrec.cfg"
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Child Property Set 1 of 2 follows below.
Wed Jun 16 16:36:47 2004 :   01  This child is on level 1
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :     02  ---- Starting a new property set ----
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :     02  Value is ........ : ""
Wed Jun 16 16:36:47 2004 :     02  Type is  ........ : ""
Wed Jun 16 16:36:47 2004 :     02  Child count ..... : 0
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :     02  (No children exist below this property set.)
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :   01  Child Property Set 2 of 2 follows below.
Wed Jun 16 16:36:47 2004 :   01  This child is on level 1
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :     02  ---- Starting a new property set ----
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :     02  Value is ........ : ""
Wed Jun 16 16:36:47 2004 :     02  Type is  ........ : "search-spec"
Wed Jun 16 16:36:47 2004 :     02  Child count ..... : 1
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :     02  Child Property Set 1 of 1 follows below.
Wed Jun 16 16:36:47 2004 :     02  This child is on level 2
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :       03  ---- Starting a new property set ----
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :       03  Value is ........ : "AND"
Wed Jun 16 16:36:47 2004 :       03  Type is  ........ : "node"
Wed Jun 16 16:36:47 2004 :       03  Child count ..... : 2
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :       03  Property 01  name : "node-type"
Wed Jun 16 16:36:47 2004 :       03  Property 01 value : "Binary Operator"
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:47 2004 :       03  Child Property Set 1 of 2 follows below.
Wed Jun 16 16:36:47 2004 :       03  This child is on level 3
Wed Jun 16 16:36:47 2004 :  
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :         04  ---- Starting a new property set ----
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :         04  Value is ........ : "AND"
Wed Jun 16 16:36:48 2004 :         04  Type is  ........ : "node"
Wed Jun 16 16:36:48 2004 :         04  Child count ..... : 2
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :         04  Property 01  name : "node-type"
Wed Jun 16 16:36:48 2004 :         04  Property 01 value : "Binary Operator"
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :         04  Child Property Set 1 of 2 follows below.
Wed Jun 16 16:36:48 2004 :         04  This child is on level 4
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :   
Wed Jun 16 16:36:48 2004 :           05  ---- Starting a new property set ----
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :           05  Value is ........ : "="
Wed Jun 16 16:36:48 2004 :           05  Type is  ........ : "node"
Wed Jun 16 16:36:48 2004 :           05  Child count ..... : 2
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :           05  Property 01  name : "node-type"
Wed Jun 16 16:36:48 2004 :           05  Property 01 value : "Binary Operator"
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :           05  Child Property Set 1 of 2 follows below.
Wed Jun 16 16:36:48 2004 :           05  This child is on level 5
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :             06  ---- Starting a new property set ----
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :             06  Value is ........ : "Date"
Wed Jun 16 16:36:48 2004 :             06  Type is  ........ : "node"
Wed Jun 16 16:36:48 2004 :             06  Child count ..... : 0
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :             06  Property 01  name : "node-type"
Wed Jun 16 16:36:48 2004 :             06  Property 01 value : "Identifier"
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :             06  (No children exist below this property set.)
Wed Jun 16 16:36:48 2004 :  
Wed Jun 16 16:36:48 2004 :           05  Child Property Set 2 of 2 follows below.
Wed Jun 16 16:36:48 2004 :           05  This child is on level 5
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  ---- Starting a new property set ----
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  Value is ........ : "06/18/2004"
Wed Jun 16 16:36:49 2004 :             06  Type is  ........ : "node"
Wed Jun 16 16:36:49 2004 :             06  Child count ..... : 0
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  Property 01  name : "node-type"
Wed Jun 16 16:36:49 2004 :             06  Property 01 value : "Constant"
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  Property 02  name : "value-type"
Wed Jun 16 16:36:49 2004 :             06  Property 02 value : "DATE"
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  (No children exist below this property set.)
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :         04  Child Property Set 2 of 2 follows below.
Wed Jun 16 16:36:49 2004 :         04  This child is on level 4
Wed Jun 16 16:36:49 2004 :   
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :           05  ---- Starting a new property set ----
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :           05  Value is ........ : "LIKE"
Wed Jun 16 16:36:49 2004 :           05  Type is  ........ : "node"
Wed Jun 16 16:36:49 2004 :           05  Child count ..... : 2
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :           05  Property 01  name : "node-type"
Wed Jun 16 16:36:49 2004 :           05  Property 01 value : "Binary Operator"
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :           05  Child Property Set 1 of 2 follows below.
Wed Jun 16 16:36:49 2004 :           05  This child is on level 5
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  ---- Starting a new property set ----
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  Value is ........ : "Description"
Wed Jun 16 16:36:49 2004 :             06  Type is  ........ : "node"
Wed Jun 16 16:36:49 2004 :             06  Child count ..... : 0
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  Property 01  name : "node-type"
Wed Jun 16 16:36:49 2004 :             06  Property 01 value : "Identifier"
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  (No children exist below this property set.)
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :           05  Child Property Set 2 of 2 follows below.
Wed Jun 16 16:36:49 2004 :           05  This child is on level 5
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  ---- Starting a new property set ----
Wed Jun 16 16:36:49 2004 :  
Wed Jun 16 16:36:49 2004 :             06  Value is ........ : "A test description*"
Wed Jun 16 16:36:50 2004 :             06  Type is  ........ : "node"
Wed Jun 16 16:36:50 2004 :             06  Child count ..... : 0
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :             06  Property 01  name : "node-type"
Wed Jun 16 16:36:50 2004 :             06  Property 01 value : "Constant"
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :             06  Property 02  name : "value-type"
Wed Jun 16 16:36:50 2004 :             06  Property 02 value : "TEXT"
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :             06  (No children exist below this property set.)
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :       03  Child Property Set 2 of 2 follows below.
Wed Jun 16 16:36:50 2004 :       03  This child is on level 3
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :         04  ---- Starting a new property set ----
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :         04  Value is ........ : "LIKE"
Wed Jun 16 16:36:50 2004 :         04  Type is  ........ : "node"
Wed Jun 16 16:36:50 2004 :         04  Child count ..... : 2
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :         04  Property 01  name : "node-type"
Wed Jun 16 16:36:50 2004 :         04  Property 01 value : "Binary Operator"
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :         04  Child Property Set 1 of 2 follows below.
Wed Jun 16 16:36:50 2004 :         04  This child is on level 4
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  ---- Starting a new property set ----
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  Value is ........ : "House_ID"
Wed Jun 16 16:36:50 2004 :           05  Type is  ........ : "node"
Wed Jun 16 16:36:50 2004 :           05  Child count ..... : 0
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  Property 01  name : "node-type"
Wed Jun 16 16:36:50 2004 :           05  Property 01 value : "Identifier"
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  (No children exist below this property set.)
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :         04  Child Property Set 2 of 2 follows below.
Wed Jun 16 16:36:50 2004 :         04  This child is on level 4
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  ---- Starting a new property set ----
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  Value is ........ : "779*"
Wed Jun 16 16:36:50 2004 :           05  Type is  ........ : "node"
Wed Jun 16 16:36:50 2004 :           05  Child count ..... : 0
Wed Jun 16 16:36:50 2004 :  
Wed Jun 16 16:36:50 2004 :           05  Property 01  name : "node-type"
Wed Jun 16 16:36:51 2004 :           05  Property 01 value : "Constant"
Wed Jun 16 16:36:51 2004 :  
Wed Jun 16 16:36:51 2004 :           05  Property 02  name : "value-type"
Wed Jun 16 16:36:51 2004 :           05  Property 02 value : "TEXT"
Wed Jun 16 16:36:51 2004 :  
Wed Jun 16 16:36:51 2004 :           05  (No children exist below this property set.)

Tags