First steps in the JavaScript Programming World by writing the famous Hello World script [Wiki]. This program is very popular and if you are interested, there is a list of implementations in various languages [Wiki].
Here, I assume that your configuration previously described [Link] is fine.
1. Create your first script
Run ImageJ and go toPlugins > New > JavaScript
, a window entitled Script.js
is created , then copy the following code and paste it in the window Script.js :var text = "Hello World!";
IJ.log(text);
Save this file in
File > Save As...
(Fig.1) and choose the location and file name.Note: As I already said [Link], the most convenient way is to store all of your scripts in the directory ImageJ > plugins > CrazyBio_Learning_JS
Fig.1: Save your script by clicking the File > Save As... menu item of the JavaScript window. |
In this window, go to the menu
Macros > Run Macros
or use the shortcut Ctrl + R and a new window Log is displayed with the text Hello World! (Fig.2).Congratulations!! this is your first program. Easy, isn't it?
Fig.2: Result of your Hello World! script. |
In this two-lines script,
- First, we declare a variable named text and assign to it the sentence "Hello World!".
- Second, we print in the ImageJ Log window, the value contained in the variable text thanks to the function IJ.log(...).
<< Previous: Setup of your dev environment Next: Variables >>
Everything is fine, am happy about your blog. Thanks admin for sharing the unique content, you have done a great job I appreciate your effort and I hope you will get more positive comments from the web users.
ReplyDeleteschool branding uk