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

Re: [amibroker] How to tell if a variable is defined?



PureBytes Links

Trading Reference Links

Excellent Herman!  Thanks for pointing that out.

So that can be a direct replacement for isUnDefined()

if( isNull( VarGet( "myVar1" ))) { myVar1 = defaultValue; }

Or if I want to make it more readable:

procedure VarInit( varName, defaultValue)
{
if( isNull( VarGet( varName ))) { VarSet( varName, defaultValue ); }
}
and the similar VarInitText( varName, defaultText)

I will make good use of these.

Best regards,
Dennis

On Jan 23, 2009, at 6:33 PM, Herman wrote:

You can use varget(), it returns NULL (EMPTY) when not initialized.

//VarSet("Test",999); // uncomment to see NULL disappear.
Title = "Test Value: "+VarGet("Test");

best regards,
herman


Friday, January 23, 2009, 5:53:14 PM, you wrote:

> Hello,

> I am building a program in a modular way with #includes.  I would like
> modules to contain all their needed variables included as default  
> values, but I would like let the values be pre-defined to override the
> defaults.  I know how to do this with static variables since an  
> undefined static variable will return a null or "" depending on the  
> type.  However, I wanted to do this with regular variables and I did  
> not want to define them all ahead of time (like explicitly assigning  
> them null to use the default).  That way I can add functionality to an
> #include file without having to worry about changing all the old  
> programs that use it to add the new variables.

> For instance using a hypothetical isDefined() function:

> myVar1 = myOverrideValue;


> // #include starts here:

> if( not isDefined( myVar1 ) { myVar1 = DefaultValue1; } // this one is
> overridden
> if( not isDefined( myVar2 ) { myVar2 = DefaultValue2; } // this one is
> not

> ... AFL stuff

> // #include ends

> I  would appreciate any ideas.

> Thanks,
> Dennis


> ------------------------------------

> **** IMPORTANT ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.

> *********************
> TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
> SUPPORT {at} amibroker.com
> *********************

> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:

> For other support material please check also:

> *********************************
> Yahoo! Groups Links

> <*> To visit your group on the web, go to:

> <*> Your email settings:
>     Individual Email | Traditional

> <*> To change settings online go to:
>     (Yahoo! ID required)

> <*> To change settings via email:

> <*> To unsubscribe from this group, send an email to:

> <*> Your use of Yahoo! Groups is subject to:



__._,_.___

**** IMPORTANT ****
This group is for the discussion between users only.
This is *NOT* technical support channel.

*********************
TO GET TECHNICAL SUPPORT from AmiBroker please send an e-mail directly to
SUPPORT {at} amibroker.com
*********************

For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
http://www.amibroker.com/devlog/

For other support material please check also:
http://www.amibroker.com/support.html

*********************************




Your email settings: Individual Email|Traditional
Change settings via the Web (Yahoo! ID required)
Change settings via email: Switch delivery to Daily Digest | Switch to Fully Featured
Visit Your Group | Yahoo! Groups Terms of Use | Unsubscribe

__,_._,___