Is it possible to repeat a function/code after every line?

Say I’m running a function like this:

function FirstFloor (Map) {
 
Map = DP.Initialize (60, 60, '▒');
Map = DP.Spawn1x1Element (mapTester, 12, 8, 'X'); //Exit.
Map = DP.SpawnEdgeWalls (mapTester, 1, 4, '█');
Map = DP.SpawnEdgeElement (mapTester, 'bottom', 10, '☺'); //Entrance.
//mapTester = designerTestInst.Floor1MainPath (mapTester, 10, 60); //Refine to gauge entrance loc later.
return Map;

}

And I need to do something, say Debug.Log(some string); after every line to profile and/or make sure everything’s working right.

Is there a way to put the Debug.Log code in only once but have FirstFloor repeat it after every individual DP function?

var check : int = 0;

function FirstFloor (Map) {

if (check == 0){
Debug.Log("Your stuff");
check = 1;
}
 
Map = DP.Initialize (60, 60, '▒');
Map = DP.Spawn1x1Element (mapTester, 12, 8, 'X'); //Exit.
Map = DP.SpawnEdgeWalls (mapTester, 1, 4, '█');
Map = DP.SpawnEdgeElement (mapTester, 'bottom', 10, '☺'); //Entrance.
//mapTester = designerTestInst.Floor1MainPath (mapTester, 10, 60); //Refine to gauge entrance loc later.
return Map;
 
}

Maybe recursion is your answer. Here’s a quick tutorial:

http://thenewboston.org/watch.php?cat=16&number=31

I think you could achieve what you want by using a property.

You’d need something like

	public Map MapProperty{
		get{ return mapInstance; }
		set{ 
			mapInstance = value;
			Debug.Log(somestring);
		}
	}

Notice I use Map as the Type, not the variable name. The variable is mapInstance. You also don’t need to have a getter, if you only use it for the debugging as you said. If can also be private if you deem it necessary.

You’d use it by

MapProperty = DP.Function();

EDIT: In UnityScript, you could create a wrapper function.

function Start(){
	Extended(DPFunction,3);
	Extended(DPFunction,5);
}

function DPFunction(i : int){
	Debug.Log("Inside stuff "+i.ToString());
}

function Extended(originalFunction : function(int), parameter1 : int){
	originalFunction(parameter1);
	Debug.Log("Now other stuff...");
}