123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|416|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> JSE -> JSE vs Source Files

Wed, 16 Jul 2025, 12:49
realtime
Does jse support multiple files? I want to put some of my code into a separate file that I want to use later

-=-=-
BASIK
Wed, 16 Jul 2025, 12:49
Jayenkai
Nope, 'fraid not. Everything goes in one big box!

-=-=-
''Load, Next List!''
Wed, 16 Jul 2025, 15:04
Dan
It is fairly easy to export the entire JSE library and to extract the single game from there.
Thu, 17 Jul 2025, 00:40
Pixel_Outlaw
Global variables would probably stomp each other too between files.
You might be able to do package/module scope though with a prefix on the globals...
The idea would be that you generate new globals with a different name and the user's variables get silently prefixed for that module.

So if you have a package foo and a package bar, you get foo:a and bar:a.
If the user just had "a" it first gets looked up in the package it's in.
Otherwise they can explicitly use prefixes from other packages.
Thu, 17 Jul 2025, 02:59
Jayenkai
Not the reason. I couldn't give a rats arse about the fact that everything's a global.
The reason is..

1. JSE was designed to be easily portable to forums, hence why everything, from code to graphics to sound, is all code based. So it's all inside one script, and that can be copy+pasted directly to a forum post.

2. If you use 2 scripts, just two.. You get this..

-=-=-=-

Main.jse


Second.jse


To use this, save Main.jse as Main.jse and then Second.jse as Second.jse

-=-=-=-

And then the end user has to go through their own stuff, make sure nothing's already Main and Second, rename if necessary, then copy two lots of code over, ensure they're the right names, and THEN finally get around to clicking the run button.

That's NOT the ease of use that JSE was designed for, and that's exactly why this doesn't happen.

It was Pakz trying to show us a "quick" example in Godot's Online version, where we had to download the code and the image, package it into a zip with the right filenames, then upload the zip, then hit run, which inspired me to make JSE function like this.


...Anyway...

I left this bobbling about in my head overnight, and the concept of "Folding" seemed somewhat appropriate to this methodology. Now, whether that copy+pastes well, that's a whole other matter. (See also, syntax highlighting)
Maybe I'll have to interject when the browser receives a "Copy", and do my own thing, and perhaps folded code could have a symbol on the left of the lines or something..?
Could be doable, I think

-=-=-
''Load, Next List!''
Thu, 17 Jul 2025, 04:11
realtime
You can add command something like:
Import from "http:/yourcode"

You can then combine it and work as usual
I think this is good when you have reusable code.

I don't mind with everything global.
You can use tag to separate things.

-=-=-
BASIK
Thu, 17 Jul 2025, 04:32
Jayenkai
That's a nice solution, but how do you do that without having to host it yourself?
And what do you host it as?
And how do we secure the javascript so it isn't importing something that can easily hack the user?

-=-=-
''Load, Next List!''
Thu, 17 Jul 2025, 06:19
realtime
It is a jse code. There is no harm with it.
You can parse it and it Will fail if it is not a jse code.
You can do like separate the image, or data.

For hosting, we can upload it here like we upload image as usual.

-=-=-
BASIK
Thu, 17 Jul 2025, 08:13
Jayenkai
I'm still thinking Fold...



And then have a little toggle to hide the fold, but also lets you copy just the contents of the fold, so you can reuse it in a different project.

|edit| -=-=-=- |edit|

But...
What if you want to change .DoSomething, then you'd have to go back and fix it for ALL the projects that use it.

But...
That also wouldn't work if you uploaded your .jse script here to the uploads section, because you can't really update uploads. (I do need to fix that.. It used to work ages ago, but I broke it.)
If you did update the script and used the upload, the filename would be different, so you'd STILL have to go back through past projects to update them, anyway.

-=-=-
''Load, Next List!''
Thu, 17 Jul 2025, 08:21
Jayenkai
But....

What if you had a post like <<^^this post^^>> and you posted some code into it..



And then in JSE you have...



(The ImportFrom would only grab the first code-box, to save things getting confusing)

That way, not only is your code visible and usable elsewhere, but other people can see it, too, and reuse if necessary.

Then we're not dealing with the complicated mess of SoCoder's uploads, but we're also not having "code on another server" issues, either.
The "Download HTML5" function can probably grab that bit of script, too, and inject it directly into the code when it's saving it.

.... Hmmm.
But then we're back to "you'd need to update all your downloaded projects if you need to fix a function in the import" issue again.

-=-=-
''Load, Next List!''