EteRNAScript outln acting oddly with a javascript output

So, I’m attempting to create a script where a text file of data is downloaded upon the user clicking a link, and I’m using FileSaver.js to do it. I take the code from here and put it in an outline command as so:


Oddly enough, the script fails with: “Return : missing ) after argument list” and acts the exact same way if I remove the script tags (where it should just output the text, not rendering it as javascript). The javascript runs fine if I’m just using it in my code without putting it in an outline, it runs fine in a separate HTML webpage, and the script doesn’t crash if I just assign it to a variable without using outln.

Any help?

1 Like

And for a little more information:

When deleting the marked paren, the script fails with “Return : Unexpected token {”. When I delete everything after and including the marked curly brace, the script runs fine.

I’m quite perplexed with what you’re trying to do here… outln() is just not meant for this “job”, and unless I’m missing something, this is completely superfluous here. Why not just paste these 2 lines of javascript at the top of your own script? Then just use the saveAs() function later when you need it.

What I’m attempting to do is create a link in the output box that says “Click here to download data”, and upon clicking it, will run the saveAs command with the data generated from the script. It appears to me, however, the only way I can do that is to include the script in the HTML of the output box, as I can’t call something in my script, which has already ran, with HTML code in the output box.

Is there anything else that your script is supposed to do when it’s done running? If not, you could simply prompt() the users for their choice.

1 Like

Nope, that would do it. However, I have been rather curious about creating interactive interfaces using HTML in the output box. I haven’t had any issues with any other script, so I may just be out of luck in file downloads for this… It would be nice to be able to have something that could work though. I would not be opposed to a way to change the scripting interface so that either it’s GUI based (where you can put HTML in the GUI components), or if it’s possible to make the script run continuously, not freezing the browser page.

I’m still confused about why there’s an issue though? outln() should still be treating what’s inside it as literal text, especially if there are no HTML tags in it.

outln() works basically by updating an element, a div if my memory serves me well. It does this:

  • locate the ‘result’ element
  • get its innerHTML content
  • concatenate the passed value (a string)
  • update the element

As you can see, there may be a few problems with that. It is not only assumed that the passed data is valid HTML (do you think there are no ’

No angle braces are in that script. Neither was I trying to split an element into multiple calls.

I see many ‘&’ that weren’t converted to ‘&’ …

Anyway, the point stays the same, outln() is just not meant for such a job as you were envisioning. More generally, the current output box is fairly limited, but you have javascript, so nothing stops you from creating a new window and from injecting any HTML and scripts you want in it.

As soon as you’re trying for a more ambitious application, you should just drop the pervasives like clear() and outln(). These were very minimalistic output functions that the original EternaScript coders had to have in the library, nothing more.

Understood, thank you!