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.

 

Go Back   Doom9's Forum > Capturing and Editing Video > Avisynth Development

Reply
 
Thread Tools Search this Thread Display Modes
Old 25th September 2016, 02:40   #1  |  Link
qiangbro
Registered User
 
qiangbro's Avatar
 
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?
qiangbro is offline   Reply With Quote
Old 25th September 2016, 03:33   #2  |  Link
raffriff42
Retried Guesser
 
raffriff42's Avatar
 
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)
}
raffriff42 is offline   Reply With Quote
Old 25th September 2016, 10:27   #3  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
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
D:\WRK\DIR1\function.avsi
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)
}
D:\WRK\DIR2\GetWorkingDir.avsi [EDIT: from here:- http://forum.doom9.org/showthread.ph...02#post1590402 ]
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)}_}
Result
__________________
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.
StainlessS is offline   Reply With Quote
Reply

Tags
avisynth

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 00:33.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.