Discussion:
Startup script launches itself 3 times (without no loop inside) !!!
(too old to reply)
loic_aigon
2008-09-10 10:42:54 UTC
Permalink
Hi I am facing a curious behavior.
If I put a script in the startup script so the script is persistent throught the session, I notice that the script is executed 3 times.
For example, If I put an alert, it appears three times. I click ok, it comes back, ok, it comes back, I click ok then the alert does not come back again.
That's annoying.
Is there anything to avoid that ?
Thanks for helping.
Regards,
Loic
try67
2008-09-10 16:25:04 UTC
Permalink
Could you post the script here? Do you have any other startup scripts installed?
O***@adobeforums.com
2008-09-10 19:45:28 UTC
Permalink
Hi Loic,

Where, exactly, are you putting the startup script?

Thanks,

Ole
loic_aigon
2008-09-11 07:09:50 UTC
Permalink
Hi all,
Here is the script :

Olav, I put the script in this folder on my Windows Xp at the office.
C:\Program Files\Fichiers communs\Adobe\Startup Scripts CS3\Adobe InDesign\
At home I have a Mac and tried to place the script in the startup scripts folder located in the Indesign main folder's subfolders (Export as Xhtml...).
On the mac, I am not prompted but the script only work a few then do nothing more.

#targetengine "session"
logfiles();
function logfiles()
{
var myApplicationEventListener = app.eventListeners.add("afterOpen",myEventInfo, false);
}
function myEventInfo(myevent)
{
var apppath = app.filePath;
var doc = app.documents[0];
//myevent.parent;
//app.documents[-1];
//app.open(File(myevent.parent.fullName));
//Try all these options without any changes

var filename = doc.name;
var filepath = doc.fullName;
var mydate = new Date;
var myday= mydate.getDate();
var mymonthlst = ["Janvier", "Fevrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Aout", "Septembre", "Octobre", "Novembre", "Decembre"]
var mymonth = mymonthlst[mydate.getMonth()];
var myyear = mydate.getFullYear();
if(myday>15)
{
var monthsdaysnb = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
var M = monthsdaysnb[0];
var D ="16-"+M;
}
else
{
var D = "1-15";
}
var mylogsfolderpath=apppath+"/logsfolder";
var logsfolder = new Folder(mylogsfolderpath)
logsfolder.create();
var mylogfile = logsfolder +"/fileslog_"+D+"_"+mymonth+"_"+myyear+".txt";
if(File(mylogfile).exists==false)
{
var fileslog = new File(mylogfile);
}
else
{
var fileslog = File(mylogfile);
}
fileslog.open("r");
var fileslogcontent = fileslog.read();
if(fileslogcontent.indexOf(filename)==-1)
{
fileslog.open("e");
fileslog.seek(0,2);
fileslog.writeln (filename+"\r"+filepath);
fileslog.close();
}
}

Hope you can bring me the light :-)

thx a lot in advance
Loic
Kasyan Servetsky
2008-09-11 10:27:51 UTC
Permalink
Hi Loic ,

I just put your script inside D:\Program Files\Adobe\Adobe InDesign CS3\Scripts\Startup Scripts folder on my PC and it seems to be working as expected.
Or you can put it into User folder:
C:\Documents and Settings\Kasyan\Application Data\Adobe\InDesign\Version 5.0\Scripts\Startup Scripts

Folders like C:\Program Files\Common Files\Adobe\Startup Scripts CS3\Adobe InDesign are intended for scripts installed by applications, not by users.

Kasyan
loic_aigon
2008-09-11 13:09:58 UTC
Permalink
Hi Kasyan,
I tried what you offered me to do. It seems endless. I am really desperate now.
Now the script do not even work once and prompt immediatly for a error alert saying :

javascript error #30476 the action couldn't be achieved because the object doesn't exist anymore. (sorry for the language, it's frenglish)

It seems that this alert comes twice cause when I click ok, it prompt me once again.

I am still looking on my side and start thinking I won't ver get the magic key :-(

Thanks you for having considered the question.
Loic
Kasyan Servetsky
2008-09-11 15:13:30 UTC
Permalink
Loic,

