I need help with a script. I am trying to shift some values within an open file. The script works but I want it to stay within the current open file and not create a new one. Any help or suggestions?
// Global Variables
var newDocString;
var entireDocString;
var entireDocArray = ;
//******************************************************************************
//* Main Script Sequence
//******************************************************************************
UltraEdit.activeDocument.selectAll();
entireDocString = UltraEdit.activeDocument.selection;
entireDocArray = entireDocString.split(ā\nā);
//shiftValue(/robtarget Pth01_/, 101.6, 0);
//shiftValue(/searchExpressions/, shiftValue, External Axis);
//shiftValue(/robtarget/, 90, 0); // Ext_a
shiftValue(/jointtarget/, -5, 1); // Ext_b
//shiftValue(/robtarget/, 0, 2); // Ext_c
//shiftValue(/robtarget/, 0, 3); // Ext_d
//shiftValue(/robtarget/, 0, 4); // Ext_e
//shiftValue(/robtarget/, 38, 5); // Ext_f
//shiftValue(/jointtarget/, 0, 5); // Ext_f
newDocString = entireDocArray.join(ā\nā);
UltraEdit.newFile();
UltraEdit.activeDocument.write(newDocString);
//******************************************************************************
//* shiftValue - isolates robTarget external axis values, applies math to
//* specified value, inserts values back into robtarget data.
//******************************************************************************
function shiftValue(searchExpression, shiftValue, position){
// Local Variables
var testLine;
var indexPos1;
var indexPos2;
var extAxis;
var extAxisValue;
var lineString;
var lineArray = ;
for (i = 0; i < entireDocArray.length; i++) {
testLine = searchExpression.test(entireDocArray[i]);
if (testLine == true) {
indexPos1 = entireDocArray[i].lastIndexOf('[')+1;
indexPos2 = entireDocArray[i].lastIndexOf(']]');
extAxis = entireDocArray[i].slice(indexPos1,indexPos2);
lineArray = extAxis.split(',');
extAxisValue = lineArray[position];
if (extAxisValue == '9E9') {
extAxisValue = 0;
}
lineArray[position] = parseFloat(extAxisValue)+shiftValue;
lineString = lineArray.join(',');
entireDocArray[i] = entireDocArray[i].replace(extAxis, lineString);
}
}
}