メインコンテンツまでスキップ
バージョン:25.2

textChunkIteration

  • global property
  • new in 1.60
  • The global property, the textChunkIteration  can be set to true to allow chunk expressions to be used directly as iterators in repeat statements. For example, consider the repeat loop:

        repeat with each word term in words 3 to 12 of phrase

    In that example, "words 3 to 12 of phrase" is a chunk expression that selects a portion of the text but previously didn't convey any information to the repeat loop, so "each word" was needed to specify repeating through the words of the text. With the textChunkIteration set to true, the chunk expression acts as an iterator, so the same repeat can be expressed more simply as:

        repeat with each term in words 3 to 12 of phrase

    Setting a variable to a chunk expression will simply copy the indicated text as before, but by making a reference to a chunk it can be used as an iterator in contexts other than a repeat:

        set bar to "once upon a time there lived a barr"

         set foo to refer to words 2 to 7 of bar
put foo.nextValue -- "upon"
put foo.nextValue -- "a"

    For now, the textChunkIteration is set to false by default for backward compatibility because it can affect the behavior of some existing expressions, particularly 'each' expressions that refer to 'items' within a text chunk, such as: "each item in words 2 to 5 of myVar".