Hello fellow scripters - This is probably something really basic, and it really is something minor but would be appreciated if someone could look into and explain why the \n isn't working correctly.
I've got a code;
//created by Daryl Smith //puts artist name, filename, and date in the top left of the file. #target illustrator var thisDoc = app.activeDocument; var filename = app.activeDocument.name.replace(/\.[^\.]+$/, ''); var createdate = app.activeDocument.modified; var theDate = new Date(); var day = theDate.getDate(); var month = theDate.getMonth() + 1; var year = theDate.getFullYear(); var hours = theDate.getHours(); var min = theDate.getMinutes(); if (min < 10) min = ("0" + min); var morn; if (hours >= 12) { hours = hours-12; morn = " PM"; } else morn = " AM" var saveDate = (month + "-" + day + "-" + year + " " + hours + ":" + min + morn ); var nameTextFrame = thisDoc.textFrames.add(); nameTextFrame.contents = globalartistname + "\n" + filename + "\n" + saveDate; nameTextFrame.filled = true; nameTextFrame.alignment = "center"; var thisdoc = app.activeDocument; var hasDocCoords = app.coordinateSystem == CoordinateSystem.ARTBOARDCOORDINATESYSTEM; var p = thisdoc.pageItems; for (var i = 0, l = p.length; i < l; i++) { var pID = p[i]; if (pID.guides == true) { var guideBox = pID } } var wNum = guideBox.width; var hNum = guideBox.height; var tboxw = nameTextFrame.width; var tboxh = nameTextFrame.height; var xOffset = (wNum/2); var yOffset = (hNum/2); var xNum = guideBox.position[0]+xOffset-tboxw-50; var yNum = guideBox.position[1] + tboxh + 80 ; nameTextFrame.position = [xNum,yNum]
that I run from my pallet using;
var putname = new File("S:/Art/ArtDept/Illustrator JS Palette/Scripts/Art Share Server/Construct/filenameonart.jsx"); miscgroup.add ("iconbutton", undefined, ScriptUI.newImage (miscputnameIcon.a, miscputnameIcon.b, miscputnameIcon.c, miscputnameIcon.d),{style:"toolbutton"});
miscgroup.children[2].onClick = function() { putname.open("r"); var bt = new BridgeTalk; bt.target = "illustrator"; var script = putname.read(); putname.close(); bt.body = script; bt.send();
So I'm pulling the script through bridge. The script works correctly when I run the script directly but doesn't when I run it from the pallet. It reads the "\n" as text instead of the new line that it is suppose to be only when ran from the pallet through BridgeTalk.
Message was edited by: daryl smith