Find/Change random scripting


hi,

 

i've never used indesign scripting before , looking find/change script found it's standard sample script makes possible me change example "aa" "aå". want make script random.

so if there multible double a's in text times changes "aa" "aå" other times changes "åa" there way edit sample or make script self, have start??

 

thanks in advance

i don't know sample thinking of, it's quite not meant change items @ random. that's rare thing ask mind explaining why?

 

in case, following script (cs3 or newer!) trick. findtext function fed correct parameters: text found , case sensitive on, not find 'aa' or 'aa' or 'aa'. since findtext function returns array (rather 'a next item', 1 one), can loop on found items , change either first character or second. setting either character #0 or character #1 of contents a-ring, leaving other character alone. backward loop prevent messing document, should of code change text.

 

the math construction returns random value between 0 , 2 inclusive, 0 changes first character, 1 2nd, , 2 nothing (left out brevity).

 

app.findchangetextoptions.casesensitive = true;
app.findtextpreferences = nothingenum.nothing;
app.findtextpreferences.findwhat = "aa";

founditems = app.activedocument.findtext();
for (var i=founditems.length-1; i>=0; i--)
{
switch (math.floor(math.random()*3))
{
  case 0: founditems[i].contents[0] = 'å'; break;
  case 1: founditems[i].contents[1] = 'å'; break;
}
}

note: untested!



More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

Flip address is out of range arduino uno r3

Arduino Uno not uploading

Indesign and MathType fonts