Buglet in AdobeLibrary1.jsx

I thought I'd point out a technical bug in one of the functions in AdobeLibrary1.jsx. The function file.getExtension() can return wrong results when the filename has no extension because (on Windows, at least) parts of the pathname can have "." in them. This isn't real common, but is possible. So if you pass the filename "c:/bob/ted.alice/jack" to your function, it will return ".alice/jack" as the extension which is not technically correct. In reality, it should return "" since there is no extension.
In my own code, I've used a regular expression /\.[^\/\\]*$/ which is a period, followed by some number of non-path separator characters at the end of the string and this handles both cases.
--John

[email protected] wrote:
> I think you need to use brackets with the exec method of the re eg
>
> var re = /\.([^\.\/\\]+$)/;
> var reResultsAr = re.exec(targetstring);
> var firstBracket = reResultsAr[1];
>
> I better admit that I have not tested this, I'm just going from the Core Javascript Ref 1.5.
>
> Andrew
I knew about doing this, but he wanted a one liner, i.e. one that just used
regexp to return a result. It's not possible with JavaScripts regexp implementation.
Also, you don't need to use RegExp.exec: String.match will give you the same
behaviour.
And, if you really want to get it all on one line, do it like this:
((RegExp.__tmp = str.match(/\.([^\.\/\\]+$)/)) ? RegExp.__tmp[1] : undefined)
While something like this is (almost) obvious to me, I can't say that most PS
scripters would understand it at first glance.
ciao,
-X

