facebook

interactive JavaScript console

  1. MyEclipse IDE
  2.  > 
  3. General Development
Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #489978 Reply

    patwillard
    Participant

    I am writing JavaScript programs without a UI. I have been unable so far to find any information (or by trial and error) on an interactive JavaScript console in MyEclipse.

    Can someone let me know how to do this?
    Thanks much.

    #490078 Reply

    support-swapna
    Moderator

    patwillard,

    Are you referring to an interactive console during debugging a JavaScript application? You can use the Display view (Window > Show View > Display) to execute code in debug mode in the scope of the current breakpoint (to evaluate expressions or to change data).

    If you are referring to code/content assist while coding, then please take a look at this tutorial which outlines the JavaScript development in MyEclipse :

    JavaScript Development in MyEclipse

    For an overview about JavaScript debugging support in MyEclipse, please refer to this tutorial :

    Debugging JavaScript in MyEclipse

    If you have a different requirement, then please elaborate what exactly you are looking for.Please provide us with references to the feature.

    Let us know if you have any questions.

    –Swapna
    MyEclipse Support

    #490098 Reply

    patwillard
    Participant

    Hi, Thanks for your prompt response. Providing you with more detail, let’s say I have a very simple JavaScript file titled gethello.js as follows:

    var getHelloTo;

    getHelloTo= function(name) {
    return “Hello to ” + name;
    }

    At some sort of terminal (within MyEclipse), I want to call the method in this file with getHelloTo(“my friends”), and have the terminal respond immediately with “Hello to my friends”.

    It would be like having the js file running in a non-terminated state, listening for commands and responding as the commands are given.

    #490195 Reply

    support-piotr
    Participant

    Hi Pat!

    This is a very interesting use case and we will be looking into adding it as a functionality. For now I will provide you with a little workaround.

    1. Open Terminal View: Window > Show view > Other > type “Terminal”
    2. In the Terminal View click on blue monitor icon to open new terminal and choose “Local Terminal”. You may customize encoding if needed.
    3. Now you just need to locate you node.js installation and execute in the terminal console “node.exe” or “node” depending on your platform. MyEclipse ships with node.js installation and you can find the path in following way:
      1. Open Window > Preferences
      2. Type “node.js” in the filter view and select “Node.js” node under “MyEclipse/JavaScript/Tern/Server”
      3. Copy contents of “Node.js path” field and close window
      4. In terminal view type quote ", paste the path (right click -> Paste), type quote " again and press enter
    4. Now the terminal has node.js running in interactive mode. If you need to restart console simply press “CTRL+C” twice or type “.exit”
    5. To simplify launching node.js in interactive mode, you can use Snippets view to store command path.
      1. Open Window > Show View > Snippets
      2. Right click in the view and choose Customize
      3. Choose New > Category
      4. Name it “Terminal commands”
      5. Right click on the new category and choose New > New Item
      6. Name the item “Run node.js in interactive mode” and in the template field paste the command. Remember to add quotes at the beginning and the end. If you add enter after the command, it will be automatically executed when applied to Terminal View
      7. Click “Apply”
    6. Now you can simply drag and drop “Run node.js in interactive mode” to your Terminal View.

    Let us know how the workaround worked for you!

    • This reply was modified 8 years, 5 months ago by support-piotr.
    Attachments:
    You must be logged in to view attached files.
    #490443 Reply

    patwillard
    Participant

    Hi Piotre,
    Thanks for this. It does work as a work-around.

    I appreciate you moving this to the enhancement requests queue. I used to be a product manager in software for 15 years and I know it could take forever or never 🙂

    Last question: Looking at your screenshot, and comparing it to mine, how did you get the raft of messages from node.js following the “{” to not show as in my screen. See attachment.

    Attachments:
    You must be logged in to view attached files.
    #490592 Reply

    support-piotr
    Participant

    Hi Pat!

    > Thanks for this. It does work as a work-around.

    That’s great!

    > I used to be a product manager in software for 15 years and I know it could take forever or never ?

    It happens, but the thing is that such improvements are what makes Webclipse or MyEclipse special, so I think it won’t be that long 😉

    > how did you get the raft of messages from node.js following the “{” to not show as in my screen

    Truth is, I haven’t done anything… I just pressed ENTER at the end of the line and typed the next one. Maybe you’ve pasted TAB character which resulted in node.js trying to assist you with global variable name? It does have nice dynamic content assist on TAB 🙂 I hope this is the case!

    Let me know if you have any questions!

    #490640 Reply

    patwillard
    Participant

    Hi Piotre,
    Regarding the “assist with global variable names” following “{“, you are correct about the TAB entry. What I was doing was copying the entire javascript file from the MyEclipse file window into the terminal. The file was format (with ‘hidden’ tabs) as MyEclipse does by default. Removing these manually and copy-pasting again solved the “assist with global variable names.”

    Thanks again.
    Cheers,
    Pat

    #490787 Reply

    support-piotr
    Participant

    Pat,

    That’s great. It also means that such an interactive console should allow for easy paste of the code containing TABs. We will be looking into providing the feature.

    Best regards,
    Piotr Tomiak

Viewing 8 posts - 1 through 8 (of 8 total)
Reply To: interactive JavaScript console

You must be logged in to post in the forum log in