CS6 Windows problem with BridgeTalk
-
Mike Hale
CS6 Windows problem with BridgeTalk
I also wanted to say thanks for supporting the site. The hosting account is up for renewal the first of next month and donations are used to offset the cost of running the site.
-
kpt
CS6 Windows problem with BridgeTalk
Glad to help, the collected knowledge here is invaluable.
-
kpt
CS6 Windows problem with BridgeTalk
BTW: Paul, did you manage to get that regular expression to work? I can't seem to escape the backslashes, I had to resort to building the "\" from its ASCII code. Perhaps there is a better way?
Code: Select all var res = "(1234+5678)";
var re = new RegExp(String.fromCharCode(92)+"d+", "i");
alert("re = " + re); /* => /\d+/i */
alert(res.match(re)); /* => 1234 */
alert(res.match(/\d+/)); /* => null */
alert(res.match(/\\d+/)); /* => null */
Code: Select all var res = "(1234+5678)";
var re = new RegExp(String.fromCharCode(92)+"d+", "i");
alert("re = " + re); /* => /\d+/i */
alert(res.match(re)); /* => 1234 */
alert(res.match(/\d+/)); /* => null */
alert(res.match(/\\d+/)); /* => null */
-
Mike Hale
CS6 Windows problem with BridgeTalk
There is an detailed explanation for the need to escape BridgeTalk messages.
As that applies here I think that in a normal script you escape the backslash when you create an explicit re. You don't with an implicit re.
In a BridgeTalk message like this you have to escape both types.Code: Select all //Test for regex, run from ESTK
//needs to have a document open in Photoshop
function script(){
try{
alert('Got here');
/* you need to escape backslash etc */
/* N.B coments must be like this! */
/* you also need to be aware of which type of quote you use */
var re = new RegExp('\\.[^\\.]+$');
var explicitRE = app.activeDocument.name.replace(re, '');
var explicitRE = app.activeDocument.name.replace(/\\.[^\\.]+$/, '');
alert(explicitRE);
alert(explicitRE);
}catch(e){alert(e);}
}
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.send();
Or did I misunderstand your question?
As that applies here I think that in a normal script you escape the backslash when you create an explicit re. You don't with an implicit re.
In a BridgeTalk message like this you have to escape both types.Code: Select all //Test for regex, run from ESTK
//needs to have a document open in Photoshop
function script(){
try{
alert('Got here');
/* you need to escape backslash etc */
/* N.B coments must be like this! */
/* you also need to be aware of which type of quote you use */
var re = new RegExp('\\.[^\\.]+$');
var explicitRE = app.activeDocument.name.replace(re, '');
var explicitRE = app.activeDocument.name.replace(/\\.[^\\.]+$/, '');
alert(explicitRE);
alert(explicitRE);
}catch(e){alert(e);}
}
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.send();
Or did I misunderstand your question?
-
Paul MR
CS6 Windows problem with BridgeTalk
Thanks Mike it looks as if you have found an answer.
Creating a new RegExp doesn't need to be escaped and just works.
Code: Select all //Test for regex, run from ESTK
//needs to have a document open in Photoshop
function script(){
try{
/* you need to escape backslash etc */
/* N.B comments must be like this! */
/* you also need to be aware of which type of quote you use */
/* This works with no escaping*/
var re = new RegExp('\.[^\.]+$');
var explicitRE = app.activeDocument.name.replace(re, '');
alert(explicitRE);
/* This does not work */
var explicitRE = app.activeDocument.name.replace(/\\.[^\\.]+$/, '');
alert(explicitRE);
}catch(e){alert(e);}
}
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.send();
Creating a new RegExp doesn't need to be escaped and just works.
Code: Select all //Test for regex, run from ESTK
//needs to have a document open in Photoshop
function script(){
try{
/* you need to escape backslash etc */
/* N.B comments must be like this! */
/* you also need to be aware of which type of quote you use */
/* This works with no escaping*/
var re = new RegExp('\.[^\.]+$');
var explicitRE = app.activeDocument.name.replace(re, '');
alert(explicitRE);
/* This does not work */
var explicitRE = app.activeDocument.name.replace(/\\.[^\\.]+$/, '');
alert(explicitRE);
}catch(e){alert(e);}
}
var bt = new BridgeTalk;
bt.target = "photoshop";
bt.body = "var ftn = " + script.toSource() + "; ftn();";
bt.send();
-
Mike Hale
CS6 Windows problem with BridgeTalk
Funny, I was testing with a new doc and all I noticed was it no longer said null. I didn't notice the implicit match was not what it should have been.