🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: adobe.scripting.indesign
Article #10278

Re: Placing Random Text String on Multiple Pages

#10278
From: Micah_Nolte
Date: Thu, 29 Jun 2006 14:44
23 lines
1525 bytes
I resolved this. Thanks for all the help. Here is the working code:

var n = 0;
var randomString = new Array();

randomString[n++] = "Hi There 1";
randomString[n++] = "Hi There 2";
randomString[n++] = "Hi There 3";
randomString[n++] = "Hi There 4";
randomString[n++] = "Hi There 5";
randomString[n++] = "Hi There 6";
randomString[n++] = "Hi There 7";

var allThings = app.activeDocument.textFrames;

// This function was given to me by Dirk Becker on the Adobe Forums
TextFrames.prototype.itemWhose = function (f){
	var result = [];
	for( var i=0; i<this.length; i++ ) if( f.apply(this.item(i)) ) result.push(this.item(i)); return result; }

theRandomBoxes = allThings.itemWhose( function() { return this.label=="RandomBox" } );

for (var j=0; j<theRandomBoxes.length; j++){ 	var k = Math.round((n-1)*Math.random()); 	theRandomBoxes[j].contents = randomString[k]; }
Technical Details
Message-ID: <3bc0bcde.4@webcrossing.la2eafNXanI>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!news.datemas.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing
References: <3bc0bcde.-1@webcrossing.la2eafNXanI>

Show Full Headers
Complete Article Headers
X-Google-Thread: f939a,4247686e19571fc
X-Google-Attributes: gidf939a,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Micah_Nolte@adobeforums.com
Newsgroups: adobe.scripting.indesign
Subject: Re: Placing Random Text String on Multiple Pages
Message-ID: <3bc0bcde.4@webcrossing.la2eafNXanI>
Date: Thu, 29 Jun 2006 07:44:27 -0700
References: <3bc0bcde.-1@webcrossing.la2eafNXanI>
Lines: 29
MIME-Version: 1.0
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news.germany.com!news.datemas.de!news.albasani.net!news.ecp.fr!news.stben.net!webcrossing