Feature - Implemented ASH Function to Check Name of Script

bumcheekcity

Active member
Would be be possible to have an ASH function to check the name of the script as per the users computer? So that if they rename it we can still make aliases referring to the script? I appreciate this is going to be very low priority what with all the January stuff happening.
 
You can already access the script name as far as I know with __FILE__

print(__FILE__);

print(__FILE__ == "MyScriptName.ash");

SO, you can do the following:

cli_execute("alias newAlias => " + __FILE__);
cli_execute("alias newAlias => ashq import<" + __FILE__ + "> file_function()");
 
Last edited:

StDoodle

Minion
Ooh, I'd been wondering how this worked with imports for a while, so I tested with two scripts; one script returned the string of __FILE__ in a funciton, and was imported into the other, and both reported their own script's name. Awesome!

I could swear there was another hidden variable that was named similarly; anyone remember what it is?
 

bumcheekcity

Active member
You can already access the script name as far as I know with __FILE__

print(__FILE__);

print(__FILE__ == "MyScriptName.ash");

SO, you can do the following:

cli_execute("alias newAlias => " + __FILE__);
cli_execute("alias newAlias => ashq import<" + __FILE__ + "> file_function()");

Fantastic, this sounds like exactly what I wanted - thanks for letting me know, it sounds like this can be closed without any action :D
 

matt.chugg

Moderator
I could swear there was another hidden variable that was named similarly; anyone remember what it is?

This actually intruiged me enough to go look in the code, but I can't find anything else in the parser!

Code:
// Parse constant values
		// true and false are reserved words

		else if ( this.currentToken().equalsIgnoreCase( "true" ) )
		{
			this.readToken();
			result = DataTypes.TRUE_VALUE;
		}

		else if ( this.currentToken().equalsIgnoreCase( "false" ) )
		{
			this.readToken();
			result = DataTypes.FALSE_VALUE;
		}

		else if ( this.currentToken().equals( "__FILE__" ) )
		{
			this.readToken();
			result = new Value( String.valueOf( this.shortFileName ) );
		}
 
Top