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

jsx for date and month

Return to Member Forum

  • Author
    Posts
    • #58725
      Gert Verrept
      Member

      I made a little javascript to keep the date and the month together on one line (non-breaking space).

      It works fine with the “find and change” from indesign, but once in a jsx it does nothing (even no error). I probavly made an error somewhere, but where? Listed below the script

      app.changeGrepPreferences = NothingEnum.nothing;

      app.findGrepPreferences = NothingEnum.nothing;
      app.findGrepPreferences.findWhat = '(d|1er)[ ](januari|janvier|februari|février|maart|mars|mei|mai|april|avril|juni|juin|juli|juillet|augustus|août|september|septembre|oktober|octobre|november|novembre|december|décembre))';

      app.changeGrepPreferences.changeTo = '$1~S$2';

      app.activeDocument.changeGrep();

      app.changeGrepPreferences = NothingEnum.nothing;

      app.findGrepPreferences = NothingEnum.nothing;

      Gert

    • #58726

      I was already typing a long answer, but let me check this first …

      Inside InDesign when using GREP, you have to escape each special character with a backslash to make it non-special. But the backslash is also a special character for Javascript! So to get a single backslash inside a GREP expression (to make the next character special), you have to insert two of them in a Javascript string (because JS itself will replace it with one 'regular' backspace).

      In your script, as seen above, it would seem that you only used single backspaces, which is a common pitfall when copying a working GREP expression into a non-working script. But (there is always a “but”) … this forum software eats backslashes for breakfast, and to see a single one you need to insert two in your post!

      So … is there one backslash per backslash, or did you have two (and the forum ate one), or …?

      A good way to check is to remove the two commands at the very end of your script, which reset the Find/Change box to its default state. When removed, the Find/Change dialog will show the exact settings it used; and you can even press the “Find Next” button to check the Find What is still valid.

    • #58729
      Gert Verrept
      Member

      The're 2 backslaches before the “(” and one before “d”. In the mean while I found the error, the 2 backslashes have to be after the “(” and at the end of that line I had to delete the 2 backslashes too.

      Thnks for the help

      gert

Viewing 2 reply threads
  • You must be logged in to reply to this topic.
Forum Ads