Skip to main content
Known Participant
August 21, 2008
Question

INDESIGN TEMPLATE INSERT DATE CS3 PROMBLEM

  • August 21, 2008
  • 27 replies
  • 3897 views
I have a indesign template with a text box that is filled by the script - The date looks like this -

Friday, August 22, 2008

The script worked perfect in CS2 when I upgraded to CS3 it no longer works???? Not sure about this one????

------------------------------------
BELOW IS THE ERROR I'M GETTING
------------------------------------

JavaScript Error!

Error Number: 24
Error String: aDoc.search is not a function
Line:29
Source: aDoc.search("", false, false, dateString,{appliedCharacterStyle:cStyleName});

------------------------------------

--------------------------------------------------

//DESCRIPTION: Use to insert date/time into document.

if (app.documents.length == 0) { exit() }
insertDTs(app.documents[0]);

function insertDTs(aDoc) {
var curPrefs = aDoc.characterStyles[0].extractLabel("dtprefs");
if (curPrefs == "") {
// Doc has no prefs; use saved prefs
curPrefs = getCurPrefs(File(getScriptPath().absoluteURI.replace(/Insert\.jsx/, "Prefs.txt")));
} // end if curPrefs
var prefParts = curPrefs.split("\n");
if (prefParts[2] != "[None]") {
insertIt(aDoc, prefParts[0], prefParts[2]);
}
if (prefParts[3] != "[None]") {
insertIt(aDoc, prefParts[1], prefParts[3]);
}

function insertIt(aDoc, formString, cStyleName) {
var formStrings= ["Day, Month, Year"]
var theFuncs = [dayMonthYear]
var charStyleStrings = aDoc.characterStyles.everyItem().name
if (indexOf(charStyleStrings, cStyleName) < 1) { return } // style not found or is No Style
var func = indexOf(formStrings, formString);
if (func < 0) { return } // requested form not recognized
var dateString = theFuncs[func](new Date());
aDoc.search("", false, false, dateString, {appliedCharacterStyle:cStyleName});
} // end insertIt

function dayMonthYear(date) {
date.setDate(date.getDate()+1);
// returns dayName, monthName date, year
var myDateString = date.toLocaleDateString();
myParts = myDateString.split(" 0");
if (myParts.length != 1) {
myDateString = myParts[0] + " " +myParts[1];
}
return myDateString.slice(0,-5) + "," + myDateString.slice(-5);

}


function indexOf(array, find,offs) {
for( var i = offs == undefined ? 0 : offs; array.length > i; i++ ) {
if( array==find ) {return i}
}
return -1;
}

function getScriptPath() {
// This function returns the path to the active script, even when running ESTK
try {
return app.activeScript;
} catch(e) {
return File(e.fileName);
} // end try
} // end getScriptPath

} // end insertDTs

--------------------------------------------------
This topic has been closed for replies.

27 replies

Known Participant
August 28, 2008
You can't insert tomorrows date with Text Variables?
Inspiring
August 27, 2008
I was thinking: maybe I should produce a CS3 version. But then I thought: what for? This script is completely obsoleted by the Text Variable feature of CS3.

Dave
Known Participant
August 27, 2008
I agree! thanks for all the help - I guess you can't help stupidity! I did get it work!!! by putting the scripts in a folder labeled Version 4.0 Scripts - and follow directions...

Thanks again! - and sorry for wasting your time - I know it is valuable!
Inspiring
August 26, 2008
This is getting boring. It works for me. Are you following the instructions properly? Did you read the PDF?

Dave
Known Participant
August 26, 2008
Yes but I think the text file your set up script makes is not linking correctly?
Inspiring
August 26, 2008
They are CS2 scripts, you know. Did you put them in the Version 4.0 Scripts folder?

Dave
Known Participant
August 26, 2008
I was able to download the script and connect to your site. - Still having trouble getting the script to work in CS3 on a MAC?
Larry G. Schneider
Community Expert
Community Expert
August 25, 2008
Works here in CA too.
Inspiring
August 24, 2008
Thanks Peter.

Dave
Peter Kahrel
Community Expert
Community Expert
August 24, 2008
No problem connecting to your site from the other side of the pond.

Peter