Wrapping Routing Lists |
This script is used to break the contents of one box (e.g., a routing list) into two side-by-side boxes -- so you have the names in two columns. |
Script Language: JavaScript | For use with: DB/TextWorks | Requires at least version 4.1 |
// If you have assigned different script names to the
// boxes containing the routing list names
// change the names in these two variables to match:
var routeName1 = "route1"; // box containing routing list
var routeName2 = "route2"; // empty box for second half of routing list
// If your box height is not 5, change the boxHeight value below
var boxHeight = 5; // maximum height of routing list box
var maxCount = boxHeight * 2; // maximum number of names that can be shown
function onRecordOpen()
{
var routeBox1; // box named routeName1
var routeBox2; // box named routeName2
var routeBox1Content; // content of routeBox1
var linebreak; // line break character
// check for existence of boxes named above,
// stopping if both are not found
routeBox1 = Form.boxes(routeName1);
if (!routeBox1)
return;
routeBox2 = Form.boxes(routeName2);
if (!routeBox2)
return;
routeBox1Content = routeBox1.content;
if (routeBox1Content != "")
{
// determine line break character
if (routeBox1Content.search("\n") != -1)
{
linebreak = "\n";
}
else if (routeBox1Content.search("\r") != -1)
{
linebreak = "\r";
}
else
{
return;
}
var routeEntries = routeBox1Content.split(linebreak);
var secondHalf = routeEntries.slice(boxHeight,maxCount);
var secondBox = secondHalf.join(linebreak);
routeBox2.content = secondBox;
}
} |
Notes: This script assumes you have a "route1" box containing your routing list, and an additional empty "route2" box next to (and ideally anchored to) "route1" for the script to copy the second half of the routing list into. It assumes the "route1" box has Box Properties>Paragraphs set to "Make each item or entry a paragraph". Be sure to set the minimum height of the empty "route2" box to match the boxHeight value specified in the script. Note: Form Scripts are currently disabled for label forms. | Submitted by Inmagic Staff on 23-May-2001 16:34 |