27 Replies Latest reply on Dec 4, 2008 5:23 PM by Roy McCoy

    Pausing AppleScript

    Roy McCoy Level 1
      I want to manually select text in the middle of an InDesign AppleScript in order to do a find/replace operation on the selection. Searching the web last night I found the following in the Photoshop Scripting Archive:

      *****

      tell application "Adobe Photoshop CS2"
      activate
      tell current document
      -- Do stuff...
      -- Do stuff...
      -- Do stuff...
      if my askUserToCrop() then -- Only continue if the user hit Continue
      activate -- Bring PS back to the front
      -- Continue...
      -- Do stuff...
      -- Do stuff...
      end if
      end tell
      end tell

      on askUserToCrop()
      activate me -- Bring the script to the front
      set theDialog to display dialog "Go back to Photoshop and crop the image. Return here and select Continue when ready."
      buttons {"Cancel", "Continue..."} default button 2
      with icon note giving up after 600 -- Give the user enough time to crop.
      if (button returned of theDialog = "Cancel") or (gave up of theDialog = true) then
      return false
      else
      return true
      end if
      end askUserToCrop

      *****

      I copied this to my script and adapted it slightly, and I remember that for a while it worked. I don't know what I did to change that, but in any event it isn't working now. When I try to click on my InDesign document window and do something, I just get a beep, and I believe I now see the InDesign CS4 icon in the pause window, where I don't think it was before. The only other thing I remember is that for some reason it seemed necessary to move the subroutine outside of the main tell statement (I reveal my ignorance and lack of experience here, I know - sorry), and maybe this was when it stopped working. If it was working at that point, though, I don't suppose I would have felt that I had to move it out of the tell statement.

      Here's the subroutine, now below "end tell" in the script:

      *****

      on doYourThing()
      activate me -- Bring the script to the front
      set theDialog to display dialog "Perform required function." buttons {"Cancel", "Continue"} default button 2 with icon note giving up after 600 -- So be there and don't wait forever.
      if (button returned of theDialog = "Cancel") or (gave up of theDialog = true) then
      return false
      else
      return true
      end if
      end doYourThing

      *****

      And here's how I call it from within the tell statement:

      *****

      if my doYourThing() then
      activate
      end if

      *****

      Thanks to anyone who can indicate what's wrong here.... Well durn, now it's working again! I just have to use cmd-tab to get back to the Script Editor alert rather than clicking on a Script Editor window. So now it's (again) showing the Script Editor icon rather than the InDesign icon. This suggests that it has to do with how the script is launched, and this indeed turns out to be the case. If I run the script from Script Editor, the alert shows the Script Editor icon and I can play around with my document before hitting Continue. If I run it from the InDesign scripts palette, however, the alert shows the InDesign icon and I can't. I suppose there's a simple explanation for this and I'd appreciate it if someone could tell me what it is. Also appreciated would be a way to script such a pause in a script run from the scripts palette, given the convenience of triggering scripts in this way.

      Roy McCoy
      UEA, Rotterdam
        • 1. Re: Pausing AppleScript
          sstanleyau Level 4
          On 26/11/08 4:56 AM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> If I run it from the InDesign scripts palette, however, the alert shows the<br />> InDesign icon and I can't. I suppose there's a simple explanation for this and<br />> I'd appreciate it if someone could tell me what it is.<br />> <br />The dialog is run from whatever application is running the script; if you<br />want to specify a particular app, wrap the dialog in a tell construct. The<br />reason you can't do anything when it's run from ID is because it's a modal<br />dialog -- that's what modal means: put it in a mode where nothing can be<br />done until the dialog is dismissed. But if you make it a Script Editor<br />dialog, then you're free to do stuff in ID while the dialog is up.<br /><br />> Also appreciated would be a way to script such a pause in a script run from<br />> the scripts palette, given the convenience of triggering scripts in this way.<br />> <br />You can't, really -- you'd need some sort of non-modal dialog.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
          • 2. Re: Pausing AppleScript
            Roy McCoy Level 1
            You can't, really -- you'd need some sort of non-modal dialog.

            Okay, so I'm trying to wind up this sequence of scripts with one last
            one for all the remaining things that I can do, and another one for
            those I can't do and announce a pause for. I suppose there isn't much
            sense in putting the latter in a script when I can read them just as
            well in a text file, but I'm trying in principle to script as much as
            possible and so will try to stick with this for the time being.

            I got stuck on one of the can-do things, not because I couldn't do it
            but because I couldn't do it in the way I wanted to. I had this text
            (non-Helvetica symbols deleted):

            FD (medicino; eldonado): d-ro Zheng Bocheng, profesoro pri medicino,
            Haidianqu Huayuan Beilu Tayuan Xiaoqu, Yingchunyuan 4 Haolou 4 Men 403-
            Shi, 100083 Beijing; [h](010) 62046942, [of](010) 64210081, [of](010)
            64260067 redaktoro de Granda Äina Enciklopedio (medicina vol.).

            The job here was to move his second profession after his first one,
            this being necessary owing to space limitations in our old database. I
            did it with this:

            set find what of find text preferences to " redaktoro de Granda Äina
            Enciklopedio (medicina vol.)"
            set change to of change text preferences to ""
            set theFinds to find text document 1
            select item 1 of theFinds
            set zoom percentage of layout window 1 to (get zoom percentage of
            layout window 1)
            display dialog "Got Bocheng second profession?" buttons {"Yes", "No",
            "Cancel"} default button "Yes"
            if button returned of result is "Yes" then
            cut selection
            set find what of find text preferences to "Bocheng, profesoro pri
            medicino, "
            set change to of change text preferences to "Bocheng, profesoro pri
            medicino, redaktoro de Granda Äina Enciklopedio (medicina vol.), "
            set theFinds to find text document 1
            select item 1 of theFinds
            set zoom percentage of layout window 1 to (get zoom percentage of
            layout window 1)
            display dialog "Got Bocheng first profession?" buttons {"Yes", "No",
            "Cancel"} default button "Yes"
            if button returned of result is "Yes" then
            change text selection
            end if
            end if

            What I wanted to do, as indicated by my cutting rather than deleting,
            was to use the clipboard contents in the replace. This, however,
            didn't work:

            set change to of change text preferences to "Bocheng, profesoro pri
            medicino," & "^c" & ", "

            Ooh, but maybe I don't have to concatenate that... yeah,

            set change to of change text preferences to "Bocheng, profesoro pri
            medicino,^c, "

            works and I'll use that. But let me ask: How would I script placing
            the insertion point (1) after a found selection? (2) before it?
            And (3) how do I script simply moving the text cursor a character,
            word, etc. to the left or the right? I didn't have any problem with
            this in PM scripting, but I can't find anything on moving the text
            cursor in a script. There may, furthermore, be an explanation of the
            mysterious "insertion point -1", but I can't find it. Insertion point
            1 seems to be the beginning of a story or text frame or whatever, and
            it says somewhere that insertion point -2 is the last character before
            the return at the end of a paragraph, but there doesn't seem to be an
            explanation of the general system. The thing about insertion point -2
            seems to suggest that insertion point -1 would be the return itself,
            but generally insertion point -1 simply seems to indicate where the
            cursor is. I don't know why it's called insertion point -1, then. Just
            plain "insertion point" would be nice, but I guess it needs a number.


            Thanks,

            Roy McCoy
            Rotterdam, NL
            • 3. Re: Pausing AppleScript
              Roy McCoy Level 1
              I'm continuing to be hurting from not knowing how to deselect text
              ("select none", which I've seen and which sometimes works, tends to
              give me "Adobe InDesign CS4 got an error: Invalid value for parameter
              'selectable items' of event 'select'. Expected object, list of
              objects, nothing or all, but received none."), move the text cursor,
              etc. The next thing on my list is to insert a certain line of text at
              the end of the Denmark section, right before Dominican Republic. I can
              find "DOMINIKA", but then what? I'd like to deselect it with the
              cursor on the left, back up one char to the end of the preceding
              entry, enter a return, set the desired paragraph style and add the
              text. But I don't know how to deselect the found text and then move
              the cursor back.

              I ordered a copy of Shirley Hopkins' AppleScripting InDesign book
              today, by the way, and hope it will get me a little up to speed on
              basic stuff like this. The Adobe documentation doesn't seem to be
              doing it for me, and if the answers are in the application dictionary
              I still haven't figured out how to find them. I looked at the blue C's
              in all the suites that seemed plausible, and didn't find anything
              about moving the insertion point.


              Thanks,

              Roy McCoy
              Rotterdam, NL
              • 4. Re: Pausing AppleScript
                sstanleyau Level 4
                On 28/11/08 1:31 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> What I wanted to do, as indicated by my cutting rather than deleting,<br />> was to use the clipboard contents in the replace.<br /><br />Why not forget copy and paste and use the move command.: "omev oneTextRef to<br />after[or before} anotherTextRef".<br /> <br />> works and I'll use that. But let me ask: How would I script placing<br />> the insertion point<br /><br />You're going to confuse yourself with that terminology: you're moving the<br />*selection* -- an insertion point is the gap between/before/after a<br />character.<br /><br />> (1) after a found selection?<br /><br />        set selection to insertion point -1 of selection<br /><br />> (2) before it?<br /><br />        set selection to insertion point 1 of selection<br /><br />> And (3) how do I script simply moving the text cursor a character,<br /><br />        set selection to insertion point before selection<br /><br />> I didn't have any problem with<br />> this in PM scripting, but I can't find anything on moving the text<br />> cursor in a script.<br /><br />That's because ID scripting is nothing like PM scripting. In PM, you<br />essentially drove the interface; in ID, you use a different interface, so on<br />the whole you just act on things rather than selecting them, and you get and<br />set variables rather than cut and paste. it's a different way of viewing the<br />document.<br /><br />> but generally insertion point -1 simply seems to indicate where the<br />> cursor is.<br /><br />No it doesn't; you're confusing it with selection.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                • 5. Re: Pausing AppleScript
                  Roy McCoy Level 1
                  On Nov 28, 2008, at 4:22 AM, Shane Stanley wrote:

                  > Why not forget copy and paste and use the move command.: "omev
                  > oneTextRef to
                  > after[or before} anotherTextRef".

                  The glib reply would be because ^c finally worked and because I don't
                  understand text references or how to move them, but I think I can get
                  a handle on this movin' business, thanks.

                  >> works and I'll use that. But let me ask: How would I script placing
                  >> the insertion point
                  >
                  > You're going to confuse yourself with that terminology: you're
                  > moving the
                  > *selection* -- an insertion point is the gap between/before/after a
                  > character.

                  Well, "selection" is kind of confusing too, as it usually means what's
                  selected. And the feeling remains that it's really that "gap" that I
                  want to move - or create, if I have a selection without a text cursor
                  that I want to deselect.

                  [...]

                  >> but generally insertion point -1 simply seems to indicate where the
                  >> cursor is.
                  >
                  > No it doesn't; you're confusing it with selection.

                  Hopefully less so now. Will have a crack at pulling the Danish and
                  Swedish things out of the last script with things manually done and
                  getting them into the last automatic one. The manual pause is

                  display dialog "Move lines from change file to ends of Danio and
                  Svedio."
                  if my doYourThing() then
                  activate
                  end if

                  and the automated version is... Hmm, not there yet. When find text has
                  found DOMINIKA and it's selected, "set selection to insertion point
                  before selection" crashes InDesign, both with and without "set
                  selection to insertion point 1 of selection" preceding. The Apple
                  Script Error is: "Adobe InDesign CS4 got an error: Connection is
                  invalid." This is with

                  set find what of find text preferences to "DOMINIKA"
                  find text document 1
                  set theFinds to find text document 1
                  select item 1 of theFinds
                  set zoom percentage of layout window 1 to (get zoom percentage of
                  layout window 1)
                  --set selection to insertion point 1 of selection
                  set selection to insertion point before selection

                  Maybe you didn't mean that line literally. I still can't figure out
                  how to get from the beginning of the DOMINIKA paragraph to the end of
                  the one preceding.


                  Thanks,

                  Roy McCoy
                  Rotterdam, NL
                  • 6. Re: Pausing AppleScript
                    sstanleyau Level 4
                    On 28/11/08 3:42 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> The glib reply would be because ^c finally worked and because I don't<br />> understand text references or how to move them, but I think I can get<br />> a handle on this movin' business, thanks.<br /><br />Text references are what your searches are returning.<br /><br />> Well, "selection" is kind of confusing too, as it usually means what's<br />> selected. And the feeling remains that it's really that "gap" that I<br />> want to move - or create, if I have a selection without a text cursor<br />> that I want to deselect.<br /><br />Overcome the feeling. A blinking cursor in text means you have an insertion<br />point selected.<br /><br />> I still can't figure out<br />> how to get from the beginning of the DOMINIKA paragraph to the end of<br />> the one preceding.<br /><br />I'm not sure you need to. Assuming you want to move just the text, not its<br />styling, you can do something like:<br /><br />set oneFind to item 1 of theFinds<br /> set prevParStart to insertion point 1 of paragraph before oneFind<br />move oneFind to after prevParStart<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                    • 7. Re: Pausing AppleScript
                      Roy McCoy Level 1
                      On Nov 28, 2008, at 7:43 AM, Shane Stanley wrote:

                      Text references are what your searches are returning.

                      There's one good argument in favor of cut/copy and paste I thought of
                      after last night, and that was that every new (or returning) scripter
                      is already familiar with it. Another is that the alleged inefficiency
                      doesn't really matter, because the operations are occurring lightning-
                      fast at this point in time anyway. But I certainly don't want to
                      criticize AppleScript, I just want to use it. It's esthetically
                      pleasant, for one thing. And it apparently works, once you get it
                      figured out.

                      And right now I still need to figure out what my searches are returning,
                      so that I'll then better understand text references and how to deal with
                      them.

                      Overcome the feeling. A blinking cursor in text means you have an
                      insertion point selected.

                      That suggests that an insertion point is a kind of selection, which
                      isn't counterintuitive at all. But what's missing in my conception
                      then is why "selection" isn't similarly a class with all those useful
                      elements and properties. I have the feeling that there should be a
                      selection class corresponding to insertion point... but now I remember
                      seeing the latter defined (curiously) as a collection of insertion
                      points. So maybe that's it.... Yes, that's in fact the precise
                      definition of the insertion point class, intuitive or not.
                       
                      I still can't figure out  how to get from the beginning of the DOMINIKA
                      paragraph to the end of the one preceding.

                      I'm not sure you need to. Assuming you want to move just the text,

                      I don't, and I think you've misunderstood what I was trying to do here.
                      I'm sure it's easier for you to understand my old PageMaker dialect
                      than for me to understand your new AppleScript one. You can hardly beat
                      "textcursor char -1", for example, and you surely know what a text
                      cursor is in that and similar contexts. So I'll try to make myself a
                      little clearer, explaining that I don't want to move any text in this
                      case ("DOMINIKA" and "SVISLANDO" being used only to locate the desired
                      point, as they're unique or at least uniquely capitalized in the text),
                      but only the text cursor, that is,... you know, that blinking thing.

                      And after last night, I know I'm not the only one to have experienced
                      a serious problem with the new manner of dealing with this. The question
                      that occasioned the formula I found was: "what I want to do is, [...]
                      move the cursor one place to the right or left [...]. (CAN'T FIND
                      ANYTHING IN THE DICTIONARY!) Seriously: does InDesign have *any*
                      commands for moving the cursor about? I can't find anything. All I
                      want to do is go one place forward or back."

                      I think that's a very normal thing to want or need to do, and
                      instruction on this kind of basic thing doesn't seem to be provided
                      in the documentation. All right, so I haven't read the documentation
                      and thus hardly have the right to complain, but I have searched through
                      it using various related search terms and haven't found anything.
                      Believe me, if I could have avoided shelling out fifty euros for a
                      somewhat clunkily printed book on the subject, I would have.

                      not  its styling, you can do something like:

                      set oneFind to item 1 of theFinds
                      set prevParStart to insertion point 1 of paragraph before oneFind
                      move oneFind to after prevParStart

                      And not "contents of oneFind" or similar. This is a little confusing
                      since you said that what I was finding was a reference, and here you
                      don't seem to be moving a reference but the text itself. Only, again,
                      I don't want to move anything, and so the first two lines should be
                      enough. So I'll go back and see... Skipping the selecting and zooming
                      this time...

                      No, that isn't working for me. It highlights "insertion point 1"
                      and says "Adobe InDesign CS4 got an error: Invalid parameter."
                      Because both this line and "set selection to insertion point before
                      selection" work for you but not for me, I suspect I'm sending my tell
                      statement to the wrong place. I tried "tell document 1" but that gave
                      a different alert, "Adobe InDesign CS4 got an error: Canât set find
                      what of find text preferences of document 1 to "DOMINIKA"."


                      Thanks,

                      Roy McCoy
                      Rotterdam, NL

                      • 8. Re: Pausing AppleScript
                        sstanleyau Level 4
                        On 28/11/08 10:25 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> There's one good argument in favor of cut/copy and paste I thought ofafter<br />> last night, and that was that every new (or returning) scripteris already<br />> familiar with it.<br />> <br />But if you keep persisting with it for things like this, you're going to<br />continue to be disappointed. You have to start thinking the way ID scripting<br />(and in fact most scripting) does. In the UI, it makes sense to have to<br />first select something, and then act on it -- you couldn't really work any<br />other way. But in scripting, you specify the command and target in the one<br />statement. So in the UI you select word x and then apply a style; in<br />scripting you just apply a style to word x -- no selecting required. Unless<br />you want scripting to remain a chore, you have to come to grips with this<br />fundamental difference.<br /><br />> And right now I still need to figure out what my searches are returning, so<br />> that I'll then better understand text references and how to deal with them.<br />> <br />They are returning object references to the text -- object references are<br />how ID refers to objects in scripting.<br /><br />>> A blinking cursor in text means you have an insertion point selected.<br />>> <br />> That suggests that an insertion point is a kind of selection<br />> <br />No, no, no. The insertion point is there whether you click in it or not.<br /><br />Consider an otherwise empty text frame. When you type in it, the text takes<br />on certain attributes. Where are these attributes stored? They can't be<br />stored in the frame, because it doesn't have text attributes. The answer is<br />that they are stored in the first insertion point, which has virtually<br />identical properties to a character. So to insert text anywhere, you set the<br />contents of the relevant insertion point. For example, to add text at the<br />end of a paragraph but before the return, you 'set contents of insertion<br />point -2 of paragraph 1 to "blah, blah"'. The concept might seem a bit odd<br />at first, but you need to grasp it.<br /><br />> But what's missing in my conceptionthen is why "selection" isn't similarly a<br />> class with all those usefulelements and properties.<br />> <br />Selection is a property that returns a list of object references to whatever<br />is selected. Just write a simple script to get selection, and play with it<br />with various things selected.<br /><br />> I don't, and I think you've misunderstood what I was trying to do here.I'm<br />> sure it's easier for you to understand my old PageMaker dialect than for me to<br />> understand your new AppleScript one. You can hardly beat"textcursor char -1",<br />> for example, and you surely know what a textcursor is in that and similar<br />> contexts.<br />> <br />But the point is that that's something one rarely needs to do in ID<br />scripting, because where the cursor is is mostly irrelevant.<br /><br />> And after last night, I know I'm not the only one to have experienced a<br />> serious problem with the new manner of dealing with this. The questionthat<br />> occasioned the formula I found was: "what I want to do is, [...]move the<br />> cursor one place to the right or left [...]. (CAN'T FIN DANYTHING IN THE<br />> DICTIONARY!) Seriously: does InDesign have *any*commands for moving the cursor<br />> about? I can't find anything. All I want to do is go one place forward or<br />> back." I think that's a very normal thing to want or need to do<br />> <br />And that's the problem: it's *not* a very normal thing to want to do,<br />because except in the limited case of trying to point something out to the<br />user, if you're doing it, chances are you're doing things the wrong way. If<br />you want to move text, you "move <a reference to the text> to <a reference<br />to where you want it to go>" -- there's no need to deal with the selection.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                        • 9. Re: Pausing AppleScript
                          Roy McCoy Level 1
                          Shane,

                          There's one good argument in favor of cut/copy and paste I thought of
                          after  last night, and that was that every new (or returning) scripter
                          is already familiar with it.

                          But if you keep persisting with it for things like this, you're going
                          to continue to be disappointed.

                          I didn't express myself adequately. My intention wasn't to defend
                          copying and pasting, about which I'm sure you're correct. What I wanted
                          to say, but didn't, was that if a radically different concept is
                          involved, then this should be initially laid out more clearly for us
                          dummies who have always cut and pasted and don't know anything else.

                          The first thing I thought reading the above was that you hadn't heard
                          me when I said I didn't want to move text, but just get to a certain
                          point. But now I remember that in fact I did want to move text in the
                          earlier case of the Chinese guy with one too many professions. I didn't
                          express myself well on that either. I knew, clearly, that this was no
                          place for copying and pasting, since - for one thing - you could paste
                          the desired text into the script as or more easily than you could make
                          the script paste the text into the desired location. I just wanted to
                          know how to do it for possible future reference and reuse, that's all.
                          And I found out that ^c works, even slipped directly into strings on
                          either side. I don't imagine that you'd want to say that nobody would
                          ever want to use ^c in an InDesign script, even if it's indeed generally
                          to be avoided.

                          Y ou have to start thinking the way ID scripting (and in fact most
                          scripting) does. In the UI, it makes sense to have to first select
                          something, and then act on it -- you couldn't really work any other
                          way. But in scripting, you specify the command and target in the one
                          statement. So in the UI you select word x and then apply a style; in
                          scripting you just apply a style to word x -- no selecting required.
                          Unless you want scripting to remain a chore, you have to come to grips
                          with this fundamental di fference.

                          Well, the thing is, if the thing is selected and it's standing out in your computer screen there, you can see what's happening - and at this initial point I feel a need to keep an eye on what's going on. I think I was mainly continuing to select the found text in order to be able to then use that handy line of yours:

                          set zoom percentage of layout window 1 to Â¬
                             (get zoom percentage of layout window 1)

                          to get the page to come up on the screen so I could see it. I'm not into selecting for the sake of selecting, and I can easily see that there's no real reason to select "DOMINIKA" or "SVISLANDO", other than perhaps to bring their locations into view (at least until I'm sure the script is functioning properly), if selecting is indeed necessary for that.

                          And right now I still need to figure out what my searches are returning,
                          so  that I'll then better understand text references and how to deal with them.

                          They are returning object references to the text -- object references
                          are how ID refers to objects in scripting.

                          I think a rose by any other name would smell as sweet.

                          That suggests that an insertion point is a kind of selection

                          No, no, no. The insertion point is there whether you click in it or not.

                          Perhaps a tentative or potential selection, then. I don't tend to believe the precise terminology and semantics matter that much - I just need to get the job done, and I'm running late. There's a whole series of mailings that should have been done in November, and I'm still working on the first one. I screwed up not reading up more before jumping in on the job, but again, it's not like I totally ignored the documentation even though I didn't read page by page through the Scripting Guide.

                          Consid er an otherwise empty text frame. When you type in it, the text takes on certain attributes. Where are these attributes stored? They can't be stored in the frame, because it doesn't have text attributes. The answer is that they are stored in the first insertion point, which has virtually identical properties to a character. So to insert text anywhere, you set the contents of the relevant insertion point. For example, to add text at the end of a paragraph but before the return, you 'set contents of insertion point -2 of paragraph 1 to "blah, blah"'. The concept might seem a bit odd at first, but you need to gr asp it.

                          I think I've got it, actually. I just needed to know how to get to the end of the preceding paragraph, and I couldn't find that anywhere. Now I think I need to know why "set selection to insertion point before selection" and "set prevParStart to insertion point 1 of paragraph before oneFind" don't work for me, these apparently indicating how I should be going about it. Hmm, looking again at "set selection to insertion point ((index of selection) + 1) of parent story of selection", which does work, I notice that "of parent story" that's missing in your two lines... so they should be in a tell statement to the parent story? Sometimes I haven't been able to use "current" when I've thought I could. If you want the current story, do you have to say "story 1"? What's "story 2", by the way? I've never seen that one, or a 2 anything.

                          But what's missing in my conceptionthen is why "selection" isn't
                          similarly a  class with all those usefulelements and properties.

                          Selecti on is a property that returns a list of object references to whatever is selected. Just write a simple script to get selection, and play with it with various things se lected.

                          Play with it how? That's just what I don't know, how to get in there and see everything. 

                          I don't, and I think you've misunderstood what I was trying to do here.
                          I'm  sure it's easier for you to understand my old PageMaker dialect than
                          for me to understand your new AppleScript one. You can hardly beat
                          "textcursor char -1", for example, and you surely know what a textcursor
                          is in that and similar contexts.

                          But the point is that that's something one rarely needs to do in ID
                          scripting, because where the cursor is is mostly irrelevant.

                          *I* need to get to a certain place. I've only used the cursor to get
                          there before. If you don't need the cursor, fine, but I still need
                          to get there and the modes of navigation don't seem to be as clearly
                          documented as in, for example, the  PageMaker Scripting book. Okay,
                          so I need a book on this too. It's been shipped.

                          An d after last night, I know I'm not the only one to have experienced a serious problem with the new manner of dealing with this. The questionthat occasioned the formula I found was: "what I want to do is, [...]move the cursor one place to the right or left [...]. (CAN'T FIN DANYTHING IN THE DICTIONARY!) Seriously: does InDesign have *any*commands for moving the cursor about? I can't find anything. All I want to do is go one place forward or back." I think that's a very normal thing to want or need to do

                          And that's the problem: it's *not* a very normal thing to want to do,

                          Oh but I think it is. I've referenced things to a current point all the time, and I'm sure others do as well.

                          be cause except in the limited case of trying to point something out to the user, if you're doing it, chances are you're doing things the wrong way. If you want to move text, you "move <a reference to the text> to <a reference to where you want it to go>" -- there's no need to deal with the se lection.

                          Fine, to hell with the selection then. But I still need to be able to move around at will and get to where I want to go - or make "it" go to where I want "it" to go. Whatever. I've just got to finish automating the preparation of this text.


                          Many thanks,

                          Roy McCoy
                          Rotterdam, NL


                          • 10. Re: Pausing AppleScript
                            sstanleyau Level 4
                            On 29/11/08 7:57 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> Oh but I think it is.<br /><br />Then I wish you all the best. I'm happy to suggest how to script things, but<br />I'm not really interested in arguing whether it would be better if it worked<br />another way. At this point I think that's just a waste of time.<br /><br />Cheers,<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                            • 11. Re: Pausing AppleScript
                              Roy McCoy Level 1
                              Shane Stanley wrote:

                              I'm not really interested in arguing whether it would be better if it worked
                              another way. At this point I think that's just a waste of time.

                              Odd, that's what I wanted to say. What I have several times tried to say is that I don't think it would be better if it worked another way, and that I assume you're correct even if I haven't yet mastered this object-model concept, or whatever it is. What I disagreed with was your emphatically saying that wanting to go one place forward or back was not a normal thing to want to do, when I'm quite sure it is and that's what the other fellow was wanting to do too. You can't do anything anywhere if you can't locate the place you want to do it - that's all I wanted to say, other than that I haven't found the provided documentation to be very helpful on basic navigational operations, whether one is copying text or moving references or whatever. Going one place forward or back is an individual case of the general desire/need to to one paragraph forward or back, or page, or whatever. I need to know how to do that, believe me.

                              But enough of the general discussion already. Agreed!


                              Thanks,

                              Roy McCoy
                              Rotterdam, NL

                              • 12. Re: Pausing AppleScript
                                sstanleyau Level 4
                                On 29/11/08 11:42 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> What I disagreed with was your emphatically saying that wanting to go one<br />> place forward or back was not a normal thing to want to do<br /><br />No, I said *moving the cursor or selection* was not a normal thing to want<br />to do. Terminology *does* matter.<br /><br />So supposing you have an object reference to some text, either as the result<br />of a search, or from a search, or from a reference such as "set theRef to<br />object reference of word -1 of paragraph x of parent story of text frame 1<br />of document 1". It will look something like: 'text from character 33 to<br />character 36 of story id 186 of document "Untitled-1"'.<br /><br />To get an object reference to the paragraph that contains that text referred<br />to (or the first character of it), you can use:<br /><br /> set thePar to object reference of paragraph 1 of theRef<br /><br />And if you want the paragraph before, you can use:<br /><br /> set thePar to object reference of paragraph before paragraph 1 of theRef<br /><br />So, for example, to move the selected text to the beginning of its<br />paragraph, you could use:<br /><br />  move selection to before paragraph 1 of selection<br /><br />To put it before the paragraph before, use:<br /><br />  move selection to before paragraph before paragraph 1 of selection<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                                • 13. Re: Pausing AppleScript
                                  sstanleyau Level 4
                                  On 30/11/08 10:34 PM, "Shane Stanley" <member@adobeforums.com> wrote:<br /><br />> either as the result of a search, or from a search<br /><br />Make that " either as the result of a search, or from a selection"<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                                  • 14. Re: Pausing AppleScript
                                    Roy McCoy Level 1
                                    Shane Stanley wrote:

                                    >> What I disagreed with was your emphatically saying that wanting to
                                    >> go one place forward or back was not a normal thing to want to do
                                    >
                                    > No, I said *moving the cursor or selection* was not a normal thing
                                    > to want to do. Terminology *does* matter.

                                    And an insertion point is not a blinking text cursor! I read your
                                    messages over yesterday and I think I finally understand you on this.

                                    > So supposing you have an object reference to some text, either as
                                    > the result of a search, or from a [selection], or from a reference
                                    > such as "set theRef to object reference of word -1 of paragraph x of
                                    > parent story of text frame 1 of document 1". It will look something
                                    > like: 'text from character 33 to character 36 of story id 186 of
                                    > document "Untitled-1"'.

                                    Yes, there's that PARENT STORY again. I was talking about "story 1"
                                    and "current story", but will now be trying "parent story". I see
                                    terminology does matter if one term works and another doesn't.

                                    > To get an object reference to the paragraph that contains that text
                                    > referred to (or the first character of it), you can use:
                                    >
                                    > set thePar to object reference of paragraph 1 of theRef

                                    "Object reference" in a line of script - now I have something new to
                                    start misunderstanding! My first guess: like, where it is?

                                    > And if you want the paragraph before, you can use:
                                    >
                                    > set thePar to object reference of paragraph before paragraph 1 of
                                    > theRef
                                    >
                                    > So, for example, to move the selected text to the beginning of its
                                    > paragraph, you could use:
                                    >
                                    > move selection to before paragraph 1 of selection
                                    >
                                    > To put it before the paragraph before, use:
                                    >
                                    > move selection to before paragraph before paragraph 1 of selection

                                    In the case of the Chinese guy with two professions, I need(ed) to
                                    move the second one - which I don't need to select and likely
                                    shouldn't! - to a definable point in the middle of the same paragraph.
                                    (The insertion point had to, er, be defined - or seemed to have to be
                                    - as the previous paragraph in the other case, where I needed to
                                    insert explanatory lines about "Ã" city names in Denmark and Sweden).
                                    When thinking yesterday about how I was going to get to the right
                                    insertion point, I had the brilliant idea of creating a SECOND
                                    VARIABLE for the text at that insertion point - duh. Will try to do it
                                    that way, though perhaps later as I really have to plow through the
                                    rest of this stuff and get the job out this time one way or another,
                                    hopefully at least half-assedly automated.


                                    Thanks,

                                    Roy McCoy
                                    Rotterdam, NL
                                    • 15. Re: Pausing AppleScript
                                      Roy McCoy Level 1
                                      I got this far, trying again with the two-profession guy ["FD (medicino; eldonado): d-ro Zheng Bocheng, profesoro pri medicino, Haidianqu Huayuan Beilu Tayuan Xiaoqu, Yingchunyuan 4 Haolou 4 Men 403-Shi, 100083 Beijing; [h](010) 62046942, [of](010) 64210081, [of](010) 64260067 redaktoro de Granda Äina Enciklopedio (medicina vol.)."]:

                                      set find what of find text preferences to " redaktoro de Granda Äina Enciklopedio (medicina vol.)"
                                      set theFinds to find text document 1
                                      set toBeMoved to item 1 of theFinds
                                      set find what of find text preferences to "Bocheng, profesoro pri medicino, "
                                      set theFinds to find text document 1
                                      set moveToHere to item 1 of theFinds
                                      move toBeMoved to after moveToHere

                                      But then I started generating crashes again when I tried, one way or another, to change the contents of the insertion point following toBeMoved to ", ", the comma and space I need to add. The alert was again that the connection wasn't valid, whatever that means.

                                      I could just change "(medicina vol.)" to "(medicina vol.), "... and I've now done that just to provisionally wind up this variant:

                                      set find what of find text preferences to "(medicina vol.)"
                                      set change to of change text preferences to "(medicina vol.), "
                                      change text document 1

                                      But I should of course know how to insert text at a desired point, also in the middle of a paragraph. But lacking my blinking text cursor I seem even more lost at this point, and I'm again tending to hanker back to copying and pasting, considering that I could simply request a text insertion after a paste and it would be entered at the desired point. I can't use toBeMoved anymore because it essentially involves the position of the text being moved, right? This is what I've been saying, that however one wants to put it, I need to be able to "get to" a desired point so that I can do what I want to do at that point, whether it's moving or pasting or deleting or whatever.

                                      Am I correct in my suspicion that I'll need to mention "parent story" somehow in the missing line or lines here that would/will enable me to insert a comma and word space following the point where the text was moved? Again, this seems to have been common to the lines that have worked, as opposed to others that have not worked, some of which have crashed ID.


                                      Thanks,

                                      Roy McCoy
                                      Rotterdam, NL

                                      • 16. Re: Pausing AppleScript
                                        Roy McCoy Level 1
                                        Alas, I seem to be losing another night. I have this (ignoring styling etc.):

                                        BRAZILO
                                        Regionaj delegitoj: Amazonia: Pekim Tenório Vaz, D k FD en Belém;
                                        Centrokcidenta: Henrique A.K. Mendonça, D k FD en Anápolis;
                                        Nordorienta: Wandemberg Ribeiro Morais, D k FD en Fortaleza;
                                        Orienta: Luiz Alberto de Oliveira Coelho, FD en ParaÃba do Sul;
                                        Suda: Gloria Lucie Perine, D k FD en Curitiba.
                                        Äefdelegito: James Rezende Piton, Rua Macedo Soares, 1035, Cid. Universitária, 13083-130 Campinasâ-âSP; â[h]+f(19) 3307 8008, â[of](19) 3512 1188; sudastelaro@gmail.com.
                                        Além ParaÃba (Minas Gerais) 34 000 â
                                        D kaj FD (instruado: E): Ãlio Lopes de Oliveira, em. bankoficisto, Rua São Geraldo 238, Vila Laroca, 36660-000 Além ParaÃbaâ-âMG; â(32) 3462 2945.

                                        The lines between "BRAZILO" and "Äefdelegito" are screwed up, and I need to place the replacement text, which I've put in an exported tagged-text file because of the style changes in it, after the Äefdelegito paragraph rather than before it.

                                        I can do this:

                                        set find what of find text preferences to "Regionaj delegitoj: Amazonia: Pekim Tenório Vaz, D k FD en Belém;
                                        Centrokcidenta: Henrique A.K. Mendonça, D k FD en Anápolis;
                                        Nordorienta: Wandemberg Ribeiro Morais, D k FD en Fortaleza;
                                        Orienta: Luiz Alberto de Oliveira Coelho, FD en ParaÃba do Sul;
                                        Suda: Gloria Lucie Perine, D k FD en Curitiba.
                                        "
                                        set theFinds to find text document 1
                                        set textToDelete to item 1 of theFinds
                                        select textToDelete
                                        delete textToDelete

                                        with the selection line seeming necessary to "get me to" this point. I just have to "get there" one way or another, and this at least seems to be doing it for me. But after this none of my attempts work, and I can't do it without the selection either. I myself would be happy to simply jump the cursor one paragraph down and insert the text, but if you think it's better to insert the text at the desired point without jumping down there, that's fine with me. I just need to be able to do it, one way or another. But I don't seem to be able to do anything. I haven't kept a log of my failures, but I can simply start screwing up again at any point. For example, right now:

                                        set myPar to paragraph 1 of selection
                                        select myPar

                                        This just trying to check on "paragraph 1 of selection". The cursor is at the beginning of "Äefdelegito", but the paragraph isn't selected and SE says: "Invalid value for parameter 'selectable items' of event 'select'. Expected object, list of objects, nothing or all, but received "<0108>efdelegito: James Rezende Piton, Rua Macedo Soares, 1035, Cid. Universitária, 13083-130 Campinas<2009>-<2009>SP; â[h]+f(19) 3307 8008, â[of](19) 3512 1188; rsudastelaro@gmail.com.
                                        "."

                                        I forget about the correct place for the time being and simply try to place the replacement text file wherever the cursor is sitting:

                                        set theRegionalDelegates to choose file with prompt "Choose regional delegates file:"
                                        place theRegionalDelegates

                                        But the alias doesn't understand the place message. HOWEVER (ooh! ooh!), it does understand it if I wrap it in a tell statement to insertion point 1 of paragraph 1 of selection. And if that works, then, in accordance with your message the other day, it should also work with, uh, insertion point 1 of paragraph after paragraph 1 of selection.... But that doesn't work! It says it can't get the alias. Why should it be able to get the alias for insertion point 1 of paragraph 1 of selection but not for insertion point 1 of paragraph after paragraph 1 of selection? That's the way it is, anyway - I rechecked. So I apparently do need to "move the text cursor", at least in this immediate circumstance and unless you can tell me how to get the place command to work otherwise.

                                        Okay, I finally got it:

                                        tell insertion point -1 of paragraph 1 of selection
                                        place theRegionalDelegates
                                        end tell

                                        Do you know why insertion point -1 of paragraph 1 of selection works, but insertion point 1 of paragraph after paragraph 1 of selection doesn't?


                                        Thanks,

                                        Roy McCoy
                                        Rotterdam, NL

                                        • 17. Re: Pausing AppleScript
                                          sstanleyau Level 4
                                          A few points (your last two messages are formatted with no space between<br />paragraphs, and in some cases missing returns, which makes them almost<br />impossible to read):<br /><br />"parent story" is a property of a text frame, and you use it to refer to the<br />whole story, including any that spills to other frames or goes into overset.<br /><br />>set myPar to paragraph 1 of selection select myPar<br /><br />Try:<br /><br />set myPar to object reference of paragraph 1 of selection<br />select myPar<br /><br />> try to place the replacement text file wherever the cursor is sitting:<br />> set theRegionalDelegates to choose file with prompt "Choose regional delegates<br />> file:" place theRegionalDelegates<br /><br />Using place like that won't place at the cursor; you need to tell ID where<br />to place, using the "on" parameter, or doing it inside a tell construct.<br /><br />> Do you know why insertion point -1 of paragraph 1 of selection works, but<br />> insertion point 1 of paragraph after paragraph 1 of selection doesn't?<br /><br />It works fine here:<br /><br />tell application "Adobe InDesign CS3"<br />    tell document 1<br />        tell insertion point 1 of paragraph after paragraph 1 of selection<br />            place (choose file)<br />        end tell<br />    end tell<br />end tell<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                                          • 18. Re: Pausing AppleScript
                                            Roy McCoy Level 1
                                            Shane Stanley wrote:

                                            > your last two messages are formatted with no space between
                                            > paragraphs, and in some cases missing returns, which makes
                                            > them almost impossible to read):

                                            Yes, I now see at the site. Sorry about that. But they look
                                            normally okay in my Mail 3.5 send box, and I don't recall
                                            having changed anything that would have such drastic results
                                            lately. Is this one okay, I hope?

                                            > "parent story" is a property of a text frame, and you use it
                                            > to refer to the whole story, including any that spills to
                                            > other frames or goes into overset.

                                            What's the difference between parent story and story 1.
                                            Does "current story" even exist, or did I imagine it?

                                            >> set myPar to paragraph 1 of selection [newline] select myPar
                                            >
                                            > Try:
                                            >
                                            > set myPar to object reference of paragraph 1 of selection
                                            > select myPar

                                            That was supposed to be two lines, of course. I can understand
                                            that object reference of paragraph 1 works where paragraph 1
                                            alone doesn't, but I don't understand the difference between
                                            the two. LOL - I go to the dictionary and receive the ultimately
                                            helpful explanation "object reference (assigned story, r/o) :
                                            An object reference for the object." That really helps a lot!
                                            I find also that one's an element and the other one's a property,
                                            which doesn't help much because I don't understand the difference
                                            between those two either.

                                            >> try to place the replacement text file wherever the cursor is
                                            >> sitting:
                                            >> set theRegionalDelegates to choose file with prompt "Choose regional
                                            >> delegates file:" place theRegionalDelegates
                                            >
                                            > Using place like that won't place at the cursor; you need to tell ID
                                            > where to place, using the "on" parameter, or doing it inside a tell
                                            > construct.

                                            Yes, putting it in the tell construct was how I finally got it to work:

                                            tell insertion point -1 of paragraph 1 of selection
                                            place theRegionalDelegates
                                            end tell

                                            How would I use the "on" parameter for that?

                                            >> Do you know why insertion point -1 of paragraph 1 of selection works,
                                            >> but insertion point 1 of paragraph after paragraph 1 of selection
                                            >> doesn't?
                                            >
                                            > It works fine here:
                                            >
                                            > tell application "Adobe InDesign CS3"
                                            > tell document 1
                                            > tell insertion point 1 of paragraph after paragraph 1 of
                                            > selection
                                            > place (choose file)
                                            > end tell
                                            > end tell
                                            > end tell

                                            Not for me. With CS4 rather than CS3 as the only change, I get "Canât
                                            get alias " Great Royzito:Users:Home:Documents:Current Work:Jarlibro
                                            2009: text files for scripts:brazilaj regionaj delegitoj.txt".

                                            I got the job done! Everything that was previously in various files
                                            (and before that on scraps of paper) has been incorporated into eight
                                            consecutive scripts, seven run from the scripts palette and one from
                                            Script Editor. I'm a little late, but we got there. I can combine and
                                            improve them later, and I certainly want to do other things with
                                            AppleScript as well. I can't thank you enough, as I literally couldn't
                                            have done it without you.


                                            Thanks,

                                            Roy McCoy
                                            Rotterdam, NL
                                            • 19. Re: Pausing AppleScript
                                              sstanleyau Level 4
                                              On 1/12/08 1:41 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> What's the difference between parent story and story 1.<br />> Does "current story" even exist, or did I imagine it?<br /><br />Text frames have a parent story; documents can have many stories, hence<br />story 1, story 2, etc. There's no such animal as current story.<br />> <br /> <br />> That was supposed to be two lines, of course. I can understand<br />> that object reference of paragraph 1 works where paragraph 1<br />> alone doesn't, but I don't understand the difference between<br />> the two. <br /><br />If you use:<br /><br /> set x to object reference of paragraph 1<br /><br />you get "text from...".<br /><br />If you use:<br /><br /> set x to paragraph 1<br /><br />you get the contents of paragraph 1 as a string.<br /><br />> I find also that one's an element and the other one's a property,<br />> which doesn't help much because I don't understand the difference<br />> between those two either.<br /><br />In many ways they're similar. Generally, properties are used where something<br />always exists and there's only one of them, whereas element is used where<br />there can be many or none.<br /><br />> tell insertion point -1 of paragraph 1 of selection<br />> place theRegionalDelegates<br />> end tell<br />> <br />> How would I use the "on" parameter for that?<br /><br />place theRegionalDelegates on insertion point -1 of paragraph 1 of selection<br />> <br />> Not for me. With CS4 rather than CS3 as the only change<br /><br />It looks like the "after" reference is broken in CS4, unfortunately. There<br />are other ways around this, like using the index property, for example:<br /><br />    set z to index of character -1 of paragraph 1 of selection<br />    place (choose file) on insertion point 1 of parent story of selection<br />whose index > z<br /><br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                                              • 20. Re: Pausing AppleScript
                                                Roy McCoy Level 1
                                                Shane Stanley wrote:

                                                > Text frames have a parent story; documents can have many stories,
                                                > hence story 1, story 2, etc. There's no such animal as current story.

                                                Okay, got that - but I don't remember ever seeing a "story 2" or such.
                                                When would you know what story 2 was?

                                                Along this line, I tried making a folder in folder 1, which doesn't
                                                work at all if QuicKeys calls the file. I can put the script text in
                                                QuicKeys and then it makes the folder, but it's annoying to have to do
                                                that because I'm trying to keep all the scripts in one place. The
                                                script seemed to be working before, with "make folder in front window"
                                                in place of "container of selection", which I think you confirmed
                                                doesn't work anymore. But it didn't work right earlier tonight, and I
                                                soon realized that it was because the front window wasn't necessarily
                                                the containing folder of the selection. So then I had the traditional
                                                try this, try that and blow a lot of time while nothing works
                                                experience. Okay, I give up. Is it possible to make a folder in the
                                                same folder as the selection. I suppose I have to get the location of
                                                the selection and then make the folder at the same location. But I
                                                don't know how, and I thought there were supposed to be things like
                                                "container" to serve this purpose.

                                                Another thing I was wondering about was the CS3/CS4 sample scripts.
                                                When I updated to CS4 I was amazed that all my CS3 scripts amazingly
                                                and automatically converted to "tell application Adobe InDesign CS4";
                                                only now I see the (uncompiled) sample scripts don't do that. Is there
                                                a way to get them to?


                                                Thanks,

                                                Roy McCoy
                                                Rotterdam, NL
                                                • 21. Re: Pausing AppleScript
                                                  sstanleyau Level 4
                                                  On 2/12/08 1:58 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />> Okay, got that - but I don't remember ever seeing a "story 2" or such.<br />> When would you know what story 2 was?<br /><br />You probably wouldn't. But if you decided to do something to every story in<br />a document, then looping through the stories makes more sense than looping<br />through text frames and getting parent stories.<br />> <br />> Okay, I give up. Is it possible to make a folder in the<br />> same folder as the selection.<br /><br />Sure:<br /><br />tell application "Finder"<br />    -- get reference to selection<br />    set theSelection to selection<br />    -- because it's a list, get the first item<br />    set theSelection to item 1 of theSelection<br />    -- alert the user<br />    beep<br />    -- ask for the folder name<br />    set folderName to text returned of (display dialog "Name for new<br />folder:" default answer "Untitled")<br />    --make the folder<br />    try -- so we ignore errors; they don't matter here<br />        make folder at container of theSelection with properties<br />{name:folderName}<br />    end try<br />end tell<br /><br />> <br />> Another thing I was wondering about was the CS3/CS4 sample scripts.<br />> When I updated to CS4 I was amazed that all my CS3 scripts amazingly<br />> and automatically converted to "tell application Adobe InDesign CS4";<br />> only now I see the (uncompiled) sample scripts don't do that. Is there<br />> a way to get them to?<br /><br />No; that's one of several reasons why saving them as text instead of<br />compiled is a bad idea. But you can download the CS4 versions.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                                                  • 22. Re: Pausing AppleScript
                                                    Roy McCoy Level 1
                                                    Shane Stanley wrote:

                                                    You probably wouldn't. But if you decided to do something to every story in a document, then looping through the stories makes more sense than looping through text frames and getting parent stories.

                                                    Might "story 1" then be a synonym of an equivalent expression? Not that it matters or that it's necessary, I'm just wondering.

                                                    I was really disappointed the other night when, trying to be a good boy, I looked in the Finder dictionary trying to find the whatever it was I needed and discovered

                                                    insertion location (specifier, r/o) : the container in which a new folder would appear if âNew Folderâ was selected

                                                    That really seemed to be exactly what I needed - but I couldn't get it to work with make folder. :-(

                                                    tell application "Finder"
                                                       -- get reference to selection
                                                       set theSelection to selection
                                                       -- because it's a list, get the first item
                                                       set theSelection to item 1 of theSelection
                                                       -- alert the user
                                                       beep
                                                       -- ask for the folder name
                                                       set folderName to text returned of (display dialog "Name for new
                                                    folder:" default answer "Untitled")
                                                       --make the folder
                                                       try -- so we ignore errors; they don't matter here
                                                           make folder at container of theSelection with properties
                                                    {name:folderName}
                                                       end try
                                                    end tell

                                                    I laughed when I saw this, as it seemed identical to simply command-n, so why would anybody want or need to script that? I then thought it could be part of a larger script where somebody would want to do that, so it made more sense - though I must say, at the risk of again being pointlessly critical, that it seems an overly arcane way to have to do something as totally ordinary and basic as making a new folder in the place where the selection is.

                                                    Actually I didn't laugh immediately, because my first (incorrect) reaction was annoyance at having to enter the name. Again, if I had to do that I could just hit command-n and do it in the Finder without a script every bit as easily and even more so (not needing a QuicKey, etc.). But this is for a standard operation, namely moving previous versions of work files to a "  noncurrent" folder in the current job folder, creating it if it doesn't exist. So...

                                                    tell application "Finder"
                                                      set theSelection to selection
                                                      set theSelection to item 1 of theSelection
                                                      try
                                                        make folder at container of theSelection with properties {name:"  noncurrent"}
                                                      end try
                                                      move selection to folder "  noncurrent" of container of theSelection
                                                    end tell

                                                    Yippee. Used Result pane in Script Editor to get needed info on "  noncurrent" while finally coming up with this.

                                                    No; that's one of several reasons why saving them as text instead of
                                                    compiled is a bad idea. But you can download the CS4 versions.

                                                    Couldn't find these yesterday, but looked again and did today.


                                                    Thanks again,

                                                    Roy McCoy
                                                    Rotterdam, NL

                                                    • 23. Re: Pausing AppleScript
                                                      Roy McCoy Level 1
                                                      P.S. "while finally coming up with this" - I mean, while correcting
                                                      the problem that the variable I was trying to use wasn't defined when
                                                      the folder already existed and the try failed.
                                                      • 24. Re: Pausing AppleScript
                                                        Roy McCoy Level 1
                                                        P.P.S. I'd tried using AT container rather than OF container.
                                                        • 25. Re: Pausing AppleScript
                                                          Roy McCoy Level 1
                                                          Shane Stanley wrote:

                                                          > (your last two messages are formatted with no space between
                                                          > paragraphs, and in some cases missing returns, which makes them almost
                                                          > impossible to read):

                                                          This seems to have corrected itself since. Please let me know if it
                                                          happens again.

                                                          > "parent story" is a property of a text frame, and you use it to
                                                          > refer to the
                                                          > whole story, including any that spills to other frames or goes into
                                                          > overset.

                                                          That's easy enough to understand, now I just have to figure out when
                                                          and how to use it.

                                                          In a later message you said that "properties are used where something
                                                          always exists and there's only one of them, whereas element is used
                                                          where there can be many or none." I take it parent story isn't an
                                                          exception, and so every text frame has a story even if the story is
                                                          empty - text flow id 224 of document "Untitled-6" of application
                                                          "Adobe InDesign CS4", I see. Is text flow then synonymous with
                                                          (parent) story, and thus likewise a property even though it doesn't
                                                          appear in the dictionary?

                                                          *****

                                                          > If you use:
                                                          >
                                                          > set x to object reference of paragraph 1
                                                          >
                                                          > you get "text from...".
                                                          >
                                                          > If you use:
                                                          >
                                                          > set x to paragraph 1
                                                          >
                                                          > you get the contents of paragraph 1 as a string.

                                                          The rain in Spain stays mainly in the plain!

                                                          > place theRegionalDelegates on insertion point -1 of paragraph 1 of
                                                          > selection

                                                          That's nifty.

                                                          > It looks like the "after" reference is broken in CS4, unfortunately.

                                                          Unfortunately indeed, as "insertion point 1 of parent story of
                                                          selection whose index > z" seems comparatively incomprehensible. It
                                                          would seem that the sense of ">" was then "1 more than z" rather than
                                                          simply "greater than z" - unless I grossly misunderstand, which is
                                                          possible.

                                                          *****

                                                          > tell application "Finder"
                                                          > -- get reference to selection
                                                          > set theSelection to selection
                                                          > -- because it's a list, get the first item
                                                          > set theSelection to item 1 of theSelection

                                                          Just one more thing here. I've been seeing this "item 1" business, so
                                                          let's see these other items already.... Oh, I get it. It's a list
                                                          because a selection can consist of more than one item, and there's
                                                          only one item if there's only one thing selected. Hey, that's at least
                                                          one thing you didn't have to explain to me!


                                                          Thanks,

                                                          Roy McCoy
                                                          Rotterdam, NL
                                                          • 26. Re: Pausing AppleScript
                                                            sstanleyau Level 4
                                                            On 4/12/08 10:47 PM, "Roy McCoy" <member@adobeforums.com> wrote:<br /><br />>> "parent story" is a property of a text frame, and you use it to<br />>> refer to the<br />>> whole story, including any that spills to other frames or goes into<br />>> overset.<br />> <br />> That's easy enough to understand, now I just have to figure out when<br />> and how to use it.<br /><br />Simple: all the time, unless you specifically want to talk only to part of a<br />story contained by a particular text frame.<br />> <br />> Is text flow then synonymous with<br />> (parent) story, and thus likewise a property even though it doesn't<br />> appear in the dictionary?<br /><br />No -- a text flow is a story. Just ignore it.<br /><br />> Unfortunately indeed, as "insertion point 1 of parent story of<br />> selection whose index > z" seems comparatively incomprehensible. It<br />> would seem that the sense of ">" was then "1 more than z" rather than<br />> simply "greater than z" - unless I grossly misunderstand, which is<br />> possible.<br /><br />No, it means greater than as normal. But " insertion point 1 ... whose index<br />> z" can also be written as "first insertion point ... whose index > z", and<br />the first one after z is always going to be z+1.<br /><br /> <br />> Just one more thing here. I've been seeing this "item 1" business, so<br />> let's see these other items already.... Oh, I get it. It's a list<br />> because a selection can consist of more than one item, and there's<br />> only one item if there's only one thing selected.<br /><br />Right. In most cases InDesign handles this automagically for you, but other<br />apps don't.<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                                                            • 27. Re: Pausing AppleScript
                                                              Roy McCoy Level 1
                                                              Shane Stanley wrote:

                                                              >> That's easy enough to understand, now I just have to figure out when
                                                              >> and how to use [parent story].
                                                              >
                                                              > Simple: all the time, unless you specifically want to talk only to
                                                              > part of a
                                                              > story contained by a particular text frame.

                                                              Who's my daddy!

                                                              > No, it means greater than as normal. But " insertion point 1 ...
                                                              > whose index
                                                              >> z" can also be written as "first insertion point ... whose index >
                                                              >> z", and
                                                              > the first one after z is always going to be z+1.

                                                              Oh, right. Like insertion point 1 in a paragraph.


                                                              Thanks,

                                                              Roy