I tested your script again, at my work this time, on Mac and PC, it works for me: creates logsfolder if it doesn’t exist, creates file (e.g. fileslog_1-15_Septembre_2008.txt) and writes file name and path of opened file to it.
I was able to reproduce the exact error you have by putting the script into the wrong place (C:\Program Files\Common Files\Adobe\Startup Scripts CS3\Adobe InDesign).

Kasyan
loic_aigon
2008-09-11 15:22:48 UTC
Permalink
Ok Kasyan,
I must have offended a egyptian sanctuary and so I am damned for eternity :-(
Thanks for your help anyway. At least I know it runs, except at my place.
Maybe rebooting the PC will trash some temp files that annoy me.
I stop bugging you so.
Thanks once again.
Loic
O***@adobeforums.com
2008-09-11 17:58:16 UTC
Permalink
Hi Loic,

Please double-check the ExtendScript startup script directory for copies of your script--if you put it there, as Kasyan says (thanks, Kasyan!), you'll get exactly the error you report. Again, this is the WRONG place to put the script (where "~" is your drive):

~\Program Files\Common Files\Adobe\Startup Scripts CS3\Adobe InDesign

The RIGHT place to put the script is:

~\Program Files\Adobe\Adobe InDesign CS3\Scripts\Startup Scripts

Thanks,

Ole
loic_aigon
2008-09-11 18:48:18 UTC
Permalink
Hi Kasyan & Olav,
Thanks a lot to you guys.

Kasyan, you ironically first make me feel depressed cause Icouldn't understand why I was like the only one that couldn't make it run properly. But in the same time, it was nice to know that the main part, the script, was working.

Olav, your last remark about ExtendScript startup script directory was a good hint. I digged on this way and finally reviewed the
Adobe InDesign CS3 Scripting Tutorial.pdf that precise the path :

Mac OS: ~/Library/Preferences/Adobe InDesign/Version 5.0/Scripts

Windows XP: ~\Documents and Settings\user_name\Application Data\Adobe\InDesign\Version 5.0\Scripts

To run a specific script when InDesign starts, put the script inside a folder named “Startup Scripts” inside the Scripts folder (create this folder if it does not already exist).

So after placing my script there, it seems that the script on my mac at home runs well. I will check on my PC at the office but it shouldn't be a trouble any longer. I hope so.
I won't be at the office till Monday so I won't be able to give you a feedback for windows before but whatever happens I will keep you in touch.

Thanks you a lot. That was so frustrating. I was close to cry really.

Loic
loic_aigon
2008-09-15 15:55:37 UTC
Permalink
Hi Olav & Kasyan,
I have bad news.
Put the script here and in my office's windows XP, it still refuse to run properly bugging for javascript error 30476.

C:\Documents and Settings\Loic\Application Data\Adobe\InDesign\Version 5.0\Scripts\Startup Scripts\Raccourci vers write_files_log.jsx

FYI
Loic
O***@adobeforums.com
2008-09-15 18:18:02 UTC
Permalink
Hi Loic,

So it's a difference between your home machine and your office machine. The first thing to suspect: permissions. Are you logged in as an Administrator on your work machine?

Thanks,

Ole
loic_aigon
2008-09-15 20:28:02 UTC
Permalink
Hi Olav,
I will have a look tomorrow at the office and let you know.
I have a lot of files disseminated on many servers, could you think it could be the source of the issue ?
Thanks for your patience and understanding
Loic
loic_aigon
2008-09-16 08:37:39 UTC
Permalink
Hi Olav,
I checked this morning and noticed I am on a administrator machine with all priviledges.

I don't know if it can help but :

var mytxtfile = new File("/c/Program Files/Adobe/Adobe InDesign CS3/logsfolder/toto.txt");
mytxtfile.open("e");
mytxtfile.write("toto");

through ESTK works fine. The file is created. So I guess I can operate in this folder without restrictions.

Thanks for your care.

Loic
loic_aigon
2008-09-17 14:36:41 UTC
Permalink
Hi Olav, Kasyan,
Just to close the book, it finally works on my office machine.
I don't know what happened special but after many attempts to make it run, it finaly started.
I have no explanation but I am glad to get it at end.
Thanks for all your time and efforts to help me.
Loic
Kasyan Servetsky
2008-09-17 15:23:47 UTC
Permalink
Loic,

It makes me glad to hear that it works at last, although the mystery still remains unsolved.

Kasyan

Loading...