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. |
18th April 2019, 17:42 | #1 | Link |
Registered User
Join Date: Dec 2018
Posts: 140
|
How to make check is variable defined?
I wanna import some core file, but I want to made core file selfish.
Like if I import core file, coremode=0 if I load core file, coremode=1, so use variable in corefile. How can I make this? |
18th April 2019, 18:53 | #5 | Link | |||
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Same link as Wilbert posted.
Quote:
Quote:
Code:
blankClip zet=9 # try Comment me out what=VarExist("zet") Subtitle(String(what)) Quote:
__________________
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; 18th April 2019 at 18:56. |
|||
18th April 2019, 19:35 | #7 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
I forgot to use Double quotes too when first testing that bit of script, it often happens to me so dont kick yourself too hard.
The Wiki dont define what it means by "var" or "name", perhaps it should.
__________________
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 ??? |
18th April 2019, 20:25 | #8 | Link |
Registered User
Join Date: Mar 2011
Posts: 4,823
|
You can do something like this for backwards compatibility, as only Avisynth+ has VarExist().
Try{ IsZet = defined(Zet) } catch(err_msg){ IsZet = false } or some other variation Try{ Zet = Zet } catch(err_msg){ Zet = undefined() } |
18th April 2019, 20:38 | #9 | Link | |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Also, just to be a bit pedantic,
Code:
catch(err_msg){ Zet = undefined() } RT_Stats(), nearly any version. Quote:
__________________
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 ??? |
|
18th April 2019, 21:15 | #10 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Code:
Function MyGlobaVarExist(String Name) { try { Eval(name) ex=true} catch(err) { ex=false } return ex } blankclip Fred = "blurt" #Global Fred = "fart" name="Fred" try { Eval(name) existFred=true} catch(err) { existFred=false } GlbExistFred=MyGlobaVarExist(name) S1="Local(inline) Fred =" + String(existFred) S2="Global Fred =" + String(GlbExistFred) S=S1+"\n"+S2 subtitle(s,lsp=0) EDIT: Variation (same result as above) Code:
Function MyGlobaVarExist(String Name) { try { Eval(name) ex=true} catch(err) { ex=false } return ex } blankclip(width=196,height=64) Fred = undefined # exists but Undefined (Comment out both assignments for non exist) #Global Fred = undefined name="Fred" try { Eval(name) existFred=true} catch(err) { existFred=false } GlbExistFred=MyGlobaVarExist(name) S1="Local(inline) Fred =" + String(existFred) S2="Global Fred =" + String(GlbExistFred) S=S1+"\n"+S2 subtitle(s,lsp=0)
__________________
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; 18th April 2019 at 21:34. |
20th April 2019, 03:53 | #12 | Link | |
Registered User
Join Date: Mar 2011
Posts: 4,823
|
Quote:
function VeryUndefined(){} try{ Fred=Fred }catch(err){ Fred=VeryUndefined() } Name=Fred What=Defined(Fred) Last edited by hello_hello; 20th April 2019 at 03:55. |
|
20th April 2019, 09:10 | #13 | Link |
HeartlessS Usurer
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
|
Code:
Function SyntheticUndefined(var "DontSupllyAnyValueAtAllToThisOptionalVariableWithAVeryLongName") { return DontSupllyAnyValueAtAllToThisOptionalVariablewithAVeryLongName } EDIT: Yes, good one HH, just realized what your function does, and does it better than above rubbish [probably].
__________________
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; 20th April 2019 at 09:14. |
20th April 2019, 11:58 | #14 | Link | ||
Avisynth language lover
Join Date: Dec 2007
Location: Spain
Posts: 3,431
|
Quote:
Quote:
(You will see there that stickboy had already written a function Undefined() way back then ) |
||
Thread Tools | Search this Thread |
Display Modes | |
|
|