I am writing a script that should eventually be run from a drop down menu.
The parts of this script are:
The following is what I currently have. I have no declaration issues except that I am being told that I am trying to pass in null buffers in locations 1, 2 and 3 in the diff() function
//===Relevant declarations===
Object thiso, thato
Module thismod, thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thiso in thismod do {
for that o in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = thiso."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
delete thatotext
delete thisotext
delete diffResult
}
}
}
Things that I have checked:
I began learning DXL three weeks ago, so I am still a little new. This has me stumped, but I will continue trying different things as I wait to see if anyone has advice.
Thank you in advance to anyone who has the time to help.
Okay! Took me a second, but I think I figured out why your first section of code failed.
//===Relevant declarations===
Object thiso, thato
Module thismod, thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thiso in thismod do {
for that o in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = thiso."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
delete thatotext
delete thisotext
delete diffResult
}
}
}
The issue here is in those 'delete' calls. The first time this is run, the very first object that matches all criteria ( thiso."Reqid" "" == thato."Reqid" "" ) will cause the buffers to be deleted and nulled out. The next successful match will just throw an error.
//===Relevant declarations===
Object thiso, thato
Module thismod, thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thiso in thismod do {
for thato in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = thiso."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
thatotext = ""
thisotext = ""
diffResult = ""
}
}
}
delete thatotext
delete thisotext
delete diffResult
This will clear the buffers in between comparisons but not destroy them. I think this behavior is also causing the issue in your functionalized example - you are repeatedly creating and destroying buffers rather than re-using the same buffer space.
Let me know how this goes!
Edit: Looking over your question, if you are embedding this in layout dxl, you may want to use the ( obj."Reqid" "" ) rather than the 'thiso in thismod' loop. Layout dxl is evaluated for each object, and 'obj' is effectively assigned as the handle to the object that the layout dxl is invoked from. Right now every object in is looping through every object.
Edit 2: Sample code
//===Relevant declarations===
Object thato
Module thatmod // these have been assigned using my search function
Buffer diffResult = create
Buffer thisotext = create
Buffer thatotext = create
//===The problem child===
for thato in thatmod do {
if(thiso."Reqid" "" == thato."Reqid" "") {
thisotext = obj."Object Text"
thatotext = thato."Object Text"
diff(diffResult, thatotext, thisotext, "\\cf1\\strike","\\cf3\\u1") // here lies issue number 1
displayRichWithColor(stringOf(diffResult)) // commented out atm
thatotext = ""
thisotext = ""
diffResult = ""
}
}
delete thatotext
delete thisotext
delete diffResult