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. |
![]() |
#1 | Link |
Matroska Dev
Join Date: Sep 2002
Location: Texas, USA
Posts: 230
|
Get the current script filename
Is it possible to get the filename of the current AVS script file inside a filter?
I want to make a Audio Normalizing filter that caches the the peak levels to an external file so that it only has to scan it once. ![]()
__________________
The Matroska Effect |
![]() |
![]() |
#5 | Link |
Matroska Dev
Join Date: Sep 2002
Location: Texas, USA
Posts: 230
|
![]() I went ahead and made the filter but it takes the peak value file as an argument. Normalize2 Now with mf's function I can get similar results to what I wanted. Code:
function GetScriptName() { Try { NonExistantfiltername() } Catch(err_msg) { err_msg2 = MidStr(err_msg, 67) filename = LeftStr(err_msg2, (FindStr(err_msg2, ", line")-1)) return filename } } ... Normalize2(GetScriptName()+".norm") ![]()
__________________
The Matroska Effect |
![]() |
![]() |
#7 | Link | |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Quote:
![]() But it won't work for the contrived case where the filename has ", line" in it. Here's a modified version (and that also isn't dependent on NonExistentFilterName): Code:
function GetScriptName() { Try { assert(false) } Catch(err_msg) { err_msg = MidStr(err_msg, FindStr(err_msg, "(") + 1) filename = LeftStr(err_msg, StrLen(err_msg) - FindStr(RevStr(err_msg), ",")) return filename } } Last edited by stickboy; 15th December 2003 at 21:40. |
|
![]() |
![]() |
#14 | Link |
Simply me
Join Date: Aug 2002
Location: Lancashire, England
Posts: 610
|
I'm a bit confused as usual
![]() I understand the GetScriptName function (hats off to mf) but I don't understand what Normalise2 is doing with it and what is meant by caching so it only has to scan the file once ![]() I'm sure its simple but the usage has got me stumped ![]() regards Simon
__________________
http://www.geocities.com/siwalters_uk/fnews.html |
![]() |
![]() |
#16 | Link |
Registered User
Join Date: Nov 2008
Posts: 67
|
Here's my slighlty more efficient version, only one string, and safer as script name must not contain ", line " instead of ", line" (extra char), and it doesn't depend on a fixed length of error code.
Code:
function GetScriptName() { try { willGiveNonExistantError() } catch(err_msg) { pos1= findStr(err_msg, "(") } return midStr( err_msg, pos1+1, findStr(err_msg, ", line ")-pos1-1 ) } |
![]() |
![]() |
#17 | Link |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,257
|
@isidroco, that function maybe was useful in 2003 but after AviSynth 2.6 (2015) there are already a internal function ScriptName()
http://avisynth.nl/index.php/Interna...ons#ScriptName I close this old thread to avoid new post. Last edited by tebasuna51; 11th August 2024 at 11:09. |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|