This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

  • Resolved

write to a result file, from js command prompt

Prodigy 120 points

Replies: 4

Views: 1688

hi,

I am new to javascripting and ccs.

I have taken the example file (Breakpoints.js) provided by TI . I am giving it as input from my scripting console. Say, for example, my js has a statement similar to one below:

         nPC = debugSession.expression.evaluate("PC")

Now my quesiton is, how to write the value of "nPC" into a ".res" ( or any .txt file - basically some result file) file. Also guide me on how to create the .res file, using js.

 

Thanks for your reply in advance,

Regards

Sudheer.

  • Guru 301240 points

    Hello Sudheer,

    JavaScript itself does not have much support for file i/o type functionality. Java does however. Since it is pretty simply to call Java APIs from JavaScript, you can use the java.io.file APIs from your script. You'll need to import the java.io.file package first.

    http://docs.oracle.com/javase/6/docs/api/java/io/File.html

    For an example, you can take a look at this javascript include file which I created long ago.

    http://winsvn.sanb.design.ti.com/winsvn/filedetails.php?repname=apps&path=%2Fdss%2Ftrunk%2Finclude%2FFileSystemJava.js

    This is a JavaScript include file created to abstract the java calls. You can use this include file and then create a file system object like:

    load("FileSystemJava.js");
    var fso = new FileSystem();
    var myFile = fso.fileWriterOpen("C:\\Temp\\myFolder\\file.txt", false);
    fso.write(myFile, "Hello\n");

    fso.fileClose(myFile);

    Thanks

    ki

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

    Did you read the CCS Forum Guidelines & FAQ? If not, PLEASE read it. If you haven't read it in awhile, please read it again to see if any updates were made.

    Having CCS problems? Check out the CCS Troubleshooting Guide

    Looking for CCS Training/Documentation? Check out the CCS Resources page

    Curious about the status of a bug and know the tracking ID? Track it via the public bug tracking portal

    NOTE: When a bug is filed and a tracking ID is provided, the thread may then be suggested as "TI Thinks Resolved". Why? Please read the first FAQ of the CCS Forum Guidelines & FAQ

  • In reply to Ki:

    Hi Ki,

    Thanks for the reply.

    However, I am unable to open Javascript Include File link. The link is unavailable.

    Could you please attach the include file?

    Thanks in advance.

     

    Regards

    Sudheer.

  • Guru 301240 points

    In reply to sugam sudheer:

    I think that was an internal url. Sorry about that. I attached the file here (renamed as txt)

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

    Did you read the CCS Forum Guidelines & FAQ? If not, PLEASE read it. If you haven't read it in awhile, please read it again to see if any updates were made.

    Having CCS problems? Check out the CCS Troubleshooting Guide

    Looking for CCS Training/Documentation? Check out the CCS Resources page

    Curious about the status of a bug and know the tracking ID? Track it via the public bug tracking portal

    NOTE: When a bug is filed and a tracking ID is provided, the thread may then be suggested as "TI Thinks Resolved". Why? Please read the first FAQ of the CCS Forum Guidelines & FAQ

    FileSystemJava.txt
  • In reply to Ki:

    Thanks a lot Ki. That worked.

This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.