Skip navigation
Currently Being Moderated

[JS CS3] BridgeTalk : bt.body = x.toSource() vs a bt.body = a String

Jul 27, 2009 1:26 PM

Hi,

I found a script on this page

http://d.hatena.ne.jp/kamiseto/

 

The author uses this line :

bt.body = toInDesign.toSource()+"("+contents.toSource()+","+gb.toSource()+","+kumi.toSource()+");";

I tried to use this syntax and my script didn't produce any result.

I found another approach based on an old Harbs's post. The syntax is like :
theScript = "...";
theScript += "...";
bt.body = theScript;
And it runs well.

However, as I don't like to saty ignorant, what is the reason of the toSource() error ?

Thanks in advance for explanation.

Loic

 
Replies
  • Currently Being Moderated
    Jul 27, 2009 3:00 PM   in reply to Loic_aigon

    It looks to me as if "toSource" uses a single static buffer!

     
    |
    Mark as:
  • Currently Being Moderated
    Jul 28, 2009 3:34 AM   in reply to Loic_aigon

    I tried to write a sample to show this kind of error in pure javascript, using something like

     

    var buf;
    alert ("What happens now? "+fn("a", buf)+fn("b", buf));
    newstr = "And now?"+fn("c", buf);
    newstr += fn("d", buf);
    alert (newstr);
    function fn (str, dest)
    {
     dest = "["+str+"]";
     return dest;
    }
    

     

    -- but I couldn't get it not to work ...

     

    I recognized the symptoms because I also write in the programming language C/C++, and there it's perfectly possible to mess up a program with such constructions. Done that a dozen times and more. I think the correct approach of writing such routines is called "thread-safe" (since the same problem occurs in a multi-threading environment, where each function needs a buffer for itself, even if that same function is called twice).

     

    Oh, enough with the side tracking.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points