TIB: An 89 routine


[Prev][Next][Index][Thread]

TIB: An 89 routine



I was working on my latest project the other day and came across the need for a function to determine if a variable exists or not. Since there is not a function built in that is solely for this purpose, I came up with this simpe routine that returns a 1 or 0 depending on whether a var exists or not, allowing you to do cool things like
If exists("x")
to execute code if the var x exists. I just thought this might be helpful to you 89 people out there with a similar need (it should work on 92+ as well, but I cannot test this as I do not own a 92+.).
 
:exists(var)
:Func
:Local var
:If expr("getType("&var&")")!="NONE" Then
:Return 1
:Else
:Return 0
:EndIf
:EndFunc
 
I hope this helps you all in your projects. Happy coding!
     --Chris