Similar Messages

  • AdobeLibrary1.jsx etc License and Distribution

    [Preamble - I may be totally wrong about the following - I do hope so, please put me right if so]
    It would make life a lot easier if we could include the Adobe Library scripts along with scripts we release ourselves - when they are required. At the moment the Library scripts' licenses do allow us to include them ('we may distribute them'), but then the user is not allowed to use them without written permission from Adobe. That really isn't workable. Furthermore, the only place I have found that provides the files for download is as part of the ImportCamera package. Again, that is not a particularly workable or helpful route for other scripters to direct users to. If they have to be downloaded separately, please could Adobe include them as an individual item from Studio Exchange. Is there really a strong reason for not just making these Libraries copyright Adobe but open to anyone to distribute *and use*?
    My experience in releasing scripts is that if the process is not totally simple (one set of files to be put in one location) then it doesn't happen and you end up with frustrated and pissed off users. Because of that I think I am going to have to fall back on not using the libraries (and reinventing the wheel - usually not so well as a consequence) until a more workable way of getting them to the user is made possible.
    While it appears the libraries come as part of the package for CS2, this does not seem to be the case with PS CS2, also I believe the Library3 was not written when the initial release of CS2 was made, so again there may be gaps.
    Andrew

    Bob, I appreciate that is "your" intent to let us distribute and use these library files as we wish, but for people contemplating some money making enterprises that include Bridge scripts, your posting here isn't enough for me. So, like Andrew, I've taken to NOT using them because of that legal ambiguity.
    Is there some more formal way to fix this? Like re-release the files under one of the common licenses and let us redistribute files that contain a usable license. I think in this case you want a very open license since you're more interested in encouraging people to build off what you have and make useful stuff rather than trying to guarentee open-ness of derivative works. The LGPL, referenced above, would do as would several of the other "open licenses" that are less restrictive than the GPL.
    I know this involves the legal dept at Adobe and is probably a pain to get done, but you're really going to limit the use of those libraries for anyone intending redistribution until it's fixed.
    In case it's relevant, the Image Processor script has no licensing clause in it at all, but the stock photo scripts have the same one that AdobeLibrary*.jsx have.
    --John

  • So What the heck is AdobeLibrary2.jsx?

    So far I've written a bit about what's in AdobeLibrary1.jsx and AdobeLibrary3.jsx. Now it's AdobeLibrary2.jsx's turn.
    Bridge provides one method for persistently storing script settings. app.preferences is how it's done. But what if you want to store a bunch of stuff, and you don't want it destroyed when the user purges their preferences?
    For example, the import from camera script stores standard import locations and renaming templates. You don't want your user to lose those things if the trash their Bridge preferences.
    The answer is ScriptStore - AdobeLibrary2.jsx
    ScriptStore is an XML storage facility. It's primitive in that there is very little searching capability, you have to know what you put in there. But it's also robust and fast.
    The actual data is stored in a folder in the user data area
    Win: c:\documents and settings\[user]\application data\adobe\ScriptStore
    Mac: [user]\library\application support\adobe\ScriptStore
    There are plenty of examples in Import from Camera on how to use it.
    But the basics are (and most of this is in the top commented section of the library itself):
    MyScript = {};
    MyScript.store = ScriptStore.open( "$$$AStoragePalceForMyScript" );
    ScriptStore.open - will launch ScriptStore, and open a "store" with the given name. The name can not contain spaces, and must be unique from all other store names. So use something goofy. If the store does not exist, it returns a new, empty store.
    To put simple data into the store:
    store.put( type, name, value );
    Where type is a string - just a name - allows you to store more than one property of the same name, but delineating a "type" or category of data.
    name is the name to store it under
    value is the value
    store.put( "metadata", "Fred", "Flinstone" );
    This creates an xml structure like:
    Flintstone
    Doing it again:
    store.put( "metadata", "Barney", "Rubble" );
    yields:
    Flintstone
    Rubble
    Attempting to overwrite does exactly that.
    store.put( "metadata", "Barney", "Fife" );
    yields:
    Flintstone
    Fife
    To get stored data:
    store.get( "metadata", "Barney" );
    returns "Fife"
    You can also put Arrays into storage:
    var ar = ["Fred","Barney","Wilma","Betty"]
    store.putArray( "metadata", "FlintstoneAdults", ar );
    and get arrays
    store.getArray( "metadata", "FlintstoneAdults" );
    In AdobeLibrary1, we created an object definition, Hashtable - which I find uniquely useful.
    You can:
    var ht = new Hashtable();
    ht.put( "Fred", "Flintsone" );
    ht.put( "Barny", "Rubble" );
    ht.put( "Wilma", "Flintstone" );
    ht.put( "Betty", "Rubble" );
    store.putCollection( "metadata", "FlintFolk", ht );
    and
    var ht = store.getCollection( "metadata", "FlintFolk" );
    And if these put and get methods aren't enough for you, you can create your own data structure and traverse it yourself.
    store.root is the root XmlNode of the store.
    So to make your own structure, use XmlNode.addNode( name, value );
    myNode = store.root.addNode( "myNode" );
    myDataNode = myNode.addNode( "Fred", "Flintstone" );
    this creates an XML structure:
    Flintstone
    Once you have stored this sturcture with: store.save();
    You find it this way:
    var MyNode = store.root.findNode( "myNode" );
    var Fred = myNode.findNode( "Fred" ).getValue();
    You can find a node among multiple nodes:
    store.findNode( name, count );
    where count is an integer. Count = 0, it finds the first instance of a node with "name". Count = 1, it finds the second.
    Or you can just get them all:
    store.findNodes( name );  which returns a array of nodes
    I hope you all find this as useful as I do.
    Bob
    Adobe Workflow Scripting

    I've got some code that I would like to have run portably between CS and CS2.
    I'd like to use your XML stuff in AdobeLibrary2.jsx because:
    1) I don't have to write it
    2) It comes bundled with CS2
    3) It's "free", sorta.
    My problem is that it does not come bundled with CS which mean I would have to
    include AdobeLibrary2.jsx with my script or strip out the XML stuff and include
    it in my package.
    I don't have a problem with the mechanics of this process. What is not clear,
    howver, is what the legal ramifications are of giving AdobeLibrary2.jsx to
    someone who has not yet purchased a copy of a CS2 product. I'm not a lawyer so
    asking me to read the licensing agreements is an effort in futility. It's real
    easy for a layman like myself to misinterpret legalese.
    What I would like is clarification from someone at Adobe as to what the
    re-distribution policy is for AdobeLibrary2.jsx. I can go download a number of
    different Free XML JS implementations, but I'd rather use your stuff.
    thanks for the help.
    ciao,
    -X

  • What is the correct usage for a "photoshop.executeScript"

    I am scripting in javascript on a Mac OSX machine with Bridge 1.0.4.6.
    I am trying to execute a Photoshop Javascript file from within Bridge, but I have been, as of yet, unsuccessful. I am attempting to use the photoshop.executeScript command with a string value of the photoshop script, but all that happens is that photoshop comes up and my script is not launched.
    Inside of my Bridge script, I call the executeScript like this:
    var file = new File( "~/Desktop/test.jsx" );
    file.open( "r" );
    var buffer = file.read();
    file.close();
    photoshop.executeScript( buffer );
    And the ~/Desktop/test.jsx file looks like:
    var file = File.openDialog('Image to test');
    var fileRef = new File(file);
    var docRef = open (fileRef);
    If you have any suggestions, please let me know.
    Thank you.
    Evan Appleby
    Sony Pictures Imageworks

    I've never had any success getting photoshop.executeScript to work.
    It's better just to send a bridgetalk message yourself.
    Personally, if you're attempting to do a relatively small operation on a set of files, I would look at the BridgeTalkIterator class in AdobeLibrary1.jsx.
    There is an example of how to use it on AdobeExchange. It's a simple script called "open close" or something like that. You can easily modify it by simply changing the photoshop script to whatever it is you need.
    The benefits - it works around a bridgetalk bug in starting the target application and it also puts up a progress meter in Bridge.
    Bob

  • ProgressDialog background doesn't paint

    I'm working on a Bridge script to copy files from my card reader into a directory structure based on EXIF data. It works (most of the time), but the progress dialog never repaints correctly, and sometimes the progress dialog and the Bridge window go completely white until the script is finished.
    I'm using the progressDialog object from AdobeLibrary1.jsx. When it doesn't go white, the status text and progress bar are updated properly, but the window background is never painted. I've tried window.show() and document.refresh() with no effect. Is there something else I should try?
    Thanks.
    Henry

    Henry,
    This is one we have to live with for now. When bridge scripting is doing anyting intensive (such as copying files), there will be repaint problems. In the Import from Camera script, we flip up a warning dialog that this will happen.
    Larry's idea was worth a try, but it didn't work for me. I've tried a bunch of other ideas as well without success.
    One way that should work, is to use BridgeTalk. Have another application (Photoshop?) actually execute the copy, and send status messages back to bridge. We didn't opt for this in the Import from Camera script as it seemed too kludgy. Users might wonder why Photoshop is starting when all they wanted to do was copy some files.
    If you want to try that - take a look at the BridgeTalkLongProcess Object in AdobeLibrary1.jsx. It allows you to execute a long running process in another app, and get progress reports back to bridge. It provides the progress dialog for you, and handles all of the messaging. All you need to do is put a function call:
    sendBackStatus( progress, message )
    in your target app script code. progress is an integer 1-100, message is what you'd like shown in the progress dialog. An example of how to use it is the Contact Sheet script.
    Good Luck
    Bob
    Adobe WAS Scripting

  • Exploring and Exploiting the Bridge Libraries

    One of the things we did when we developed the Bridge Workflow Automation Scripts, was create a set of libraries to make bridge scripting easier and more productive.
    The libraries are AdobeLibrary1.jsx and AdobeLibrary2.jsx. There is an AdobeLibrary3.jsx, but it's primarily patches for the other two.
    Over the next few weeks, I am going to post some messages about those libraries to help get folks started bridge scripting.
    First up are some file handling utilities.
    getBridgeThumbnails and getBridgeFiles are two library functions that return the selected (in Bridge) Thumbnail objects or File objects. getBridgeFiles takes the output from getBridgeThumbnails and converts them to File objects. These functions also ensure that any Version Cue files that were selected are up to date on the local file system prior to returning the selected objects.
    The definition is:
    getBridgeThumbnails = function( mask, getFolderChildren, filesOnly, firstOnly )
    Where:
    mask is a comma delimited list of file extensions or Mac file type strings. The function will only return Thumbnails that point to files of these types. It defaults to no mask, which will return everything. If the user selected Thumbnails that are not included in the mask, the user will be warned by an alert dialog (the user has the ability to opt not to be warned again).
    getFolderChildren is a boolean. Set to true, it will return the first level children of any selected folder. The concept is that if a user selects a folder in bridge, they can operate the files in that folder. It defaults to true.
    filesOnly is a boolean. Set to true, it will return only files, no folders. It defaults to false.
    firstOnly is a boolean. Set to true, it returns only the first valid file found. This is useful when you are attempting to do an example of the result of one of the selected files. It defaults to false.
    One more thing: If the user has a document open in bridge, but has not selected anything, it will assume the entire contents of the document are desired. It will flip up a warning dialog if this is the case (the user can opt to not be warned again).
    We also extended the File Object in bridge (not the point apps) to do the file filtering for us. Part of that was the creation of a number of standard masks.
    TYPES.PHOTOSHOP
    TYPES.PHOTOSHOP_OPENABLE
    etc.
    var thumbs = getBridgeThumbnails( TYPES.PHOTOSHOP_OPENABLE, true, true );
    for ( var i = 0; i < thumbs.length; i++ ) {
    thumb = thumbs[ i ];
    // do something with the selected thumbnail

    John,
    Thanks.
    I'll try to get some basic examples up here too. I think the docs on Exchange were replaced with a non-read only set. Try downloading them again.
    Next Topic: The basic Bridge Scripting Paradigm
    Bridge being what it is, the typical usage of a script is to select a set of files, then select a menu item to perform some magic on the selected files.
    Scripts, therefore, typically need to create a MenuElement at startup, and then wait patiently for the user to call them.
    There are 2 ways scripts get loaded. The first is by placing them in the startup scripts folder. The best way to find the startup scripts folder is to click the button in Preferences.
    The other way is via Adobe ScriptManager. Script Manager is shipped with the full Creative Suite. It does what it says, pretty much. Provides a way to control what scripts load at startup and what don't. With ScriptManager installed (in startup scripts), it automatically loads scripts in the Workflow Automation Scritps folder (child of startup scripts for the full CS2 installation) and one other folder that is settable by the user.
    The Script Manager also has some nice to have features for scripters. When a user selects a script, the Script Manager displays information provided by the scripter. The information includes stuff like the script's name, description, help, author, website, etc. As a scripter, you should always write your scripts assuming the Script Manager is present and loading your script.
    To do this, the minimum script template is:
    // first is a target directive - tells the extendscript engine that
    // this script should be loaded into bridge. Makes it so that if a
    // user opens the script in Bridge, it will load it rather than
    // display the raw script in the ESTK
    #target bridge
    // next - all point products attempt to load all scripts in the
    // startup scripts folder, if your's is bridge-only, make sure it
    // only loads in bridge by wrapping everything in a condition like
    // this
    if ( BridgeTalk.appName == "bridge" ) {
    // always make a namespace object for your script. Make it something
    // that will not likely be something someone else might use. This
    // avoids possible name collisions between scripts
    myScript = {}; // namespace object for this script
    // next ditty is for the Script Manager
    try {
    myScript.scriptInfo = new ScriptManager.ScriptInfo();
    myScript.scriptInfo.set( "name", "My Script" );
    myScript.scriptInfo.set( "description", "A Cool Script" );
    myScript.scriptInfo.set( "help", "Help text" );
    myScript.scriptInfo.set( "author", "Your Name" );
    myScript.scriptInfo.set( "company", "Your Company" );
    myScript.scriptInfo.set( "copyright", "It's mine and you can't have it );
    myScript.scriptInfo.set( "version", "1.0" );
    myScript.scriptInfo.set( "date", "06-27-2005" );
    myScript.scriptInfo.set( "website", "http://www.adobe.com" );
    } catch ( e ) {
    // Your Script Goes HERE.
    myScript.ui = function( menu ) {
    // this function puts up any UI your script needs, then executes
    // the script
    // create your menu
    var menu = MenuElement.create( "command", "My Menu", "at the end of Tools", "tools/myScript" );
    menu.onSelect = myScript.ui;
    // the last thing for the Script Manager - after your script has
    // loaded, send the script info object to it.
    try {
    ScriptManager.reportLoading( myScript.scriptInfo );
    } catch ( e ) {
    } // closing brace for the if (appName == bridge) condition

  • Executing bridgetalk messages from a modal dialog

    I have a script that runs a BridgeTalkLongProcess from an onClick event within a modal dialog. This worked well in CS2, but not in CS3. The BridgeTalkLongProcess does run, but not until the modal dialog closes. The BridgeTalkLongProcess is attempting to run a process in Photoshop (the target)from Bridge.
    Any tips on how to work around this. Do I have to convert the dialog to a palette? Why the change from the CS2 behavior?
    TIA
    Rory

    Rory,
    I had some more time to investigate this issue today, looking for the underlying bug.
    I now think my first advice (to use a scheduled task) was probably unhelpful--sorry. I have observed the following behavior sending BridgeTalk messages from button onSelect handlers in modal dialogs. If the onSelect handler sends the BridgeTalk message to Photoshop, the message is sent immediatelyy, but the BridgeTalk object's onResult handler is not called until the modal dialog box closes. If the onSelect handler schedules a task to send the BridgeTalk message, then the message is not sent until the dialog box closes.
    I am actually not very familiar with the AdobeLibraryN.jsx scripts, but I took a quick look at the BridgeTalkLongProcess class in the AdobeLibrary1.jsx that was in your zip and it looks to me like it may rely on getting a call to the onResult handler to work as designed. That may be why your script appears to hang--we're waiting on onResult, and that does not execute until the dialog closes.
    For now I reccomend that you try a work-around that will dismiss the modal dialog before you make any BridgeTalk calls to Photoshop.
    Thanks,
    David Franzen
    Quality Engineer
    Adobe Systems, Inc.

  • Buglet in Image Processor.jsx

    I'm not sure how to report this, but there's a bug in the Image Processor script that was driving me nuts so I figured out how to patch it. This may be a Windows-only bug (I'm not sure).
    The problem is that the when you bring up either of the directory pickers for changing the directories in the Image Processor dialog, they both default to the Windows desktop rather than the path that the dialog shows. Since the Windows desktop is a long ways away from where I keep my images, tihs is a lot of mouse clicks to set this directory everytime I want to use it. There is an attempt to pass the directory picker a starting directory, but that code is just wrong. This occurs in two places in the Image Processor. To fix it, I replace this line:
    var selFolder = Folder.selectDialog( strPickDest, this.parent.parent.destLongText );
    with this line:
    var selFolder = Folder.selectDialog( strPickDest, d.destLongText);
    and now the directory picker starts out where it's supposed to and it's a lot quicker to set it to what I want.
    If this has been bugging you, you can patch your own Image Processor.jsx file. Just find the two lines that look like the first line and replace them with the second line.
    And Robert, do you have any idea how to get the real one fixed at Adobe?
    I wonder if this actually works on the Mac. On windows, it takes a chain of 5 parents up (this.parent.parent.parent.parent.parent.destLongText) to make the original way work, but I could imagine that this would be difference on Windows/Mac. Since the real parent has already been resolved with FindWindow right in this same function, I found a safer way to accomplish the goal.
    --John

    >>>I'm not sure how to report this, but there's a bug in the Image Processor script that was driving me nuts so I figured out how to patch it. This may be a Windows-only bug (I'm not sure).
    var selFolder = Folder.selectDialog( strPickDest, this.parent.parent.destLongText );
    with this line:
    var selFolder = Folder.selectDialog( strPickDest, d.destLongText); <<<<br />
    John I did your bugfix, but it did not work in my CS2. I'm still taken to the Desktop. Have you done any further work on this "bug"?
    Thanks,
    Dennis Jacobsen

  • Photoshop Image Processor.jsx could not be found. CS5

    I like to use Bridge to export groups of photos and with past versions I've been able to select photos, go to Tools>Photoshop>Image Process and select one of my custom actions.  Now I get this error: Photoshop Image Processor.jsx could not be found.
    Any thoughts?
    Thanks

    By default the image processor script should be placed in the Application
    folder (on root level, not in the user
    account)/AdobePhotoshop/presets/scripts/ image Processor.jsx
    Also by default in Bridge preferences Start up Scripts Adobe Photoshop
    should have a checkmark in front of it.
    If you changed any of these there lies your fault, if it happened to fail
    out of the blue you first should try restart Bridge holding down option key
    and choose refresh preferences.
    First check if it works now and if it does again set preferences to your
    wishes. (obvious not deselecting the PS script... )
    Now I get this error: Photoshop Image Processor.jsx could not be found.

  • Set top and bottom inset spacing values in Text Frame Options via jsx script

    I am looking for a way to set the top and bottom inset spacing values only to 2 points in Text Frame Options via a .jsx scrpt.
    For years, I have used a script that sets Preferences, such as:
    with(app.storyPreferences){
        opticalMarginAlignment = false;
        opticalMarginSize = 12;                // pts
    I would like to add the code to this same script that would make Top = 0p2 and Bottom 0p2 but leave Left and Right as 0p0.
    Any help would be greatly appreciated.

    Here is the full .jsx file that we now use to set preferences.
    Ideally, this could be modified to include setting any text frame created to have 0p2 inset Top and Bottom, but 0p0 Left and Right:
    //ApplicationTextDefaults
    //An InDesign CS2 JavaScript
    //Sets the application text defaults, which will become the text defaults for all
    //new documents. Existing documents will remain unchanged.
    with(app.textDefaults){
        alignToBaseline = false;        // align to baseline grid
        try {
    //        appliedFont = app.fonts.item("Times New Roman");
            appliedFont = app.fonts.item("Helvetica");
        catch (e) {}
        try {
            fontStyle = "Medium";
        catch (e) {}
        autoleading = 100;
        balanceRaggedLines = false;
        baselineShift = 0;
        capitalization = Capitalization.normal;
        composer = "Adobe Paragraph Composer";
        desiredGlyphScaling = 100;
        desiredLetterSpacing = 0;
        desiredWordSpacing = 100;
        dropCapCharacters = 0;
        if (dropCapCharacters != 0) {
            dropCapLines = 3;
            //Assumes that the application has a default character style named "myDropCap"
            //dropCapStyle = app.characterStyles.item("myDropCap");
        fillColor = app.colors.item("Black");
        fillTint = 100;
        firstLineIndent = "0pt";
    //    firstLineIndent = "14pt";
        gridAlignFirstLineOnly = false;
        horizontalScale = 100;
        hyphenateAfterFirst = 3;
        hyphenateBeforeLast = 4;
        hyphenateCapitalizedWords = false;
        hyphenateLadderLimit = 1;
        hyphenateWordsLongerThan = 5;
        hyphenation = true;
        hyphenationZone = "3p";
        hyphenWeight = 9;
        justification = Justification.leftAlign;
        keepAllLinesTogether = false;
        keepLinesTogether = true;
        keepFirstLines = 2;
        keepLastLines = 2;
        keepWithNext = 0;
        kerningMethod = "Optical";
        kerningValue = 0;
        leading = 6.3;
    //    leading = 14;
        leftIndent = 0;
        ligatures = true;
        maximumGlyphScaling = 100;
        maximumLetterSpacing = 0;
        maximumWordSpacing = 160;
        minimumGlyphScaling = 100;
        minimumLetterSpacing = 0;
        minimumWordSpacing = 80;
        noBreak = false;
        otfContextualAlternate = true;
        otfDiscretionaryLigature = true;
        otfFigureStyle = OTFFigureStyle.proportionalOldstyle;
        otfFraction = true;
        otfHistorical = true;
        otfOrdinal = false;
        otfSlashedZero = true;
        otfSwash = false;
        otfTitling = false;
        overprintFill = false;
        overprintStroke = false;
        pointSize = 6.3;
    //    pointSize = 11;
        position = Position.normal;
        rightIndent = 0;
        ruleAbove = false;
        if(ruleAbove == true){
            ruleAboveColor = app.colors.item("Black");
            ruleAboveGapColor = app.swatches.item("None");
            ruleAboveGapOverprint = false;
            ruleAboveGapTint = 100;
            ruleAboveLeftIndent = 0;
            ruleAboveLineWeight = .25;
            ruleAboveOffset = 14;
            ruleAboveOverprint = false;
            ruleAboveRightIndent = 0;
            ruleAboveTint = 100;
            ruleAboveType = app.strokeStyles.item("Solid");
            ruleAboveWidth = RuleWidth.columnWidth;
        ruleBelow = false;
        if(ruleBelow == true){
            ruleBelowColor = app.colors.item("Black");
            ruleBelowGapColor = app.swatches.item("None");
            ruleBelowGapOverprint = false;
            ruleBelowGapTint = 100;
            ruleBelowLeftIndent = 0;
            ruleBelowLineWeight = .25;
            ruleBelowOffset = 0;
            ruleBelowOverprint = false;
            ruleBelowRightIndent = 0;
            ruleBelowTint = 100;
            ruleBelowType = app.strokeStyles.item("Solid");
            ruleBelowWidth = RuleWidth.columnWidth;
        singleWordJustification = SingleWordJustification.leftAlign;
        skew = 0;
        spaceAfter = 0;
        spaceBefore = 0;
        startParagraph = StartParagraph.anywhere;
        strikeThru = false;
        if(strikeThru == true){
            strikeThroughColor = app.colors.item("Black");
            strikeThroughGapColor = app.swatches.item("None");
            strikeThroughGapOverprint = false;
            strikeThroughGapTint = 100;
            strikeThroughOffset = 3;
            strikeThroughOverprint = false;
            strikeThroughTint = 100;
            strikeThroughType = app.strokeStyles.item("Solid");
            strikeThroughWeight = .25;
        strokeColor = app.swatches.item("None");
        strokeTint = 100;
        strokeWeight = 0;
        tracking = 0;
        underline = false;
        if(underline == true){
            underlineColor = app.colors.item("Black");
            underlineGapColor = app.swatches.item("None");
            underlineGapOverprint = false;
            underlineGapTint = 100;
            underlineOffset = 3;
            underlineOverprint = false;
            underlineTint = 100;
            underlineType = app.strokeStyles.item("Solid");
            underlineWeight = .25
        verticalScale = 100;
    //Units & Increments preference panel
    //Must do this to make sure our units that we set are in points. The vert and horiz
    //units that get set default to the current measurement unit. We set it to points
    //so we can be sure of the value. We'll reset it later to the desired setting.
    with(app.viewPreferences){
        horizontalMeasurementUnits = MeasurementUnits.points;    // Ruler Units, horizontal
        verticalMeasurementUnits = MeasurementUnits.points;        // Ruler Units, vertical
    //General preference panel
    with(app.generalPreferences){
        pageNumbering = PageNumberingOptions.section;    // Page Numbering, View
        toolTips = ToolTipOptions.normal;                    // Tool Tips
    // Not supported in CS4
    //    toolsPalette = ToolsPaletteOptions.doubleColumn;    // Floating Tool Palette
        completeFontDownloadGlyphLimit = 2000;                // Always Subset Fonts...
        try {
            //Wrapped in try/catch in case it is run with CS4 and earlier to avoid the error
            preventSelectingLockedItems = false;                // Needed for CS5+
        catch (e) {}
    //Type preference panel
    with (app.textEditingPreferences){
        tripleClickSelectsLine = true;    // Triple Click to Select a Line
        smartCutAndPaste = true;        // Adjust Spacing Automatically when Cutting and Pasting Words
        dragAndDropTextInLayout = false;    // Enable in Layout View
        allowDragAndDropTextInStory = true;    // Enable in Story Editor
    with(app.textPreferences){
        typographersQuotes = true;            // Use Typographer's Quotes
        useOpticalSize = true;                // Automatically Use Correct Optical Size
        scalingAdjustsText = true;            // Adjust Text Attributes when Scaling
        useParagraphLeading = false;    // Apply Leading to Entire Paragraphs
        linkTextFilesWhenImporting = false;    // Create Links when Placing Text and Spreadsheet Files
    // Missing following (Font Preview Size, Past All Information/Text Only)
    //Advanced Type preference panel
    with(app.textPreferences){
        superscriptSize = 58.3;                // Superscript, size
        superscriptPosition = 33.3;            // Superscript, position
        subscriptSize = 58.3;                // Subscript, size
        subscriptPosition = 33.3;            // Subscript, position
        smallCap = 70;                        // Smallcap
    with(app.imePreferences){
        inlineInput = false;                // Use Inline Input for Non-Latin Text
    //Composition preference panel
    with(app.textPreferences){
        highlightKeeps = false;                    // Keep Violations
        highlightHjViolations = false;            // H&J Violations
        highlightCustomSpacing = false;            // Custom Tracking/Kerning
        highlightSubstitutedFonts = true;    // Substituted Fonts
        highlightSubstitutedGlyphs = false;    // Substituted Glyphs
        justifyTextWraps = false;                // Justify Text Next to an Object
        abutTextToTextWrap = true;                // Skip by Leading
        zOrderTextWrap = false;                    // Text Wrap Only Affects Text Beneath
    //Units & Increments preference panel
    with(app.viewPreferences){
        rulerOrigin = RulerOrigin.spreadOrigin;                    // Ruler Units, origin
    //    These are set at the end of the script after all the changes have been made
    //    horizontalMeasurementUnits = MeasurementUnits.points;    // Ruler Units, horizontal
    //    verticalMeasurementUnits = MeasurementUnits.inches;        // Ruler Units, vertical
        pointsPerInch = 72;                    // Point/Pica Size, Points/Inch
        cursorKeyIncrement = 1;                // Keyboard Increment, Cursor Key
    with(app.textPreferences){
        baselineShiftKeyIncrement = 2;    // Keyboard Increment, Baseline Shift
        leadingKeyIncrement = 2;        // Keyboard Increment, Size/Leading
        kerningKeyIncrement = 20;            // Keyboard Increment, Kerning
    //Grids preference panel
    with(app.gridPreferences){
        baselineColor = UIColors.lightBlue;    // Baseline Grid, Color
        baselineStart = 48;                        // Baseline Grid, Start
        baselineDivision = 6;                    // Baseline Grid, Increment Every
        baselineViewThreshold = 50;                // Baseline Grid, View Threshold
        baselineGridRelativeOption = BaselineGridRelativeOption.topOfPageOfBaselineGridRelativeOption;    // Baseline Grid, Relative To
        gridColor = UIColors.lightGray;            // Document Grid, Color
        horizontalGridlineDivision = 12;    // Document Grid, Horizontal, Gridline Every
        horizontalGridSubdivision = 12;            // Document Grid, Horizontal, Subdivisions
        verticalGridlineDivision = 12;            // Document Gird, Vertical, Gridline Every
        verticalGridSubdivision = 12;            // Document Grid, Vertical, Subdivisions
        gridsInBack = true;                        // Grids in Back
        documentGridSnapto = false;                // snap to grid or not
        documentGridShown = false;                // show document grid
    //Guides & Pasteboard preference panel
    with(app.documentPreferences){
        marginGuideColor = UIColors.violet;                // Color, Margins
        columnGuideColor = UIColors.magenta;            // Color, Columns
    with(app.pasteboardPreferences){
        bleedGuideColor = UIColors.fiesta;                // Color, Bleed
        slugGuideColor = UIColors.gridBlue;                // Color, Slug
        previewBackgroundColor = UIColors.lightGray;    // Color, Preview Background
        minimumSpaceAboveAndBelow = 72;                    // Minimum Vertical Offset
    with(app.viewPreferences){
        guideSnaptoZone = 4;                            // Snap to Zone
    with(app.guidePreferences){
        guidesInBack = false;                            // Guides in Back
    //Dictionary preference panel
    with(app.dictionaryPreferences){
        composition = ComposeUsing.both;    // Hyphenatin Exceptions, Compose Using
        mergeUserDictionary = false;    // Merge User Dictionary into Document
        recomposeWhenChanged = true;    // Recompose All Stories When Modified
    // Missing (Lang, Hyph, Spelling, Double Quotes, Single Quotes)
    //Spelling preference panel
    with(app.spellPreferences){
        checkMisspelledWords = true;                    // Find, Misspelled Words
        checkRepeatedWords = true;                        // Find, Repeated Words
        checkCapitalizedWords = true;                    // Find, Uncapitalized Words
        checkCapitalizedSentences = true;                // Find, Uncapitalized Sentences
        dynamicSpellCheck = true;                        // Enable Dynamic Spelling
        misspelledWordColor = UIColors.red;                // Color, Misspelled Words
        repeatedWordColor = UIColors.green;                // Color, Repeated Words
        uncapitalizedWordColor = UIColors.green;    // Color, Uncapitalized Words
        uncapitalizedSentenceColor = UIColors.green;    // Color, Uncapitalized Sentences
    //Autocorrect preference panel
    with(app.autoCorrectPreferences){
        autoCorrect = true;                            // Enable Autocorrect
        autoCorrectCapitalizationErrors = false;    // Autocorrect Capitalization
    // Missing (Language, Misspelled word pairs)
    //Display Performance preference panel
    with(app.displayPerformancePreferences){
        defaultDisplaySettings = ViewDisplaySettings.typical;    // Preserve Object-Level
        persistLocalSettings = false;
    // Missing (antialiasiing, greek below
    //Story Editor Display preference panel
    with(app.galleyPreferences){
        textColor = InCopyUIColors.black;                // Text Color
        backgroundColor = InCopyUIColors.white;            // Background
        smoothText = true;                                // Enable Anti-Aliasing
        antiAliasType = AntiAliasType.grayAntialiasing;    // Type
        cursorType = CursorTypes.standardCursor;    // Cursor Type
        blinkCursor = true;                                // Blink
    // Missing (Font, Size, Line Spacing & Theme)
    //File Handling preference panel
    with(app.generalPreferences){
        includePreview = true;                        // Always Save Preview Images with Doc
        previewSize = PreviewSizeOptions.medium;    // Preview Size
    with(app.clipboardPreferences){
        preferPDFWhenPasting = false;                // Prefer PDF When Pasting
        copyPDFToClipboard = true;                    // Copy PDF to Clipboard
        preservePdfClipboardAtQuit = false;            // Preserve PDF Data at Quit
    // Missing (Enable Version Cue)
    //    Optical margin (hanging punctuation, outside margins)
    with(app.storyPreferences){
        opticalMarginAlignment = false;
        opticalMarginSize = 12;                // pts
    //Wrap Up (do at end of script)
    //Units & Increments preference panel
    //Must do this to make sure our units that we set are in points. The vert and horiz
    //units that get set default to the current measurement unit. We set it to points
    //so we can be sure of the value. We'll reset it later to the desired setting.
    with(app.viewPreferences){
        horizontalMeasurementUnits = MeasurementUnits.picas;    // Ruler Units, horizontal
        verticalMeasurementUnits = MeasurementUnits.inches;    // Ruler Units, vertical
    //    These two flags are turned off to avoid the error message about
    //    missing image links when InDesign opens an ad. This can especially
    //    be a problem when doing batch processes.
    with(app.linkingPreferences){
        checkLinksAtOpen = false;            // checkbox: true/false
        findMissingLinksAtOpen = false;        // checkbox: true/false

  • Part of Photoshop isn't functioning.  Under adjustments, when HDR toning is clicked on I get a code:  Error 48: File or folder does not exist.  Line:11  - $.evalFile(g_StackScriptFolderPath   "StackSupport.jsx");  How can it be fixed?

    The phone company was here working on something while I was gone.  They sat down at my computer (iMac) and since then HDR toning doesn't work.  Get the code:   Error 48: File or folder does not exist.    Line: 11     ->  $.evalFile(g_StacScriptFolderPatch + "StackSupport.jsx");   How can this be fixed?   

    Go to //Applications/Adobe Photoshop [Version]/Presets/ Scripts/Stack Scripts Only/ and see if StackSupport.jsx is there. If it is not, uninstall and reinstall Photoshop to have it added back in. If it is there, first try recreating the Photoshop Preferences (hold down Command+Option+Shift while launching Photoshop).

  • [CS4/JS] Pnglib.jsx -- A PNG creator function

    After seeing Marc Autret's marvellous pngswatch script, I spent several hours creating PNGs with Photoshop, copying its hex data into Javascript compatible format, finding the relevant color bytes to change ... and all the while I was thinking, "there was an uncompressed PNG format, wasn't there?"
    That's not because I have a bad memory.
    Sure, Marc created his PNG in some other program, saved it as a compressed file, and 'only' changed the palette part in his script -- which involves delving quite deeply into the actual PNG format --, and that's a feasible way of doing the stuff he intended to: change jsut the color. But if you want to actually create a dropdown or listbox image on the fly -- say, for a line widths dropdown --, you have to be able to create an entire image a-new. And PNGs are notoriously difficult to create, because the image pixels themselves are compressed using the very advanced zlib compression.
    But (as I was thinking) ... zlib also allows a "non-compressed" format!
    With some sleuthing I found a couple of hints to get me started, and found a totally useful utility as well: pngcheck, which can take a PNG to bits and tell you what's wrong with it. So, here you have it: a lightweight PNGLIB Javascript, that can create any PNG right out of nothing!
    Any image, apart from the limitations, that is.
    Its main limitation is that you can only create 8-bit palettized PNGs with it. I see no reason to add umpteen functions to cater for the occasional 1-, 2-, or 4-bit or true color PNG, or to add total support for all the different types of transparency that PNG supports. But, hey, its main use is for icons, and you'll have to do with the limits of "just" 256 colors -- or even less than that, if you reserve one or more colors for transparency. On the plus side again, it's total real pixel alpha-level transparency we're talking about (overall that can make your graphics still better than the average '90s DOS game).
    Using the function is easy; at the bottom of the script is an example, but it boils down to:
    Create a string for the palette's colors. Each color is a triplet, in RGB order.
    Create a string for the transparency indexes. Each single entry determines the transparency of the full palette color at that index; the first entry applies to color index #0, the second to color index #1, and so on. The value [00] indicates zero opacity (fully transparent), the value [FF] full opacity. The transparency index string doesn't need to define all of your colors' transparencies; unlisted values are "normal", non-transparent, and if you only need to make color index #0 transparent, you are done right there and then. By the way, the transparency string may be omitted entirely if you don't need it.
    Create a string for the image itself -- wide x high color indexes. Make sure you fill the entire image, 'cause my function will refuse to work if this string length isn't correct.
    Then call my function: myImg = makePng (wide, high, palette, pixels [, transparency]);
    The returned string can be used immediately as a source for a ScriptUI dialog image, or -- less useful, but might come in handy -- be written to a file.
    Tips: hmm. I dunno. Don't use this function to create super-huge PNGs, I guess. The non-compression format uses a couple of checksums on its own, and they are sure to fail on very large images. But, come on, be realistic: it's not a Photoshop replacement we're talking about, it's for icons!
    And Be Kind to Your Users: it's rather overkill to include all of the data for a static PNG image, such as a logo or something. Just create that once, and include the binary data in your script! This function is designed to create PNGs on the fly, from variable rather than static data.
    Before I forget: here it is. Enjoy!
    /****** PngLib.jsx ******/
    /* A Jongware Product -- based *very* heavily, however, upon Marc Autret's pngswatch
    /* script (http://forums.adobe.com/thread/780105?tstart=0), and with further
    /* help from the pages of David "Code Monk" Jones (http://drj11.wordpress.com/2007/11/20/a-use-for-uncompressed-pngs/)
    /* and Christian Fröschlin (http://www.chrfr.de/software/midp_png.html)
    /* Any errors, of course, must have crept in while I wasn't paying attention.
    /* [Jw] 26-Jan-2010
    var makePng = (function()
         // Table of CRCs of 8-bit messages
         var CRC_256 = [0, 0x77073096, 0xee0e612c, 0x990951ba, 0x76dc419, 0x706af48f, 0xe963a535, 0x9e6495a3, 0xedb8832, 0x79dcb8a4, 0xe0d5e91e, 0x97d2d988, 0x9b64c2b, 0x7eb17cbd, 0xe7b82d07, 0x90bf1d91, 0x1db71064, 0x6ab020f2, 0xf3b97148, 0x84be41de, 0x1adad47d, 0x6ddde4eb, 0xf4d4b551, 0x83d385c7, 0x136c9856, 0x646ba8c0, 0xfd62f97a, 0x8a65c9ec, 0x14015c4f, 0x63066cd9, 0xfa0f3d63, 0x8d080df5, 0x3b6e20c8, 0x4c69105e, 0xd56041e4, 0xa2677172, 0x3c03e4d1, 0x4b04d447, 0xd20d85fd, 0xa50ab56b, 0x35b5a8fa, 0x42b2986c, 0xdbbbc9d6, 0xacbcf940, 0x32d86ce3, 0x45df5c75, 0xdcd60dcf, 0xabd13d59, 0x26d930ac, 0x51de003a, 0xc8d75180, 0xbfd06116, 0x21b4f4b5, 0x56b3c423, 0xcfba9599, 0xb8bda50f, 0x2802b89e, 0x5f058808, 0xc60cd9b2, 0xb10be924, 0x2f6f7c87, 0x58684c11, 0xc1611dab, 0xb6662d3d, 0x76dc4190, 0x1db7106, 0x98d220bc, 0xefd5102a, 0x71b18589, 0x6b6b51f, 0x9fbfe4a5, 0xe8b8d433, 0x7807c9a2, 0xf00f934, 0x9609a88e, 0xe10e9818, 0x7f6a0dbb, 0x86d3d2d, 0x91646c97, 0xe6635c01, 0x6b6b51f4, 0x1c6c6162, 0x856530d8, 0xf262004e, 0x6c0695ed, 0x1b01a57b, 0x8208f4c1, 0xf50fc457, 0x65b0d9c6, 0x12b7e950, 0x8bbeb8ea, 0xfcb9887c, 0x62dd1ddf, 0x15da2d49, 0x8cd37cf3, 0xfbd44c65, 0x4db26158, 0x3ab551ce, 0xa3bc0074, 0xd4bb30e2, 0x4adfa541, 0x3dd895d7, 0xa4d1c46d, 0xd3d6f4fb, 0x4369e96a, 0x346ed9fc, 0xad678846, 0xda60b8d0, 0x44042d73, 0x33031de5, 0xaa0a4c5f, 0xdd0d7cc9, 0x5005713c, 0x270241aa, 0xbe0b1010, 0xc90c2086, 0x5768b525, 0x206f85b3, 0xb966d409, 0xce61e49f, 0x5edef90e, 0x29d9c998, 0xb0d09822, 0xc7d7a8b4, 0x59b33d17, 0x2eb40d81, 0xb7bd5c3b, 0xc0ba6cad, 0xedb88320, 0x9abfb3b6, 0x3b6e20c, 0x74b1d29a, 0xead54739, 0x9dd277af, 0x4db2615, 0x73dc1683, 0xe3630b12, 0x94643b84, 0xd6d6a3e, 0x7a6a5aa8, 0xe40ecf0b, 0x9309ff9d, 0xa00ae27, 0x7d079eb1, 0xf00f9344, 0x8708a3d2, 0x1e01f268, 0x6906c2fe, 0xf762575d, 0x806567cb, 0x196c3671, 0x6e6b06e7, 0xfed41b76, 0x89d32be0, 0x10da7a5a, 0x67dd4acc, 0xf9b9df6f, 0x8ebeeff9, 0x17b7be43, 0x60b08ed5, 0xd6d6a3e8, 0xa1d1937e, 0x38d8c2c4, 0x4fdff252, 0xd1bb67f1, 0xa6bc5767, 0x3fb506dd, 0x48b2364b, 0xd80d2bda, 0xaf0a1b4c, 0x36034af6, 0x41047a60, 0xdf60efc3, 0xa867df55, 0x316e8eef, 0x4669be79, 0xcb61b38c, 0xbc66831a, 0x256fd2a0, 0x5268e236, 0xcc0c7795, 0xbb0b4703, 0x220216b9, 0x5505262f, 0xc5ba3bbe, 0xb2bd0b28, 0x2bb45a92, 0x5cb36a04, 0xc2d7ffa7, 0xb5d0cf31, 0x2cd99e8b, 0x5bdeae1d, 0x9b64c2b0, 0xec63f226, 0x756aa39c, 0x26d930a, 0x9c0906a9, 0xeb0e363f, 0x72076785, 0x5005713, 0x95bf4a82, 0xe2b87a14, 0x7bb12bae, 0xcb61b38, 0x92d28e9b, 0xe5d5be0d, 0x7cdcefb7, 0xbdbdf21, 0x86d3d2d4, 0xf1d4e242, 0x68ddb3f8, 0x1fda836e, 0x81be16cd, 0xf6b9265b, 0x6fb077e1, 0x18b74777, 0x88085ae6, 0xff0f6a70, 0x66063bca, 0x11010b5c, 0x8f659eff, 0xf862ae69, 0x616bffd3, 0x166ccf45, 0xa00ae278, 0xd70dd2ee, 0x4e048354, 0x3903b3c2, 0xa7672661, 0xd06016f7, 0x4969474d, 0x3e6e77db, 0xaed16a4a, 0xd9d65adc, 0x40df0b66, 0x37d83bf0, 0xa9bcae53, 0xdebb9ec5, 0x47b2cf7f, 0x30b5ffe9, 0xbdbdf21c, 0xcabac28a, 0x53b39330, 0x24b4a3a6, 0xbad03605, 0xcdd70693, 0x54de5729, 0x23d967bf, 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d];
         // PNG Cyclic Redundancy Code algorithm -- http://www.w3.org/TR/PNG/#D-CRCAppendix
         var crc32s = function(/*uint[]*/buf)
              var c = 0xffffffff, i;
              for( i=0 ; i < buf.length; i++ )
                   c = CRC_256[(c ^ buf.charCodeAt(i)) & 0xff] ^ (c >>> 8);
              return (c ^ 0xffffffff);
         var header = function ()
              return "\x89PNG\x0D\x0A\x1A\x0A";
         var i2s = function (/*int32*/i)
              return String.fromCharCode(i>>>24) + String.fromCharCode(i>>>16) + String.fromCharCode(i>>>8) + String.fromCharCode(i);
         var chunk = function (/*4 Char PNG code*/chunkType, /*data*/data)
              var buf = chunkType + data;
              var crc = crc32s(buf);
              buf = i2s (data.length) + buf + i2s (crc);
              return buf;
         var adler32 = function (/*string*/buf)
              var i, a = 1, b = 0;
              for (i=0; i<buf.length; i++)
                   a += buf.charCodeAt(i); s1 %= 65521;
                   b += a; b %= 65521;
              return (b<<16)+a;
         return function(/*int*/wide, /*int*/high, /*string*/ pal, /*string*/image, /*string*/transpIndex)
              var t, bits;
              if (pal.length % 3)
                   alert ("Bad Palette length -- not a multiple of 3");
                   return null;
              if (image.length != high*wide)
                   alert ("Size error: expected "+(high*wide)+" bytes, got "+image.length);
                   return null;
              bits = '';
              for (t=0; t<high; t++)
                   bits += "\x00"+image.substr(t*wide, wide);
              t = bits.length;
              bits += i2s (adler32(bits));
              var r = header() + chunk ('IHDR', i2s (wide)+i2s(high)+"\x08\x03\x00\x00\x00");
              r += chunk ('PLTE', pal);
              if (transpIndex != null)
                   r += chunk ('tRNS', transpIndex);
              r += chunk ('IDAT', "\x78\x9c\x01"+ String.fromCharCode (t & 0xff)+String.fromCharCode((t>>>8) & 0xff)+String.fromCharCode ((~t) & 0xff)+String.fromCharCode(~(t>>>8) & 0xff)+bits);
              r += chunk ('IEND', '');
              return r;
    /* Sample usage. Remove when #including the above in _your_ script! */
    var pngPal  = "\x00\x00\x00"+"\xff\x00\x00"+"\x00\xff\x00"+"\x00\x00\xff"+"\xff\xff\x00"+"\x40\x40\x40";
    var pngData =     "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"+
                        "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x00"+
                        "\x00\x01\x01\x02\x02\x03\x03\x04\x04\x00"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x01\x01\x02\x02\x03\x03\x04\x04\x05"+
                        "\x05\x05\x05\x05\x05\x05\x05\x05\x05\x05";
    img = makePng (10,11, pngPal, pngData, "\x40");
    var w = new Window("dialog", "Image test");
    w.add ('image', undefined, img);
    var f = new File(Folder.myDocuments+"/test-me2.png");
    if (f.open('w'))
         f.encoding = "BINARY";
         f.write (img);
         f.close();
    } else
         alert ("eh -- couldn't write test file...");
    w.show();

    Here is a more complicated (and useful ) example. (--Its actual usefulness is not as, erm, useful as I hoped, because it seems you don't have access to the built-in stroke styles! If anyone knows a work-around that, let me know ...)
    First, create a few custom Striped and/or Dashed stroke styles; then call this Javascript to see them created "live" in the drop down. Make sure you removed the sample code from the end of "pnglib.jsx", otherwise that dialog with interfere and mess up my nice program.
    #include "pnglib.jsx"
    function createStripeImg (styleIndex)
         var pngPal  = "\x00\x00\x00"+"\xff\xff\xff";
         var pngData = '';
         var x,y, ystart;
         var stripes = [];
         var i;
         for (y=0; y<app.activeDocument.stripedStrokeStyles[styleIndex].stripeArray.length; y++)
              stripes.push (Math.round (11*app.activeDocument.stripedStrokeStyles[styleIndex].stripeArray[y]/100));
         i = 0;
         for (y=0; y<11; y++)
              if (y >= stripes[i])
                   if (y <= stripes[i+1])
                        for (x=0; x<48; x++)
                             pngData += "\x00";
                        continue;
                   i += 2;
              for (x=0; x<48; x++)
                   pngData += "\x01";
         return makePng (48,11, pngPal, pngData, "\xff\x00");
    function createDashImg (styleIndex)
         var pngPal  = "\x00\x00\x00"+"\xff\xff\xff";
         var pngData = '';
         var x,y, xstart;
         var dashes = [];
         var i, len;
         len = 0;
         for (y=0; y<app.activeDocument.dashedStrokeStyles[styleIndex].dashArray.length; y++)
              len += app.activeDocument.dashedStrokeStyles[styleIndex].dashArray[y];
         xstart = 0;
         for (y=0; y<app.activeDocument.dashedStrokeStyles[styleIndex].dashArray.length; y++)
              dashes.push (xstart);
              xstart += Math.round (48*app.activeDocument.dashedStrokeStyles[styleIndex].dashArray[y]/len);
         dashes.push (47);
         i = 0;
         for (y=0; y<11; y++)
              if (y < 3 || y > 8)
                   for (x=0; x<48; x++)
                        pngData += "\x01";
              } else
                   xstart = 0;
                   for (x=0; x<48; x++)
                        if (x >= dashes[xstart])
                             if (x >= dashes[xstart+1])
                                  xstart += 2;
                             pngData += "\x00";
                        } else
                             pngData += "\x01";
         return makePng (48,11, pngPal, pngData, "\xff\x00");
    if (app.activeDocument.stripedStrokeStyles.length+app.activeDocument.dashedStrokeStyles.length < 1)
         alert ("This example needs a few custom stripe or dash stroke styles to play with");
         exit (0);
    var w = new Window("dialog", "Select a stripe type");
    var ddl = w.add("dropdownlist");
    for( i=0; i < app.activeDocument.stripedStrokeStyles.length; i++)
         (ddl.add('item', " "+app.activeDocument.stripedStrokeStyles[i].name)).image = createStripeImg (i);
    for( i=0; i < app.activeDocument.dashedStrokeStyles.length; i++)
         (ddl.add('item', " "+app.activeDocument.dashedStrokeStyles[i].name)).image = createDashImg (i);
    ddl.selection = 0;
    g = w.add ("group");
    g.orientation = 'row';
    g.add ("button", undefined, "OK");
    g.add ("button", undefined, "Cancel");
    w.show();

  • When I try to run a FindChangeByList.jsx in InDesignCS4, it will not let me select a txt file

    Hi all,
    I have a 100 page document that uses two javascript FindChange queries to cleanup an imported XML file. I've been using the same cleanup files for years and they have worked just fine. (I still only open it in CS4 because I've had some issues when trying to use this XML/Find-Change combo in CS5 and 6.) The only difference is my computer has been upgraded, the apps reinstalled, and I am now running 10.9.5
    I can import the XML just fine into my template, but when I double click on FindChangeByList.jsx, select Document, hit OK, nothing happens. I do not get a second dialog box asking me to choose my txt cleanup file.
    I only run this job once a year, so it's possible I am doing something wrong. I've place copies of my txt files in as many scripts folders as I can find on my computer, but they are greyed out in the FIndChange Support folder within InDesign.
    Please help, this is the only way to fix this XML!

    Hi,
    2 things:
    1. Assuming your script is original - it is not asking for a TXT file till it is found in expected location. You can choose between 2 solutions:
         to remove FindChangeList.txt from FindChangeSupport folder ==> script will ask for another file
         to override this file by your query ==> script will not ask but execute your query
    2. You can see greyed TXT files in Script Panel since this panel shows executable files (script's formats)
    Jarek

  • JSX File Type Associations...

    Got a newer machine to work on and I've noticed that when I double-sclick on a JSX script, the script opens up in ExtendScript.  On my old machine, when I double-clicked on a script, it would pop up a confirm dialog asking me if I wanted to run the script and if I clicked OK, it would run the script in whichever application the script was written for (#target illustrator, #target indesign, etc.).  Does anyone know where can re-enable this behavior?

    this is puzzling...
    back a couple of posts...your ESTK version is the latest for CS5, there's no newer version
    what happens if you double click on a script located in the "trusted" folder "adobe scripts"?, under normal circumstances you shouldn't be asked for permission to run the script.

  • How to include ".jsx" file when using Adobe Configurator

    I am trying to include a ".jsx" file so i can use their functions i've written.
    Now when i use:
    #include "filename.jsx"
    i only get an error message when i add the extension in Photoshop CC
    i think the #include statement must have a correct path, or the file won't be found, now my question would be.
    Which path das #include use?
    Or,
    How can i include a .jsx file which is in the xxx.assets Folder within the extension Folder?
    e.g. myScript.jsx inside the myScript.assets Folder, to access a function named myFunction()...

    SQL> set null <<NULL>>
    SQL> select distinct comm from emp
      2  /
        COMM
           0
         300
         500
        1400
    <<NULL>>
    5 rijen zijn geselecteerd.So I probably don't understand the question. Could you post a small test case showing the behaviour you described?
    Regards,
    Rob.

Maybe you are looking for

  • How to use your own database with your users to authenticate in a Web app?

    Hello, everybody! I'm starting to write my first web application and I'm going to use JSF, JPA and EJB3 in this application. One of the first things that I have to do on it is the authentication part where I'll have a page with a user name and a pass

  • How can I allow visitors to my website to search within pdf documents created with Acrobat?

    I honestly had no idea where to place this question. If I should move it to another forum area please just let me know. I have about 200-300 pdf documents on my website and people are able to search by the title of the file but not for items in the b

  • How to debug sales order?

    Hi, I am creating sales order but in the middle only errors occurs how to overcome this? Is there any method for debugging sales order?

  • Problems printing to large paper size

    Hi, Using Acrobat 9 In my work, I use different programs for floorplans and renderings. I send to my Customers the documents as PDF file , and usually the scaled floorplans are in  large paper size (22x34 or up) With one of the CAD programs, all work

  • How to set up xinetd?

    Hey, I got a brand new MacBook Pro and I've never used Mac before. I'm a BSD user, and for Bitlbee I use inetd but I hear Mac uses xinetd and I have never used xinetd before. I have xinetd installed on my Mac, but I have no idea where all the config