Script Debugger to save files with slash in file name

I feel like the answer is just within reach, but my poor brain can’t figure out the POSIX path vs. alias vs. POSIX file, etc.

I want to use AppleScript to tell Script Debugger to save a file that contains a slash in the file name.

Here is my code

tell application "Script Debugger"
	make new document with properties ¬
		{source text:script_command}
	compile document 1
	save document 1 as text script in script_path
	close document 1 ¬
		saving no
end tell

here, script_path might be something like Users:user1:Documents:bookmarks:filename_with_/_a_slash.applescript.

Note, this works if filename_with_/_a_slash.applescript does not have a slash, for example filename_without_a_slash.applescript.

Can someone help me puzzle this out?

The / character is used to separate parts of a path and thus cannot be used within a file name. Your only option is not have a slash within a file name.

You are permitted to use the / in a file name when saving interactively because it is translated to another character by macOS.

in addition to what @alldritt said:

what user sees as file-name-/-with-slash.ext

is actually file-name-:-with-slash.ext in the system.

in InDesign, you can do this:

tell application "Adobe InDesign 2023" to save document 1 to "/Users/username/Documents/file-:-with-slash.indd"

which will create document with display name file-/-with-slash.indd

it looks like SD won’t allow to do this (will show an error) and justly so: file names should not include forward slashes as they only cause suffering and grief to innocent developers.

Slashes are odd.
Open a document in, click in the file name at the top of the window to open the little dialog and add a slash to its name. Works without hitch. At first, I thought that a similar UNICODE glyph is used, but no, its the standard slash. Now try a colon ( : ) - it even gets replaced by a slash. Try to do this in the Finder and it will act up on you. (Just realized that the Finder indeed accepts slashes, too. Never even dared to use one.)
Now drag the little icon besides the new name at the window’s top to an open terminal window and see how the slash gets converted to a backslash-escaped colon - somehow similar to the InDesign example.
And now type open + a space-character into a terminal window, drag again and hit return: “The file with the slashcolonthing does not exist”. Now double click the file’s icon in the Finder and hooray, it does exist.
Not that this helps. But go figure.