Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
25th September 2016, 02:40 | #1 | Link |
Registered User
Join Date: Jul 2016
Posts: 5
|
Get the Top Layer script's absolute path
For Example, top.avs imported function.avsi,
in function.avsi, I want to get the top layer script's absolute path: 'e:\scripts\top.avs' I tried to call ScriptFile() in function.avsi when I execute top.avs, but it always returns function.avsi's path. It seems avisynth internel function doesn't have feature to get the Top Layer script's absolute path? |
25th September 2016, 03:33 | #2 | Link |
Retried Guesser
Join Date: Jun 2012
Posts: 1,373
|
You would use a global variable here -
Code:
## top.avs global topscript=ScriptFile Import("function.avsi") Colorbars myfunction return Last Code:
##function.avsi function myfunction(clip C) { return C.Subtitle(topscript) } |
25th September 2016, 10:27 | #3 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Think you actually need ScriptName rather than ScriptFile.
D:\WRK\Top.avs Code:
## D:\WRK\top.avs global topscriptfile=ScriptFile global topscriptname=ScriptName global topscriptdir=ScriptDir Import("DIR2\GetWorkingDir.avsi") Import("DIR1\function.avsi") Colorbars myfunction return Last Code:
## D:\WRK\DIR1\function.avsi function myfunction(clip C) { return C.RT_Subtitle("ScriptFile='%s'\nScriptName='%s'\nScriptDir='%s'\n_GetWorkingDir='%s'", \ topscriptFile,topscriptName,topscriptDir,_GetWorkingDir) } Code:
## D:\WRK\DIR2\GetWorkingDir.avsi # _GetWorkingDir(), Get Current Working Directory as used by Avisynth for easy importing of scripts:- By StainlessS # Unaffected by problems suffered by either 2.6a3 Script??? functions or synthetic versions, eg AVSPMod (null paths) # or smplayer (unix style slash). # Can live anywhere, unaffected by location of the function, can avsi autoload or import. # Any script using "SetWorkingDir()" will of course change the return value, but assuming working dir not changed, # then should return the location of your main AVS script. May have advantage over eg ScriptDir as can deliberately # use SetWorkingDir to something other than the main script directory. Function _GetWorkingDir(){Try{Import("?\")}Catch(_){s=FindStr(_,Chr(34))_=MidStr(_,s+1,FindStr(_,"?")-s-1)}_}
__________________
I sometimes post sober. StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace "Some infinities are bigger than other infinities", but how many of them are infinitely bigger ??? Last edited by StainlessS; 30th November 2018 at 12:00. |
Tags |
avisynth |
Thread Tools | Search this Thread |
Display Modes | |
|
|