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

INDESIGN TEMPLATE INSERT DATE CS3 PROMBLEM

New Here ,
Aug 21, 2008 Aug 21, 2008
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

--------------------------------------------------
TOPICS
Scripting
3.8K
Translate
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
Participant ,
Aug 21, 2008 Aug 21, 2008
It's a CS2 script. Try putting it into a folder named "Version 4.0 Scripts" (without the quotes). It should run from there.

Dave
Translate
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
New Here ,
Aug 21, 2008 Aug 21, 2008
Tried it and got nothing on one template and a error on a different template.

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

JavaScript Error!

Error Number: 24
Error String: getCurPrefs is not a function
Lin: 11
Source: curPrefs = getCurPrefs(File
(getScriptPath().absoluteURl.replace(/Insert\.jsx/,
"Prefs.txt")));
Interpreter: CS2 (4.0)

-------------------------------------
Translate
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
Participant ,
Aug 22, 2008 Aug 22, 2008
That suggests that you've lost part of the script. The getCurPrefs call is right there in the script but I don't see the function, so the error message is spot on.

Dave
Translate
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
New Here ,
Aug 22, 2008 Aug 22, 2008
Here is the problem-O

it works perfectly in CS2. same script. Maybe CS3 did something to the template so the script can't work?
Translate
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
Participant ,
Aug 22, 2008 Aug 22, 2008
If that script, as posted, works on CS2, then you have a magic CS2. The getCurPrefs function is missing. The script, as posted, cannot work.

Dave
Translate
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
New Here ,
Aug 22, 2008 Aug 22, 2008
Here the script is again... Don't know what to say? it works in CS2

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

//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());
app.findPreferences = app.changePreferences = null;
aDoc.search("", true, true, 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
Translate
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
New Here ,
Aug 22, 2008 Aug 22, 2008
Hey you wrote this script! wow... I guess you wrote the magic script!
Translate
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
New Here ,
Aug 22, 2008 Aug 22, 2008
Ok - no magic - it must be my error, I just don't know what I'm doing - any help would be great! - I tried to go to your old website but it's not up?
Translate
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
Community Beginner ,
Aug 22, 2008 Aug 22, 2008
Just a thought...
Rather than using the script, why don't you try just adding the date/time using the text variables that are built in to CS3?
It's under Type > Text Variables > Insert Variable(s)...
You could add it to your template and not have to worry about it.

Good Luck!
TJV
Translate
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
New Here ,
Aug 22, 2008 Aug 22, 2008
The script is much better from what I can tell. It give you more control - you can enter future dates next weeks or next day. Is it possible to do this with Insert Variables?
Translate
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
Participant ,
Aug 23, 2008 Aug 23, 2008
Like I said last night. The script doesn't work on CS2. I just fired it up and ran it against CS2 and, no surprise, it gives the error on line 11 that getCurPrefs is not a function.

You have no chance of getting this version of the script running.

It does look like one of mine, although I have no recollection of it.

Oh wait. I think this script is supposed to be run after the setup script. The setup script sets the dtprefs label and so the absence of the function is usually never a an issue.

You probably got it by downloading:

http://pdsassoc.com/downloads/DateScripts.zip

except that this version you're posting is a cut down version of the DateTimeInsert.jsx script (perhaps an early version). The getCurPrefs function is present in the real script.

Dave
Translate
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
New Here ,
Aug 23, 2008 Aug 23, 2008
That link ( http://pdsassoc.com/downloads/DateScripts.zip ) no longer works? - yes you are the author!
Translate
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
Participant ,
Aug 23, 2008 Aug 23, 2008
Works for me.

Dave
Translate
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
New Here ,
Aug 23, 2008 Aug 23, 2008
Your site won't load too? http://www.pdsassoc.com

maybe have someone else test it.
Translate
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
Participant ,
Aug 23, 2008 Aug 23, 2008
That also works for me and I'm accessing it through optimum online here in NJ and it's hosted by Powweb in CA (I believe).

Dave
Translate
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
Community Beginner ,
Aug 23, 2008 Aug 23, 2008
Hi Dave:

I tried to get to your site several different ways and I couldn't connect to it either. Your blog site still works fine, but PDS Associates is not connecting.

Thanks!
TJV
Translate
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
Participant ,
Aug 23, 2008 Aug 23, 2008
Thanks for trying, Theresa, and I'm really puzzled. I have no special connection to it and yet it works for me.

Oddly, getting through to this forum has been a challenge for me. I am getting frequent failures to connect here and yet I have no trouble with anywhere else.

I wonder if it has something to do with all this fancy caching that every service provider seems to be indulging in these days.

Dave
Translate
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
Community Expert ,
Aug 24, 2008 Aug 24, 2008
No problem connecting to your site from the other side of the pond.

Peter
Translate
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
Participant ,
Aug 24, 2008 Aug 24, 2008
Thanks Peter.

Dave
Translate
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
Community Expert ,
Aug 25, 2008 Aug 25, 2008
Works here in CA too.
Translate
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
New Here ,
Aug 26, 2008 Aug 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?
Translate
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
Participant ,
Aug 26, 2008 Aug 26, 2008
They are CS2 scripts, you know. Did you put them in the Version 4.0 Scripts folder?

Dave
Translate
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
New Here ,
Aug 26, 2008 Aug 26, 2008
Yes but I think the text file your set up script makes is not linking correctly?
Translate
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
Participant ,
Aug 26, 2008 Aug 26, 2008
This is getting boring. It works for me. Are you following the instructions properly? Did you read the PDF?

Dave
Translate
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