• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to change this script, increase one case that is "change each word'first letter to capital"

Advocate ,
Jun 08, 2015 Jun 08, 2015

Copy link to clipboard

Copied

I want change each word's first letter to capital.

Help me~

Thank you very much!

-----------------------------------------------------Below,there is already script.------------------------------------------------------------

//BS”D

//ToggleCase

//An InDesign CS4 script (c) Ariel Walden, 2011

//Freebie script from http://www.FreelanceBookDesign.com

try{

mySelection = app.selection[0];

if (mySelection instanceof InsertionPoint){

if(mySelection.words[0].isValid) mySelection = mySelection.words[0];

else{

myIndex = mySelection.index;

if (myIndex < mySelection.parent.insertionPoints[-1].index && mySelection.parent.insertionPoints[myIndex+1].words[0].isValid) mySelection = mySelection.parent.insertionPoints[myIndex+1].words[0];

else {

mySelection = mySelection.parent.insertionPoints[myIndex-1].words[0];

}

}

}

myText = mySelection.contents;

if (myText != myText.toUpperCase() && myText != myText.toLowerCase()) mySelection.changecase(ChangecaseMode.UPPERCASE);

if (myText == myText.toUpperCase()) mySelection.changecase(ChangecaseMode.LOWERCASE);

if (myText == myText.toLowerCase()) mySelection.changecase(ChangecaseMode.SENTENCECASE);

if (myText == myText.toSentenceCase()) mySelection.changecase(ChangecaseMode.TITLECASE);

if (myText == mySelection.contents) mySelection.changecase(ChangecaseMode.UPPERCASE); //necessary because if lowercase letter in middle of word selected, changing to titlecase does nothing.

}

catch(f){}

TOPICS
Scripting

Views

489

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 08, 2015 Jun 08, 2015

Copy link to clipboard

Copied

You want Title Case? So just run the script again!

The point of the script is to cycle (not toggle!) the current selection

through three capitalization modes -- it makes it easy to switch the

select word to all caps, or title case, or lower case, like Word's

built-in function. The script works best if you assign a keyboard

shortcut to it -- just select your text, and keep hitting the shortcut

until you get the capitalization you want.

Hope that explanation helps. What I'm saying is that what you appear to

be asking is already the way the script works!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 08, 2015 Jun 08, 2015

Copy link to clipboard

Copied

Hold on! I just noticied that what you've posted is modified version of my script -- and, almost inevitably -- the modification broke it! To make it work as originally intended -- delete the line with the SENTENCE CASE option, so the original script should look like this:

//BS"D

//ToggleCase

//An InDesign CS4 script (c) Ariel Walden, 2011

//Freebie script from www.Id-Extras.com

try{

  mySelection  = app.selection[0];

  if (mySelection instanceof InsertionPoint){

  if(mySelection.words[0].isValid) mySelection = mySelection.words[0];

  else{

  myIndex = mySelection.index;

  if (mySelection.parent.insertionPoints[myIndex+1].words[0].isValid) mySelection = mySelection.parent.insertionPoints[myIndex+1].words[0];

  else {

  mySelection = mySelection.parent.insertionPoints[myIndex-1].words[0];

  }

  }

  }

  myText = mySelection.contents;

  if (myText != myText.toUpperCase() && myText != myText.toLowerCase()) mySelection.changecase(ChangecaseMode.UPPERCASE);

  if (myText == myText.toUpperCase()) mySelection.changecase(ChangecaseMode.LOWERCASE);

  if (myText == myText.toLowerCase()) mySelection.changecase(ChangecaseMode.TITLECASE);

}

catch(f){}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Jun 08, 2015 Jun 08, 2015

Copy link to clipboard

Copied

LATEST

I've updated the original script, so it now includes SentenceCase:

http://www.id-extras.com/free-cycle-case-script

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines