This guest post is written by my colleague Kristof Meesens. Thank you Kristof for contributing.
Lately I was in a deep debugging mode and used the cross references to find out some stuff.
The cross reference is a great help, but if you want to set some breakpoints it can take a lot of work.
For example you want to set a breakpoint everywhere where a field will be written.
You use the cross reference from the table/field and filter on the reference ‘write’
If you want to set a breakpoint you have to edit each line and set a breakpoint.
I created a class KrMeeSysBreakpoints that will be used to add breakpoints from a container.
The container must contain a Path, a Line number and a Boolean to enable the breakpoint.
This container will be added to another container that the class will use to loop
public void run()
{
int i;
container bpCon;
container bpConTmp;
if (bpCons != conNull())
{
bpCon = infolog.breakpoint();
for(i=1; i<=conLen(bpCons); i++)
{
bpConTmp = conPeek(bpCons, i);
path = conPeek(bpConTmp, 1);
line = conPeek(bpConTmp, 2);
enabled = conPeek(bpConTmp, 3);
if (line != 0)
{
bpCon += [path];
bpCon += [line];
bpCon += [enabled];
}
}
infolog.breakpoint(bpCon);
}
}
To use this functionality, you can add a button to the form of the cross references.
void clicked()
{
xRefReferences xRefReferencesEdit;
container bpCons;
container bpCon;
for (xRefReferencesEdit = getFirstSelection(xRefReferences_ds);
xRefReferencesEdit;
xRefReferencesEdit = xRefReferences_ds.getNext())
{
bpCon = conNull();
bpCon += [xRefPaths::findRecId(xRefReferencesEdit.xRefPathRecId).Path];
bpCon += [xRefReferencesEdit.line];
bpCon += [true];
bpcons += [bpCon];
}
KrMeeSysBreakpoints::newFromContainer(bpcons).run();
}
You can also call this functionality from de search form
void clicked()
{
FormListItem selectedItem;
str selectedData;
int i, pos;
container bpCons;
container bpCon;
i = ResultListView.getNextItem(FormListNext::Selected);
while (i != -1)
{
selectedItem = resultListView.getItem(i);
selectedData = selectedItem.data();
pos = strFind(selectedData, '\\', 1, strLen(selectedData));
if (pos > 1)
{
bpCon = conNull();
bpCon += [subStr(selectedData, pos, strLen(selectedData))];
bpCon += [str2int(selectedData)];
bpCon += [true];
bpcons += [bpCon];
}
i = ResultListView.getNextItem(FormListNext::Selected,i);
}
KrMeeSysBreakpoints::newFromContainer(bpcons).run();
}
An example screenshot from the cross references screen:
Download the XPO: SharedProject_KrMeeSetBreakpoints.xpo.
Related
Philippe
on October 26, 2013 at 20:53
Very good post! Thx
Tommy Skaue
on October 27, 2013 at 11:45
That is cool! Thanks for sharing! :-)
Kenny Saelen
on October 28, 2013 at 11:30
Nice one!
Going to use it as of today :)
Steven De Ridder
on November 15, 2013 at 17:35
Very useful code. Nicely done.
Thx Kristof
Tom Van Dyck
on January 13, 2014 at 16:25
I just LOVE this one!
Ashlesh
on November 18, 2014 at 13:15
Nice post. Quite helpful. Thanks for sharing.