Simple beginner script problem

I'm reading Scripting InDesign CS3/4 with Javascript from O'Reilly and this simple example doesn't seem to work. Can someone please see what's up?
Another useful application of split () and join () is processing paragraphs in a text frame. To see how this works, create a new InDesign document; draw a text frame big enough to hold about half a dozen names; and type a list of half a dozen names, one a line. Select the text frame or place the cursor somewhere in the list. The following script sorts the list alphabetically:
// check that a story is selected
if (app.selection[0].parentStory.constructor.name!="Story")
exit ( );
// create an array of paragraphs by splitting the story on hard returns
myArray = app.selection[0].parentStory.contents.split ("\r");
// sort the array
myArray.sort ( );
// join the array as one string separated by hard returns
myString = myArray.join ("\r");
// replace the contents of the selected story with myString
app.selection[0].parentStory.contents = myString;

It highlights
if (app.selection[0].parentStory.constructor.name!="Story")
and says undefined is not an object
Edit: solution, I had to choose Adobe InDesign CS5 from the ESTK menu instead of ESTK CS5

Similar Messages

  • Simple shell script problem...

    I am trying to get a list of directories on a remote machine, compare them with the directories on the local machine and copy any that dont match on the local machine to a backup folder. Heres my code but i am a newbie and i cant get my shell script to read from a file. The for loop never executes so i am guessing i am not reading the file correctly - see below.
    #!/bin/ksh
    ssh -l removeserver 192.168.xxx.xxx ls /remote/server/directory/ > /store/remote/directory/listing/motapp1files.txt
    newfile=''
    $newfile < /store/remote/directory/listing/motapp1files.txt
    for file in $newfile;
    do echo $file
    if [ ! -d local/machine/directories/$file/ ]; then
    echo "this folder doesnt exist on on remote server "; echo $file;
    fi
    done

    Re-inventing the wheel perhaps. Look into rsync. Great program!
    I used it in FreeBSD to do a very similar task.

  • Scripting problems with pipes!

    Hi Boardies!
    I'm working on a script to automatically generate PKGBUILDs for my custom kernels (For my 3 systems I need 3 custom kernel packages).
    Each PKGBUILD needs the md5 checksum block, which I can generate with "makepkg -c > PKGBUILD".
    Here is the problem
    This command writes the checksums at the end of the PKGBUILD file. This isn't a clean solution. The checksums should wrote before the "build()" function.
    Because of that I need a trickly bash command, which search (grep maybe?) the "build() "-line and writes the md5-checksum block before that line.
    I tested around with egrep, but I can't isolate the line-number of "build()" and I don't know how to paste the md5-checksums be at the position (line - 1)!
    I hope somebody can help me. Thanks for your answers
    Best regards,
    Flasher

    A simple perl script would be appropriate.  The easiest way to approach this problem (actual perl programmers feel free to correct me) is to do the following:
    iterate over the file, pulling each line into a string appended to an array
    iterate over the array, printing each line.  If build() is matched, print md5sum, then the line.
    write the corrected file to stdout
    Here's one I called test.pl
    #!/usr/bin/perl
    #Add MD5SUM to file
    #Read from stdin into @file
    while (<>) {
    chomp;
    push(@file, $_);
    foreach my $a (@file) {
    if ($a =~ /build\(\)/) {
    print "MD5SUM\n";
    print "$a\n";
    Then the following command:
    cat PKGBUILD | ./test.pl > temp
    mv temp PKGBUILD
    Produces an identical PKGBUILD with the word MD5SUM printed on the line above build().

  • Simple button script not working

    I am using AS2 and need help figuring out why this simple button script is not working:
    stop();
    buttonWS1.onRelease = function(){
                        gotoAndStop("Stage1and2_Boss",4);
    buttonWS2.onRelease = function(){
                        nextFrame();
    //end
    My buttons are the square letter-puzzles below. They are images that I converted to "symbols" (specifically, buttons). I put their names as above (buttonWS1, buttonWS2, etc.) in the "instance names" boxes.
    I have no idea what is going on. Please help!

    Hi -
    1. Yes, buttonWS2 is the instance name
    2. The only code attached to it is the code I pasted above.
    3. onRelease does not execute because my trace statement does not appear in the output
    Here is the modified code for buttonWS2:
    buttonWS2.onRelease = function(){
                        trace("clicked!");
                        nextFrame();
    Question: It shouldn't matter if I have commented-out code within that set of codes should it?:
    buttonWS2.onRelease = function(){
              //if (puzzleschosenarray[0] == 2 || puzzleschosenarray[1] == 2) {
              // cannot be chosen -- make button non-functional
              //else{
                        //puzzleschosenarray[roundnumber-1] = 2;
                        trace("clicked!");
                        nextFrame();

  • SIMPLE Database Design Problem !

    Mapping is a big problem for many complex applications.
    So what happens if we put all the tables into one table called ENTITY?
    I have more than 300 attributeTypes.And there will be lots of null values in the records of that single table as every entityType uses the same table.
    Other than wasting space if I put a clustered index on my entityType coloumn in that table.What kind of performance penalties to I get?
    Definition of the table
    ENTITY
    EntityID > uniqueidentifier
    EntityType > Tells the entityTypeName
    Name >
    LastName >
    CompanyName > 300 attributeTypes
    OppurtunityPeriod >
    PS:There is also another table called RELATION that points the relations between entities.

    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    check the coloumn with WHERE _entityType='PERSON'
    as there is is clustered index on entityType...there
    is NO performance decrease.
    there is also a clustered index on RELATION table on
    relationType
    when we say WHERE _entityType ='PERSON' or
    WHERE relationType='CONTACTMECHANISM'.
    it scans the clustered index first.it acts like a
    table as it is physically ordered.I was thinking in terms of using several conditions in the same select, such as
    WHERE _entityType ='PERSON'
      AND LastName LIKE 'A%' In your case you have to use at least two indices, and since your clustered index comes first ...
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
    Have you ever thought of using constraints in your
    modell? How would you realize those?
    ...in fact we did.We have arranged the generic object
    model in an object database.The knowledge information
    is held in the object database.So your relational database is used only as a "simple" storage, everything has go through your object database.
    But the data schema is held in the RDBMS with code
    generation that creates a schema to hold data.If you think that this approach makes sense, why not.
    But in able to have a efficent mapping and a good
    performance we have thought about building only one
    table.The problem is we know we are losing some space
    but the thing is harddisk is much cheaper than RAM
    and CPU.So our trade off concerated on the storage
    cost.But I still wonder if there is a point that I
    have missed in terms performance?Just test your approach by using sufficiently data - only you know how many records you have to store in your modell.
    PS: it is not wise effective using generic object
    models also in object databases as CPU cost is a lot
    when u are holding the data.I don't know if I'd have taken your approach - using two database systems to hold data and business logic.
    PS2: RDBMS is a value based system where object
    databases are identity based.we are trying to be in
    the gray area of both worlds.Like I wrote: if your approach works and scales to the required size, why not? I would assume that you did a load test with your approach.
    What I would question though is that your discussing a "SIMPLE Database Design" problem. I don't see anything simple in your approach when it comes to implementation.
    C.

  • Tidy -- simple python script to clean annoying files and directories

    Hi all,
    recently I opened a much-used flash drive and there was a lot of files like Thumbs.db, Mac OS' ._*, .DS_Store, etc all over it, making using it really annoying.
    So I decided to mimic a simple utility I saw as a plugin in Rockbox, which takes all of these files and deletes them.
    The result is a simple python script which you can find at:
    http://github.com/houbysoft/short/blob/master/tidy
    Usage should be self-explanatory. Be warned, by default, it deletes everything that matches the regular expressions without warning (this should be fine though, so if you want to be safe, try the -s and -v (simulate, verbose) or -p (prompt) options first.
    As usual, any feedback is welcome, and if you know of other files it should clean, please post them here!

    Hi all,
    recently I opened a much-used flash drive and there was a lot of files like Thumbs.db, Mac OS' ._*, .DS_Store, etc all over it, making using it really annoying.
    So I decided to mimic a simple utility I saw as a plugin in Rockbox, which takes all of these files and deletes them.
    The result is a simple python script which you can find at:
    http://github.com/houbysoft/short/blob/master/tidy
    Usage should be self-explanatory. Be warned, by default, it deletes everything that matches the regular expressions without warning (this should be fine though, so if you want to be safe, try the -s and -v (simulate, verbose) or -p (prompt) options first.
    As usual, any feedback is welcome, and if you know of other files it should clean, please post them here!

  • SIMPLE login script install of zfd4 agent?

    Is there is simpler way of installing the zfd4 agent via a login script when
    I'm not using an intermediate tier or use the application explorer. The
    login script examples I've found onlnie (and information in the Novell docs
    and Novel Press books) seem complex and frought with pitfalls...
    Thanks,
    KB

    > I'm reviewing this TID; I may be able to do this on my own. However, if
    > anyone has an example, working "simple" login script they could post as
    an
    > example, it would be REALLY appreciated....
    >
    > Thanks!
    > KB
    > "KB" <[email protected]> wrote in message
    > news:mHgfg.738$[email protected]..
    > > Forgot to mention - I want to run this in silent mode, and need to
    handle
    > > the issue where someone already has the agent installed...
    > >
    > > Thanks,
    > > KB
    > >
    > > "KB" <[email protected]> wrote in message
    > > news:Dfgfg.703$[email protected]..
    > >> Is there is simpler way of installing the zfd4 agent via a login
    script
    > >> when I'm not using an intermediate tier or use the application
    explorer.
    > >> The login script examples I've found onlnie (and information in the
    > >> Novell docs and Novel Press books) seem complex and frought with
    > >> pitfalls...
    > >>
    > >> Thanks,
    > >> KB
    > >>
    > >
    > >
    >
    >
    Hi,
    your Login Script must be seen like this:
    #z:exist c:\programme\novell\zenworks\nalwin32.exe
    if "%ERRORLEVEL"="0" THEN GOTO NOTHING
    #z:\zfdagent\agent.bat
    NOTHING:
    END
    the agent.bat is a batch File to install the agent in silent mode
    it looks like that:
    msiexec /i z:\zfdagent\zfdagent.msi /qn ADDLOCAL=ALL EDITABLE_MT_ADDRESS=1
    STARTUP_APPWINDOW=1 STARTUP_APPEXPLORER=0 REBOOT=ReallySuppress /l*v %
    WINDIR%\zfdagent.log
    the z:\zfdagent is a subdirectory in the sys:\system\Public where
    zfdagent.msi file exists.
    hier is a link to download exist.exe
    Download: http://www.novell.com/coolsolutions/...oads/exist.zip
    Best regards
    Issam

  • Saved File Groups Issue in Bridge Center - script problem?

    Hi all,
    I tried posting this in the Bridge forum with no replies. After browsing through this forum I'm wondering if this is a script problem?
    I have the CS2 premium, and use all packages. The problem I have is saving and retrieving files in the 'Saved File Groups' of Bridge Center. I can save Photoshop files no problem, but the idea is to be able to save other files from open applications in the group and then to recall them later. I can save Illustrator files with others in a group but only Photoshop files open, and it ignores the saved Illustrator files.
    With my InDesign files, it does not even recognise them as files to be saved. I can have a file open, click on "Save open files into a file group" and it will come up with a little box saying there are no open files to save!
    OS - XP sp2. Bridge 1.0.2
    If this can be helped with scripting, please explain clearly, I am a graphic designer and no very little indeed about scripting.
    Your help would be appreciated.
    Thanks,
    Thysje Arthur

    Hi,
    Do you mean that Windows displays “Network Shortcuts” folder when you click “Browse” icon? If so, please check if you configure the default local file location to the “Network Shortcuts” folder. You could refer to the image below to find the option of the default
    local file location.
    Best Regards,
    Mandy 
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • Simple Resizing Script - Hopefully better eyes will prevail

         I'm working on a simple resizing script to incrementally resize an image in 5% steps up to the set limits as defined by the variables; newImageHeight & newImageWidth.   I'm currently running this script in Photoshop CS4 on an Intel Mac.
         The script works fine for horizontal format images but vertical images scale incrementally in significantly larger steps than 5% and the final output is well above the limit set by the variable "newImageHeight".
         I'm sure it's something simple that I've just overlooked.  Any help would be most appreciated.
    TIA
    #target photoshop
    //  Sets Adobe Photoshop to use pixels and display no dialogs.
    app.preferences.rulerUnits = Units.PIXELS;
    var doc = app.activeDocument;
    var imageFormat;
    var newImageHeight = 4000;  //  Sets the new image height to 4000 pixels.
    var newImageWidth = 2880;  //  Sets the new image width to 2880 pixels.
    if (doc.height.value > doc.width.value){  //  Determines whether the image is vertical or horizontal in format.
         imageFormat = 1;
         }else{
         imageFormat = 2;
    if (imageFormat == 1) {
         alert("Re-Scale Portrait Format");
         while (doc.height.value < (newImageHeight * 0.923550372529964)){
              alert(doc.height.value);
              doc.resizeImage (doc.height * 1.05), ResampleMethod.BICUBIC;
         alert(doc.height.value);          
         doc.resizeImage (doc.height * (1 / (doc.height / newImageHeight))), ResampleMethod.BICUBIC;
         }else{
              alert("Re-Scale Landscape Format");
              while (doc.width.value < (newImageWidth * 0.923550372529964)){
              alert(doc.width.value);
              doc.resizeImage (doc.width * 1.05), ResampleMethod.BICUBIC;
         alert(doc.width.value);     
         doc.resizeImage (doc.width * (1 / (doc.width.value / newImageWidth))), ResampleMethod.BICUBIC;
    //  EOF

    Check resizeImage out the Object Model Viewer in ESTK.
    Document.resizeImage (width: UnitValue , height: UnitValue , resolution: number , resampleMethod: ResampleMethod )
    So I think the line
              doc.resizeImage (doc.height * 1.05), ResampleMethod.BICUBIC;
    should rather be
              doc.resizeImage (doc.width * 1.05, undefined, undefined, ResampleMethod.BICUBIC);
    or
              doc.resizeImage (undefined, doc.height * 1.05, undefined, ResampleMethod.BICUBIC);
    What is the Script supposed to achieve anyway?
    It’s not based on the obsolete concept of incremental resizing for better results, is it?

  • A simple "sudo" script

    Hi, I wrote a simple "sudo" script for people who prefer to use su rather than sudo.
    #!/bin/bash
    while [ -n "$1" ]
    do
    command="${command} $1"
    shift
    done
    su -c "$command"
    Usage:
    put it in /usr/sbin, then for example, do
    sudo pacman -Sy
    Password:
    enter root password
    Advantages:
    for those who don't like sudo, this sudo script is convenient for one line commands
    simple bash completion
    Hope you find it useful

    Xilon wrote:Couldn't you just do:
    alias sudo='su -c'
    That would require you to manually put ' ' around your command, and miss bash completion.
    mucknert wrote:Uh. sudo allows a much finer selection of rights. You can say what user or group is allowed to execute with its own password (or no password at all) instead of the root pw. That's a lot more than your script does and those are good reasons, too. Read up on sudo one day. You will be suprised.
    Thanks for your suggestion, I just had a quick read through sudo and sudoers. This is some stuff I found:
    The time stamp issue was never a big one, and you can configure the time or disable it. I find sudo -k useful too.
    I thought sudo might add security risk if the user password was compromised, but you can configure sudo to ask for the root password. However, this would defeat the purpose for those who disable root.
    I also have a questions: if you want to do access control, why would you prefer sudo over simple file permissions? Or is sudo primarily used as a finer access control scheme?
    Again, thanks for your advice, I really appreciate it. Please point out anything wrong with my questions. The manual was pretty long, so I'm bound to miss something.

  • When I try to go to icloud I get 'script problem' and cannot enter. Could someone please advise me what to try. Thanks.

    When I try to go to ilcoud I get 'script problem' and can't enter. Please advise what I should try. Thanks.

    I use e-trade and a couple of times, years back, I found them behind the Java updates.
    So, now I install new Java platforms on my backup disk and test the streaming data on that first because I know it will be over-written that evening with my nightly backup.
    Of course, since I began doing that there hasn't been a problem. Do the same with printer driver updates.
    Anyway, call ScottTrade and howl! Tell them how many Macs are out there and why aren't they in Apple Developers Program?

  • OS X Lion - JAVA SCRIPT PROBLEM

    I recently updated from Snow Leopard to OS X Lion. Now I seem to have a JAVA Script problem. Where do I start fixing this issue. I have checked updates etc etc but it seems to be updated. However, when I login to my web site backend, I have a problem. Any advice please?

    Would you please write some more details? explain the problem and what web site backend you use. Thanks.

  • Help with simple Automator script

    I have a simple Automator script for updating a specified folder with files from another folder. It consists of only two actions:
    1. Get Folder Contents (from the folder I drop on the Automator executable).
    2. Copy Finder Items.
    I left the option "replace existing files" unchecked because there's no point in replacing a bunch of files that already exist (we're talking about 4000-5000 files in the source folder).  I assumed that meant to ignore any existing files but, on the contrary, I found out that the script is copying duplicates of all the existing files -- making my target folder about 9000 files strong!
    How do I get a command into the middle of this script to restrict the Copy Finder Items command to files that do not already exist in the target folder? (It would be even nicer if it could check for files that are older than the files being copied and actually replace (only) those as well.)
    Any ideas?

    If you need the Terminal window to stay open, then you're looking at scripting Terminal. You can do this with Automator's run applescript action, or you can just use Script Editor (in Applications > AppleScript). Either way you will need to save the workflow/script as an application and drag it to your Login Items (in System Preferences > Accounts).
    click here to open this script in your editor<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:400px">tell application "Terminal"
    activate
    set commands to "cd /Users/lenny/ventrilo/ 
    /Users/lenny/ventrilo/ventrilo_srv"
    do script commands in front window
    end tell</pre>
    PowerMac G5 (June 2004) 2x1.8GHz 1.25GB, PowerBook G4 (12-inch DVI) 1x1GHz 768MB   Mac OS X (10.4.3)  

  • Simple bash scripting help needed..

    I want to learn som simple bash scripting in order to automate various tasks.. Im totally noob, so bear with me
    First of all I would like to set configs without using nano.. is there a simple command for this? For example if i want change my hostname in /etc/rc.conf.. how can i print the current vallue and how can i change it`?
    i was thinking something like this to get the current value:
    # cat /etc/rc.conf | grep HOSTNAME=
    which returns HOSTNAME="myhostname"
    how can i change this value with one or more commands whitout touching the rest of the file?

    abesto wrote:
    A slightly naive solution:
    CHOICE="lisa"
    NAMES="homer marge lisa bart maggie"
    if [ "`echo \" $NAMES \" | grep \" $CHOICE \"`" ]; then
    echo "this is how you do it"
    fi
    The extra spaces inside the escaped quotes are to ensure that only a whole word is "matched".
    You can also replace the elif's with a loop through a list of "the other variables". Then you'd use the loop variable instead of $CHOICE above.
    grep can check on word-bounderies with \< and \>, or with the -w switch. The -q switch suppresses any messages and exits with exit-code 0 when the first match is found:
    if echo "${NAMES}" | grep -qw "${CHOICE}"; then
    Nice and readable, should work, but i haven't tested it
    EDIT:
    Procyon wrote:CHOICE="lisa"
    NAMES="homer marge lisa bart maggie"
    if [[ $NAMES =~ $CHOICE ]]; then echo match; fi
    This one also matches elisa, ie. no check on word bounderies. You should be carefull with that
    Last edited by klixon (2009-04-23 09:40:22)

  • Solaris 11 - run a simple BASH script on computer startup

    I need to have a simple BASH script run on my Solaris 11 machine automatically whenever the computer (re)starts. It should be run with root permissions and after the computer has fully booted. What is the easiest way to do that?
    Thank you
    Dusan

    Hi user9368043
    Yes, that should be right, and be intended this way.
    See /etc/rc3.d/README and the following part from smf(5):
    Legacy Startup Scripts
    Startup programs in the /etc/rc?.d directories are executed
    as part of the corresponding run-level milestone:
    /etc/rcS.d milestone/single-user:default
    /etc/rc2.d milestone/multi-user:default
    /etc/rc3.d milestone/multi-user-server:default
    Your question concerning upgrading to Solaris 11.1:
    In the Gnome menus, you should look for (and start)
    System --> Administration --> Update Manager
    Let it do its work. It will give you a new boot environment, containing Solaris 11.1. Possibly, you have to perform upgrading twice. With "beadm activate", see beadm(1M), you can go back to Solaris 11.0 whenever you want.
    "Local" parts of your zfs root pool, like /usr/local, home directories, /root, and so on, should be in separated file systems, and be mounted outside the root pool before upgrading. They are availlable then from any boot environment, and will not be duplicated. See more in zfs(1M), zpool(1M).
    I strongly recommend upgrading. Solaris 11.1 is great.

Maybe you are looking for

  • Webcam Video pauses when recording sound from microphone

    I have a strange problem which i am encountering when recording and playing back webcam video. I am developing a small application for recording webcam video and audio using FMS and playing it back later from FMS. I am using AS 3.0, FMS 3.5 and flash

  • Blue Ray not supported in OSX

    Why is Blue Ray not supported?? Can someone from Apple please address this....and hopefully someday this will be rectified.

  • Multi provider not active

    hi folks, when i try to activate my multiprovider with 2 basic cubes it is giving a message "the data target is not saved as active". plz could someone help me out with the issue. regards, axel

  • Cant change itunes from nano to classic

    I recently purchased an ipod classic, I deleted itunes and redownloaded it in order to start out fresh. When I opened my new itunes a screen pops of with the 3 different ipods and says "Lets get started" after I select register a screen of agreement

  • How to in a transaction catch values of Query and use in another

    hello, i have several dropboxes in a screen the user select values and then press the button "Insert Data" ....at the first view could be an simple Sql Insert but before i have to do some sql queries with the values that the user select for example..