Tagged: Interactive console, JavaScript, node.js
- This topic has 7 replies, 3 voices, and was last updated 8 years, 4 months ago by support-piotr.
-
AuthorPosts
-
patwillardParticipantI 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.
support-swapnaModeratorpatwillard,
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 :
For an overview about JavaScript debugging support in MyEclipse, please refer to this tutorial :
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
patwillardParticipantHi, 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.
support-piotrParticipantHi 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.
- Open Terminal View: Window > Show view > Other > type “Terminal”
- In the Terminal View click on blue monitor icon to open new terminal and choose “Local Terminal”. You may customize encoding if needed.
- 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:
- Open Window > Preferences
- Type “node.js” in the filter view and select “Node.js” node under “MyEclipse/JavaScript/Tern/Server”
- Copy contents of “Node.js path” field and close window
- In terminal view type quote
"
, paste the path (right click -> Paste), type quote"
again and press enter
- Now the terminal has node.js running in interactive mode. If you need to restart console simply press “CTRL+C” twice or type “.exit”
- To simplify launching node.js in interactive mode, you can use Snippets view to store command path.
- Open Window > Show View > Snippets
- Right click in the view and choose Customize
- Choose New > Category
- Name it “Terminal commands”
- Right click on the new category and choose New > New Item
- 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
- Click “Apply”
- 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, 4 months ago by support-piotr.
Attachments:
You must be logged in to view attached files.
patwillardParticipantHi 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.
support-piotrParticipantHi 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!
patwillardParticipantHi 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
support-piotrParticipantPat,
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 -
AuthorPosts