Question
Script okay in photoshop, not as BridgeTalk message
The following script extracts the style names from a style asl file in photoshop. This code works for photoshop CS2, when run from the ETSK with CS2 selected:
// CS2 version
x = function () {
var file = File(app.path + '/Presets/Styles/buttons.asl');
file.open( 'r' );
file.encoding = 'BINARY';
var stuff = file.read( file.length );
var rx = /null\x00\x00\x00\x02\x00\x00\x00\x00Nm[ ][ ]TEXT\x00\x00.+?\x00\x00/g;
var result = stuff.match( rx );
if (result != null) {
var msg = '';
for (var i = 0; i < result.length; i++ ) {
result = result.replace( /.*Nm[ ][ ]TEXT/g, '' );
result = result.replace( /[\x00-\x1F]/g, '' );
msg += '\n'+result;
}
alert(msg);
}
}
x();
---------------------
However, the identical code, run from Bridge, using BridgeTalk, will not work. BTW, this is the only code I have that will not work via BridgeTalk. It stumbles on (result != null) and photoshop seizes up.
The following code is saved as test.jsx in the StartupScripts folder:
// Bridge version
Test=function(){
var targetApp = BridgeTalk.getSpecifier( "photoshop", "9");
if (targetApp) {
var bt = new BridgeTalk;
bt.target = 'photoshop';
bt.body = x.toSource();
alert(bt.body);
bt.send();
}
}
x = function () {
var file = File(app.path + '/Presets/Styles/buttons.asl');
file.open( 'r' );
file.encoding = 'BINARY';
var stuff = file.read( file.length );
var rx = /null\x00\x00\x00\x02\x00\x00\x00\x00Nm[ ][ ]TEXT\x00\x00.+?\x00\x00/g;
var result = stuff.match( rx );
if (result != null) {
var msg = '';
for (var i = 0; i < result.length; i++ ) {
result = result.replace( /.*Nm[ ][ ]TEXT/g, '' );
result = result.replace( /[\x00-\x1F]/g, '' );
msg += '\n'+result;
}
alert(msg);
}
}
createMenu( "command", "Test...", "at the end of tools/ps", "Test", Test );
------------------
Bob - if you see this I sure would appreciate your help!
TIA
Rory
// CS2 version
x = function () {
var file = File(app.path + '/Presets/Styles/buttons.asl');
file.open( 'r' );
file.encoding = 'BINARY';
var stuff = file.read( file.length );
var rx = /null\x00\x00\x00\x02\x00\x00\x00\x00Nm[ ][ ]TEXT\x00\x00.+?\x00\x00/g;
var result = stuff.match( rx );
if (result != null) {
var msg = '';
for (var i = 0; i < result.length; i++ ) {
result = result.replace( /.*Nm[ ][ ]TEXT/g, '' );
result = result.replace( /[\x00-\x1F]/g, '' );
msg += '\n'+result;
}
alert(msg);
}
}
x();
---------------------
However, the identical code, run from Bridge, using BridgeTalk, will not work. BTW, this is the only code I have that will not work via BridgeTalk. It stumbles on (result != null) and photoshop seizes up.
The following code is saved as test.jsx in the StartupScripts folder:
// Bridge version
Test=function(){
var targetApp = BridgeTalk.getSpecifier( "photoshop", "9");
if (targetApp) {
var bt = new BridgeTalk;
bt.target = 'photoshop';
bt.body = x.toSource();
alert(bt.body);
bt.send();
}
}
x = function () {
var file = File(app.path + '/Presets/Styles/buttons.asl');
file.open( 'r' );
file.encoding = 'BINARY';
var stuff = file.read( file.length );
var rx = /null\x00\x00\x00\x02\x00\x00\x00\x00Nm[ ][ ]TEXT\x00\x00.+?\x00\x00/g;
var result = stuff.match( rx );
if (result != null) {
var msg = '';
for (var i = 0; i < result.length; i++ ) {
result = result.replace( /.*Nm[ ][ ]TEXT/g, '' );
result = result.replace( /[\x00-\x1F]/g, '' );
msg += '\n'+result;
}
alert(msg);
}
}
createMenu( "command", "Test...", "at the end of tools/ps", "Test", Test );
------------------
Bob - if you see this I sure would appreciate your help!
TIA
Rory
