Need a Geany (Thanksgiving) Miracle  [Solved]

Message
Author
User avatar
operadude
Posts: 1072
Joined: Tue Nov 05, 2019 12:08 am

Re: Need a Geany (Thanksgiving) Miracle

#11 Post by operadude »

Addendum:

Looks like I was barking-up the wrong tree about the whole "jshint"-thing missing.

I get something very similar when I "Lint" the following Python program:
geany_python_01.png
And, yet, when I press F5, or hit the "Run" button, the program DOES execute properly:

Code: Select all

3.11.2 (main, Mar 13 2023, 12:18:29) [GCC 12.2.0]
------------------
(program exited with code: 0)
Press return to continue
I know that the "Build" commands are completely different for Python, but here they are, anyway:
geany_python_02.png
Is it possible that for JavaScript the "Execute" command is missing a program name, such as, "javascript"? By default (also in the .config files, both in /home and in /usr/share/geany), the Execute command does not have any leading program name to execute the file, just the filename alone?!?

Again, here are the (default) Build commands for JavaScript in Geany:
JavaScriptBuildCommands.png
I don't know the inner workings of Geany, but for Scripting languages, I thought that in the Execute command, there should be a program name that precedes the filename, as in:

Code: Select all

Python3 "%f"
Or:

Code: Select all

ruby "%f"
And, yet, for JavaScript, for Execute, there's only this:

Code: Select all

./%e
:confused:
You do not have the required permissions to view the files attached to this post.

User avatar
l0dr3
Posts: 463
Joined: Wed Jun 28, 2023 11:06 am

Re: Need a Geany (Thanksgiving) Miracle  [Solved]

#12 Post by l0dr3 »

operadude wrote: Fri Nov 24, 2023 7:15 am What I want is the output generated by running the above code; not the code itself.
When I try to execute or run the code (button or F5), I get this:

I really don't want to have to install that huge Node.js (and npm) package, just to be able to try-out a few, very short, JavaScript (.js) programs within Geany.

Maybe I'll need a different editor. Was really hoping not to have to install Visual Studio Code, but maybe it'll be worth it in the long run.
Use 'F8' in the example given ;)

You really don't need VSCode or any node.js or even npm stuff, to tryout some simple js-code-snippets on a js-console,
you just have to follow some simple rules of html and you need nothing else then a browser with dev-tools integrated - as FF is, of course :fox:

First of All: surround your js-code with <script> .. </script> tags!

Do it like this (this enhances the example i gave above ...)

Code: Select all

<!DOCTYPE html>
<html>
<body>

<h2>What Can JavaScript Do?</h2>

<p>JavaScript can change HTML attribute values.</p>

<p>In this case JavaScript changes the value of the src (source) attribute of an image.</p>

<button onclick="document.getElementById('myImage').src='pic_bulbon.gif'">Turn on the light</button>

<img id="myImage" src="pic_bulboff.gif" style="width:100px">

<button onclick="document.getElementById('myImage').src='pic_bulboff.gif'">Turn off the light</button>

</body>

<script>
let x = 1
let y = 2
let z = 3
console.log("x:", x, "y:", y, "z:", z)
<!-- console.log("javascript version =", js_version) -->
let js_version = 123456
console.log("javascript version =", js_version)
console.log( {x, y, z} )

</script>
</html>
To switch to console in FF - just press F12, and allign (tm 'dock') the console window to the left ... see screenshot below ...
:
Screenshot_2023-11-24_14-19-21.jpg
:
When you change the code in geany, save again to the same html-file, switch to the already opened FF instance and just ReFresh the view (F5 or Ctrl-R in FF) :crossfingers:

The reason for the error in your given single-line code-snippet was, that 'js_version' isn't defined at runtime of the code. Try it with the above definition added before the call ...

HTH, good luck, greetz l0dr3

btw: example above and more can be found at https://www.freecodecamp.org/news/javas ... ole-in-js/ ,
and W3Schools Beginners Tutorials at https://www.w3schools.com/ are a very comprehensive source for making the first steps in any scripting or programming language, IMHO :popcorn:
You do not have the required permissions to view the files attached to this post.
Last edited by l0dr3 on Fri Nov 24, 2023 9:46 am, edited 1 time in total.

User avatar
operadude
Posts: 1072
Joined: Tue Nov 05, 2019 12:08 am

Re: Need a Geany (Thanksgiving) Miracle

#13 Post by operadude »

@l0dr3 :

Thank you very much for the detailed description and links !!!

Will take a look at all of this later, and get back to you.

Long weekend, family, etc., etc., etc. !!!!

User avatar
l0dr3
Posts: 463
Joined: Wed Jun 28, 2023 11:06 am

Re: Need a Geany (Thanksgiving) Miracle

#14 Post by l0dr3 »

operadude wrote: Fri Nov 24, 2023 9:09 am @l0dr3 :

Thank you very much for the detailed description and links !!!

Will take a look at all of this later, and get back to you.

Long weekend, family, etc., etc., etc. !!!!
:happy: have a nice weekend! :popcorn:

User avatar
operadude
Posts: 1072
Joined: Tue Nov 05, 2019 12:08 am

Re: Need a Geany (Thanksgiving) Miracle

#15 Post by operadude »

@l0dr3 :number1:

Tried your examples, and within a few minutes, figured-out what to do; so THANKS!!!

First step is to create an HTML file (Set Filetype) within Geany, add this to the top:

Code: Select all

<!DOCTYPE html>
<html>


<script>
Insert my JavaScript code, such as:

Code: Select all

const num1 = 5;
const num2 = 3;

// add two numbers
const sum = num1 + num2;

// display the sum
console.log('The sum of ' + num1 + ' and ' + num2 + ' is: ' + sum);

And then add this after the JS code:

Code: Select all


</script>
</html>
Finally, I can simply copy the file from Thunar, and paste (and go) in Firefox.
Alternatively, I can double-click the file in Thunar, which has a .html extension, and Firefox opens it. Firefox shows:

Code: Select all

file:///home/opera-dude/Documents/test2.html
Then, as you say, hit F12, giving me the console, and the desired output at the bottom:

Code: Select all

The sum of 5 and 3 is: 8
So, yeah, very handy :exclamation:

I also realized that there are a number of on-line sites/programs/editors that can run my JavaScript code, such as PythonTutor.com , Programiz.com , etc.

But, I like your method much better. It looks to me that I don't even have to be online; as long as the Firefox program is running, it will execute my code!

Awesome, and Many Thanks :clap: :clap: :clap:

I have a couple of questions about your post that explained the "docking", but I'll follow-up a bit later about that. In the meantime, I will mark this as "Solved".

:cool:

Post Reply

Return to “Software / Configuration”