Jump to content
Sign in to follow this  
wrybread

check if variable exists?

Recommended Posts

wrybread

I'm wondering if there's a way to check whether a variable exists?

I'm trying to test whether command line argument 2 ($CmdLine[2]) exists. If not, assign it a default value.

I suppose I could use StringLeft to get the string length, but I'm hoping there's a better way.

Share this post


Link to post
Share on other sites
seandisanti

I'm wondering if there's a way to check whether a variable exists?

I'm trying to test whether command line argument 2 ($CmdLine[2]) exists. If not, assign it a default value.

I suppose I could use StringLeft to get the string length, but I'm hoping there's a better way.

<{POST_SNAPBACK}>

$CmdLine[0] contains the number of elements, or the number of passed arguments. $CmdLine[2] can't exist if [0] < 2

Share this post


Link to post
Share on other sites
wrybread

$CmdLine[0] contains the number of elements, or the number of passed arguments.  $CmdLine[2] can't exist if [0] < 2

<{POST_SNAPBACK}>

Thank you, very elegant.

Share this post


Link to post
Share on other sites
seandisanti

Thank you, very elegant.

<{POST_SNAPBACK}>

glad i could help

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.