Back

If your email is not recognized and you believe it should be, please contact us.

  • You must be logged in to reply to this topic.Login

Checking whether Paragraph object is valid — JS

Return to Member Forum

  • Author
    Posts
    • #62074
      Brian Pifer
      Participant

      Wondering if someone can help; I'm a bit new to this scripting game:

      I have a for loop that sets the paragraph variable to anyStory.paragraphs[i]. The loop iterates backwards from (anyStory.paragraphs.length – 1) to 0.

      In the loop, I have if statements that check for certain things, and removes the graf if found:

      if (currentGraf.search(“searchterm”).length > 0) { currentGraf.remove() }

      The script throw an “Object is Invalid” error on my if statement.

      I also tried using “currentGraf.contents.itemByRange(0, 3).contents === search term” for the if statement.

      I'm running CS1 (archaic I know), so I don't have access to GREP. I'm guessing I want to check whether the currentGraf variable is valid.

      Thanks.

    • #62075
      Brian Pifer
      Participant

      Noticed an error in my post:

      “currentGraf.contents.itemByRange… ” is “currentGraf.characters.itemByRange …” in my script.

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Forum Ads