Help modifying ActionFileToJavascript.jsx

Discussion of the xtools Toolkit

Moderators: xbytor, DavideBarranca, Paul MR

Mike Hale

Help modifying ActionFileToJavascript.jsx

Postby Mike Hale » Thu Jul 18, 2013 4:30 pm

Hi X,

I have to convert several large action sets to javascript. Your script is already very, very, helpful. A lot of the actions have common steps and I noticed that if the script could output the name of the step instead of or in addition to the step's event it would be much easier for me to stop those common steps.

For example now the script might comment a step as // Duplicate. In the action that step is named 'Duplicate first document'. Another may be commented as Select where the step name is 'Select previous document'. Having the step name would let me have a better idea of what the step does than just the event class. It's true it only saves a little time over reading the contents of the step function but with as many actions as I need to convert that adds up.

So my main questions are: Do you think it is possible to comment the step name? And if so where do you think I should look to make that change. I tried stepping through the script but ESTK hangs during binary file read/write on my system.

xbytor

Help modifying ActionFileToJavascript.jsx

Postby xbytor » Thu Jul 18, 2013 9:47 pm

Mike Hale wrote:So my main questions are: Do you think it is possible to comment the step name?

Not sure. I actually have a bug in the action file reader I need to take care of. I'll check while I'm working on the bug.


And if so where do you think I should look to make that change.

The functions JSWriter.write["Action"] and JSWriter.write["ActionItem"] is where the code would need to be modified.

Mike Hale

Help modifying ActionFileToJavascript.jsx

Postby Mike Hale » Thu Jul 18, 2013 11:11 pm

I don't know if it is a bug or not but the actions I am trying to convert where recorded on a different system. A lot of the actions have save or open steps. Unless I edit the action before saving to replace the path recorded in the set the script sometimes throws a ActionStream.ERROR_CODE 'bad path error' error. So far I have been unable to tell before hand when it will fail so I have to search the actions for save or open steps before converting. It would be helpful to me if the script would output undefined, 'invalid path', or something like that for paths it can not convert instead of throwing an error and stopping. I have to modify the paths anyway even when the script completes without errors. Most of the paths are on a user desktop.

Thanks for the info. I will have a look at JSWriter.

xbytor

Help modifying ActionFileToJavascript.jsx

Postby xbytor » Fri Jul 19, 2013 7:47 pm

Mike Hale wrote:It would be helpful to me if the script would output undefined, 'invalid path', or something like that for paths it can not convert instead of throwing an error and stopping.

Can you email me an .atn file that is failing like this? There may be away I can improve the error handling.

Mike Hale

Help modifying ActionFileToJavascript.jsx

Postby Mike Hale » Fri Jul 19, 2013 9:40 pm

Thanks but I'm not sure the script needs that correction now. It seems that it is open steps that cause that error if the path points to a file that doesn't exists. Several of the actions I need to convert ask the user to open one of their files for processing. Instead of inserting a run menuItem step for File-Open the person that recorded the actions just opened one of the files on his system. So it's more a problem with the action than the conversion script.

So I like the fact the script will not convert those actions now that I understand the problem. I will email you a sample atn file in case you want to see why it sometimes converts a step with a bad path and sometimes is throws an error.

xbytor

Help modifying ActionFileToJavascript.jsx

Postby xbytor » Fri Jul 19, 2013 11:20 pm

I've updated the xtools cvs repository on sourceforge. The core of the problem is that some of the time PS stores a Path as an ascii string and other times it will use UTF-16. I was only handling the UTF-16 case.

I also changed the code so that if there is any problem at all reading the path info, it will use "~/BAD_PATH_ERROR.txt" as the file name. This should help things a bit.

If you want exceptions instead, change the variable ActionStream.PATH_ERRORS to true.

Mike Hale

Help modifying ActionFileToJavascript.jsx

Postby Mike Hale » Fri Jul 19, 2013 11:25 pm

Thanks, I grab the update.

I wonder if the Photoshop version or OS is the reason for how the path is stored. I have the impression that the actions I am converting were collected over many years.

xbytor

Help modifying ActionFileToJavascript.jsx

Postby xbytor » Fri Jul 19, 2013 11:48 pm

It gets even more complicated. There is also "Alias" type which is used to store path information in OS specific formats. Since I don't know precisely what those formats are, I have to pick through and find the different parts of the full path. It's an unpleasant bit of code.


Return to “xtools”

Who is online

Users browsing this forum: No registered users and 1 guest