Script name constant or function ?

Is there a variable, constant or function that can return the current running script name (i.e. example.script)? Not the handler of the script that’s running but just the initial script that got invoked (with the run button).

Thanks.

Yes, the CallStack function will give you what you want (and a whole lot more!). Specifically, to get just the information you asked for, try one of the following:

 put the scriptObjectID of item 1 of the callStack

or

 put the handler of item 1 of the callStack

Thanks for trying to help me. I tried both and I get this error:

Unable to access global property or function ‘CALLSTACK’

Any other ideas?

Where is this callstack stuff documented?

The CallStack() function is a fairly recent addition. It was introduced in Eggplant 2.2, so if you’re running an older version you’ll need to upgrade in order to use it.

It’s documented (minimally) in the chapter on Other Commands and Functions in the SenseTalk Reference manual.

Oh, that explains it. We’re on v 2.21.

I’ll check with our tech support group about installing 2.22.

Thanks for all the info./help.

:slight_smile:

We upgraded to v 2.22 and I tried your examples. They both work, but each produces different results.

The first example of yours returns the full path with script name exactly as how it’s saved (including the .script) at the end. Example:
/users/Documents/Suite_Name/Scripts/ScriptName.script

How can I extract just “ScriptName” from the above example?

The second code example of yours returns just the script name all in lowercase (excluding the .script too). Example:
scriptname

I don’t want to use this one because it doesn’t return the filename as it truly is in upper and lowercase.

A different question:

I saw somewhere in this forum an example of how to call another script, but in this case it was specifying the “start using” command. Can this work for images too? Like can you perhaps specify the whole suite name in the “start using” command of where the images are contained so the remainder of the script can find images there. This is so I don’t have to manually specify the suite images in the helper tab.

[quote=“toplay”]The first example of yours returns the full path with script name exactly as how it’s saved (including the .script) at the end. Example:
/users/Documents/Suite_Name/Scripts/ScriptName.script

How can I extract just “ScriptName” from the above example?
[/quote]
Try this:

put the scriptObjectID of item 1 of the callStack into fullPath
put item 1 delimited by "." of the last item delimited by "/" of fullPath into scriptName

[quote=“toplay”]A different question:

I saw somewhere in this forum an example of how to call another script, but in this case it was specifying the “start using” command. Can this work for images too? Like can you perhaps specify the whole suite name in the “start using” command of where the images are contained so the remainder of the script can find images there. This is so I don’t have to manually specify the suite images in the helper tab.[/quote]
The “start using” command is only for scripts. To begin using a suite, use the openSuite command, which makes an entire suite accessible to another, including its scripts and images, just like suites specified on the Helpers tab, but controlled dynamically from your script.

Your code worked like a charm. Thank you.

Thanks for the open suite tip too.

:slight_smile: