LastLogEntry bug

Discussion of the xtools Toolkit

Moderators:xbytor, DavideBarranca, Paul MR

Post Reply
undavide
LastLogEntry bug

Post by undavide » Wed Apr 13, 2011 9:13 pm

Hello,
it seems LastLogEntry.jsx always eats the first letter of the ScriptingListener output.
For instance:

Code: Select allvar idMk = charIDToTypeID( "Mk  " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref41 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref41.putClass( idLyr );
    desc40.putReference( idnull, ref41 );
executeAction( idMk, desc40, DialogModes.NO );

becomes

Code: Select allar idMk = charIDToTypeID( "Mk  " );
    var desc40 = new ActionDescriptor();
    var idnull = charIDToTypeID( "null" );
        var ref41 = new ActionReference();
        var idLyr = charIDToTypeID( "Lyr " );
        ref41.putClass( idLyr );
    desc40.putReference( idnull, ref41 );
executeAction( idMk, desc40, DialogModes.NO );

Digiting the missing letter and then clicking the "Fix" button, gives a similar error:

Code: Select allfunction ftn1() {
  function cTID(s) { return app.charIDToTypeID(s); };
  function sTID(s) { return app.stringIDToTypeID(s); };

ar undefined = charIDToTypeID( "Mk  " ); // missing "v"
    var desc40 = new ActionDescriptor();
        var ref41 = new ActionReference();
        ref41.putClass( cTID('Lyr ') );
    desc40.putReference( cTID('null'), ref41 );
    executeAction( undefined, desc40, DialogModes.NO );
};

Regards,
Davide

xbytor

LastLogEntry bug

Post by xbytor » Wed Apr 13, 2011 9:26 pm

Which version of PS and what OS is this happening on? I just tried CS5/Win7 and CS4/OSX without problems.
I know there's a work-around for a File.readln bug that may be related.

undavide

LastLogEntry bug

Post by undavide » Wed Apr 13, 2011 9:45 pm

Sorry for not having specified it first - OSX 10.6.7 and CS5

Davide

xbytor

LastLogEntry bug

Post by xbytor » Wed Apr 13, 2011 11:17 pm

You may have an old version that doesn't have the bug fix. The core function getLastLogEntry should look like this:

Code: Select allStdlib.getLastJSLogEntry = function(fptr) {
  if (fptr) {
    fptr = Stdlib.convertFptr(fptr);
  } else {
    fptr = new File("/c/ScriptingListenerJS.log");
    if (!fptr.exists) {
      Error.runtimeError(Stdlib.IO_ERROR_CODE, "Unable to find SLC log.");
    }
  }

  fptr.open("r", "TEXT", "????") || throwFileError(fptr, "Unable to open");
  //fptr.lineFeed = "unix";

  fptr.seek(1, 2);  // start of at the end of the file
  var prev = fptr.readch();

  for (var i = 2; i < fptr.length; i++) {
    fptr.seek(i, 2);  // start of at the end of the file
    var c = fptr.readch();
    if (c == '\n' && prev == '/') {
      break;
    }
    prev = c;
  }
  if (i == fptr.length && prev != '/') {
    return undefined;
  }

  fptr.readln();

  // XXX recheck for CS5+
  if (!isCS() && !isCS2() && !isCS3()) {
    // XXX There is a bug in CS4 that causes the previous readln to
    // read one too many characters. This looks for the bug and works
    // around it.

    var loc = fptr.tell();
    var str = fptr.read();

    if (str[0] == 'a') {
      fptr.seek(loc-1);
      str = fptr.read();
    }

  } else {
    var str = fptr.read();
  }
  fptr.close();
  return str;
};

Check to see if that's what you have. It checks fine on CS5/OSX here.

undavide

LastLogEntry bug

Post by undavide » Thu Apr 14, 2011 12:57 pm

Hi,
just installed from here: http://sourceforge.net/projects/ps-scri ... p/download ... p/download

Should be 1.7.5 nevertheless installer says it's version "1.6b2" (and the bug still exists)
Thanks

Davide

xbytor

LastLogEntry bug

Post by xbytor » Thu Apr 14, 2011 4:04 pm

I've fixed the problem for CS5 since the last packaged release that I uploaded.

I'll take a snapshot of what is currently laying on my dev disk and put that on sourceforge. It's been a year, after all.

The alternative is to use the CVS repository. It is always relatively up-to-date. It has to be, because I use it myself.
My xtools dev box is a MacPro and I have a local CVS repository there. From there, I check files in to sourceforge.
My other machines get their xtools trees from sourceforge. I eat my own dog food, so to speak. This way, if there
is a problem with the xtools files on sourceforge, I know about it pretty quick.

undavide

LastLogEntry bug

Post by undavide » Thu Apr 14, 2011 6:32 pm

Hi X,
downloaded and installed from CVS repository - the updated code (while it keeps saying it's v1.6b2 - not an issue at all) works perfectly! And by the way the first variable of the fixed code is no more:

Code: Select allvar undefined

but

Code: Select allvar desc94

or something like this.
Thank you as always!

Davide

xbytor

LastLogEntry bug

Post by xbytor » Thu Apr 14, 2011 7:25 pm

it keeps saying it's v1.6b2

I probably need to update the installation script or something...

Post Reply