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

Re: [amibroker] Are all variables Array data types?


  • Date: Mon, 14 Dec 2009 19:33:23 -0500
  • From: Herman <psytek@xxxxxxxx>
  • Subject: Re: [amibroker] Are all variables Array data types?

PureBytes Links

Trading Reference Links

A variable can be a number or an array. It all depends on the first 
assignment. If you assign a number:

VarA = 1;
VarA is a number.

If you assign an array it will be an array:

VarA = Close;

There are more variable types, you can test the type of a variable using 
TypeOf(). See this example from the Readme File:

The typeof operator is used in the following way:
typeof (operand)
The typeof operator returns a string indicating the type of the 
*unevaluated* operand. operand is the string, variable, function 
identifier, or object for which the type is to be returned.
When supplying identifier, it should be provided alone, without 
arithmetic operators, without extra arguments and without braces.
If you want to check the type of value returned by the function, you 
must first assign the return value to a variable and then use
typeof( variable ).
Possible return values are:
" undefined" - identifier is not defined
" number" - operand represents a number (scalar)
" array" - operand represents an array
" string" - operand represents a string
" function" - operand is a built-in function identifier
" user function" - operand is a user-defined function
" object" - operand represents COM object
" member" - operand represents member function or property of COM object
" handle" - operand represents Windows handle
" unknown" - type of operand is unknown (should not happen)typeof 
operator allows among other things to detect undefined variables in the 
following way
if( typeof( somevar ) == "undefined" )
{
/// when somevar is undefined the code here will execute
}
The following sample COMMENTARY code shows the output of
typeof in some common situations
x = MACD();
y = LastValue( x );
function testfun() { return 1; };
printf( typeof( test ) + "\n" ); // the undefined variable
printf( typeof( 1 ) + "\n"); // literal number
printf( typeof( "checking" ) + "\n"); // literal string
printf( typeof( x ) + "\n"); // array variable
printf( typeof( y ) + "\n"); // scalar variable
printf( typeof( MACD ) + "\n"); // function identifier
printf( typeof( testfun ) + "\n" ); // user function identifier


peter843 wrote:
> It seems that all variables are arrays. Is it possible to create variables that are numeric and therefore can be used in the condition of an IF statement?
>
>
>
> ------------------------------------
>
> **** IMPORTANT PLEASE READ ****
> This group is for the discussion between users only.
> This is *NOT* technical support channel.
>
> TO GET TECHNICAL SUPPORT send an e-mail directly to 
> SUPPORT {at} amibroker.com
>
> TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
> http://www.amibroker.com/feedback/
> (submissions sent via other channels won't be considered)
>
> For NEW RELEASE ANNOUNCEMENTS and other news always check DEVLOG:
> http://www.amibroker.com/devlog/
>
> Yahoo! Groups Links
>
>
>
>
>
>   


------------------------------------

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

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

TO SUBMIT SUGGESTIONS please use FEEDBACK CENTER at
http://www.amibroker.com/feedback/
(submissions sent via other channels won't be considered)

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

Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/amibroker/

<*> Your email settings:
    Individual Email | Traditional

<*> To change settings online go to:
    http://groups.yahoo.com/group/amibroker/join
    (Yahoo! ID required)

<*> To change settings via email:
    amibroker-digest@xxxxxxxxxxxxxxx 
    amibroker-fullfeatured@xxxxxxxxxxxxxxx

<*> To unsubscribe from this group, send an email to:
    amibroker-unsubscribe@xxxxxxxxxxxxxxx

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/