How to Report a Certain Script as an XML?

(Continuation of How to Report a Project as an XML?)
How do I report the XML data of a certain script? I would like it to report it with the <script> tag.

If you want to use it in Snap!, as your use of the word "report" suggests, then you don't want the XML at all. The script itself is first class data.

If you want to use it outside of Snap!, shift-right-click on it and choose "export script."

Is that better?

Huh? I wasn't complaining about your vocabulary; I was just trying to say that if you want to use it inside Snap! there's no need to convert it to anything.

Well i want to make a back-pack-ing system, as an extension of my BETA Testing Collection.

Well, if the backpack is kept by Snap! (for example, as a hidden sprite, which is how I'd do it), then you don't want to think about XML. You want to think about objects the way users think about them, i.e., as scripts, as costumes, as custom blocks, etc. You might need a JS one-liner that does the equivalent of clicking "export" on an object.

Well I want to use the database lib to export it, for now im focusing on scripts instead of sprites, ill get to sprites later.

Here is the link if you want it, i dont think you understand.
The block i want is basically the kind I made in the Sensing catagory. "scripts as XML". I want to be able to report ONE script instead of the whole project.

Isn't that what you were asking for?

No, I want to be able to do this:

(You gotta REALLY zoom in to see it (ctrl(command)+mouse scroll))
except only reporting one script, not the whole entire project.

Did you try "export script"?

But if it's a backpack you want, then you want the things in the backpack to be objects, not unreadable text strings. For example, if you say

you'd like the result to be

not

Right?

I think Joe wants to save the script to local storage (db lib), not a Snap! variable, so that it can be used in different projects and Snap! sessions. There needs to be a way to turn a single script into an XML string so that it can be saved to local storage and a way to parse the XML into a script that somehow can be added (maybe dragged) into the editor.

You can click file > open > browser > script name. But It needs to recognise that its a script only, by detecting the <script></script> tags.

[scratchblocks]
(JavaScript function $$[script]$$ \{ [] \} :: operators)
[/scratchblocks]
EDIT: The code below goes in the JSf reporter body.

const ide = this.parentThatIsA(IDE_Morph);
return script.toXML(ide.serializer);


You would probably say, "Well, you would still need to import the custom blocks." Well, the thing is, once you import them, and save them with the blocks I made, you no longer have to open the script via your file explorer. You can open it just as if you were opening a new project.

not

I know realize it can work without dragging.

I know, but

Im trying to use it like this:

but it wont work.

You declared an anonymous function inside another function, but you didn't run it. I think you should unwrap the inner function. The operator reporter already declares a function.