Hi Stefan.
Firstly, to retrieve the name of the currently selected package, have you considered using the API call? Repository.GetTreeSelectedPackage? This should do the trick.
But if your scenario is such that you have to execute a script for more logic.
The below sniplet should give a rough idea of how it could be achieved.
Dim SC As New ScriptControl
SC.AddObject("Repository", Repository, True) ' Adding Repository Object to be used in the Script
SC.AddCode(SourceScript)
' Script retrieved from Repository.SQLQuery("SELECT * FROM t_script")
result = SC.Run(FuncName)
'FuncName is the method in the script that you would like to call
the corresponding script will be something like
Function FuncName()
' Repository object was set before invoking the script!
' Get the currently selected element in the tree to work on
dim thePackage
set thePackage = Repository.GetTreeSelectedPackage()
if not thePackage is nothing then
FuncName= thePackage.Name;
end if
End Function