PureBytes Links
Trading Reference Links
|
-----Message d'origine-----
De : Larry McBride <lcmcb@xxxxxxxxxxx>
À : Omega List Note <omega-list@xxxxxxxxxx>
Date : lundi 29 mars 1999 20:32
Objet : Global variables
>In answer to my inquiry to Omega about global variables in TS2000i, here is
>their answer. I'll have to play with this a bit, but it looks like it can
>save some dll work. I wonder how many other hidden goodies there are?
>
This new functions do not solve the global variable problem ( variable that
are shared between windows).
To the best of my knowledge, Xref function allow to pass and retrieve values
to and from functions.
Means that the modification made inside the called function are avialable
from the calling indicator,or if you want, that a function can by this mean
return several values, althought the classic returned value is not different
from what was available in TS4.
The new thing is that inputs to the functions (means passed as arguments)
can also be treated as if they were output(s) of the considered calling
function.
This will save some DLL coding because this was only available through a DLL
called in EL ( argument passed to a DLL function could be inputs and /or
outputs).
This will bring more flexibility to design complex user function, but you
may recall that these variables are not global, that is to say that they
still belong to the chart wher the calling indicator or system is applied.
If you want share values between different windows or workspace, please see
Doug Deming's products Glovar or Kim Horn's Hashnum DLL ( I supose that they
will recompile them to 32 bits, if not yet done).
They are inexpensive and are proven useful.
For your information, this improvement was one that I had heavily claimed
when travelling to Miami in 1997.
(I was not alone to claim for this).
There are others, but wait...
Sincerely,
Pierre Orphelin
http://www.sirtrade.com
=============================
>>>>>>>>
>
>2) In version four the answer is you would have to purchase or build a
>library file to use global variables. In version 2000i you can now pass
>variables and arrays by reference. For example:
>
>Passing Variables by reference:
>The most common example used in any programming textbook is the swap()
>function. What this function does is it receives two variables and swaps
>their value. The function itself returns a zero (0).
>
>We added new keywords to the language that will allow functions to receive
>variables by reference, these names are
> NumericRef
> TrueFalseRef
> StringRef
>
>So when writing functions, we will be able to specify that a certain
>parameter will be a variable that we will use by reference. Here would
be
>the syntax for the swap function:
>
>{ Swap Function }
>Inputs: varA(NumericRef), varB(NumericRef);
>Variable: temp(0);
>
>Temp = varA;
>VarA = varB;
>VarB = temp;
>
>Swap = 0;
>
>Then this function can be used by an indicator the following way:
>{ Indicator Test }
>Variable; x(0);
>
>If BarNumber = 1 then begin
> Value1 = 1;
> Value2 = -1;
>End;
>
>X = Swap(value1, value2);
>Plot1(value1);
>Plot2(value2);
>
>When you plot this indicator, you will see that value1 and value2 swap
>values on every bar. Note that the function Swap is effectively
returning
>three values: it returns a result like any other function which in this
>example is stored in the variable x¸ and by modifying the values of the
>variables value1 and value2 it is returning two additional values.
>
>
|