Beyond Compare
From Pickwiki
Beyond Compare SB+ Paragraph formatter
- Works with Beyond Compare - allows you to compare SB+ Paragraph Processes.
- Written in Javascript.
- Save this to c:\program files\Beyond Compare 3\helpers\SBParaCompare.js
- Setup a new Tools/File Format for SB Paragraphs.
- Under the Conversion tab - conversion drop down select: External Program
- Loading: cscript helpers\SBParaCompare.js %s %t %n
// BC-SB Paragraph Compare
// This scripts uses the output from a type 19 process file
// it is then used with Beyond Compare (File Formats, Conversion)
// Stuart Boydell 21-Dec-2009
// 0. setup a new Tools/File Format for SB Paragraphs. Loading: cscript SBParaCompare.js %s %t %n
// 1. The paragraph items to compare are stored in a type19 file in U2
// 2. items are opened using Beyond Compare - it normally 'senses' the file type - but you can use the format drop down to force it.
// 3. BC invokes this script passing in source & target tmp file specs
// 4. this script writes the modified version of the process to the target file
// 5. BC then compares these files.
var of, oa, fs, ft, i, j, z, zz, re, lsep, ftyp;
var _vm = String.fromCharCode(253);
re = /\r\n/; // test for windows type newline
of = new ActiveXObject('Scripting.FileSystemObject');
oa = WScript.Arguments;
// take the source & target arguments from BC
fs = of.OpenTextFile(oa(0),1,false);
ft = of.OpenTextFile(oa(1),2,false);
fo = of.OpenTextFile(oa(2),1,false);
// Read the process item then pull att 6
z = fs.ReadAll();
if (re.test(z)){
lsep = "\r\n";
ftyp = "Win";
} else {
lsep = "\n";
ftyp = "Unix";
}
zz = z.split(lsep);
//ft.WriteLine('File Path:' + oa(2).substr(0,oa(2).indexOf('//',10)));
ft.WriteLine('Desc:' + zz[1]);
ft.WriteLine('Dict:' + zz[4]);
ft.WriteLine('LastUpd:' + zz[13]);
//ft.WriteLine('F-type:' + ftyp);
ft.WriteLine('---');
ft.Write(zz[5].split(_vm).join(lsep));
fs.Close
ft.Close
Beyond Compare SB+ Paragraph Write back Script
- Works with Beyond Compare - allows you to write back edits.
- Written in Javascript.
- Save this to c:\program files\Beyond Compare 3\helpers\SBParaWriteback.js
- Under the Conversion tab - disable editing <off>
- Saving: cscript helpers\SBParaWriteback.js %s %t %n
// BC-SB Paragraph Compare - Write back
// This writes back to a type 19 process file
// it is then used with Beyond Compare (File Formats, Conversion)
// Stuart Boydell 21-Dec-2009
var of, oa, fs, ft, i, j, z, zz, lsep, re;
var _vm = String.fromCharCode(253);
re = /\r\n/; // test for windows type newline
of = new ActiveXObject('Scripting.FileSystemObject');
oa = WScript.Arguments;
// take the source & target arguments from BC
fs = of.OpenTextFile(oa(0),1,false);
ft = of.OpenTextFile(oa(1),2,false);
fo = of.OpenTextFile(oa(2),1,false);
// Read the process item then pull att 6
z = fo.ReadAll();
if (re.test(z)){
lsep = "\r\n";
ftyp = "Win";
} else {
lsep = "\n";
ftyp = "Unix";
}
tt = z.split(lsep);
zz = fs.ReadAll().split(lsep);
tt[1] = zz[0].split(':')[1];
tt[2] = '';
tt[3] = '';
tt[4] = zz[1].split(':')[1];
tt[5] = zz.splice(4,zz.length).join(_vm);
ft.Write(tt.join(lsep));
fs.Close
ft.Close