"out" Issue with Several Methods Linked Together

Questions about MultiCharts .NET and user contributed studies.
Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

"out" Issue with Several Methods Linked Together

Postby Jobauma » 27 Nov 2018

Hi.

I'm working with a code, but having some problems. "out" for "Tension" works fine, and is in the 1st method ("void"), but "Pivot" is passed on from the 1st method to the 3rd. The 2nd, 3rd and 4th methods are "double" ( and has to be for "Tension" to assign it's calculation in the 1st method ("void") ). I've tried to add "out" to "Pivot" to the 1st method, and pass it on to the other "double" methods.

The use of "out" for "Pivot" on the 1st method only reports this error: " Use of unassigned out parameter 'Pivot'' ". This is when I use " public void CreateTension( out double Tension, double Span_A, double Span_B, out int Pivot ) ", and leaves " Tension = CreateGannSplitUp( Ratio, Pivot ); " without " out Pivot " in the 1st method. If I pass "out" from the 1st to the 3rd method ( which is shown in the code below ), I get this error: " The out parameter 'Pivot' must be assigned to before control leaves the current method ".

Note: I use "out" for "Pivot" to get the value out of the 1st method ( but the whole issue is that "Pivot" is assigned to in the 3rd method ). The 1st method is the one I use to trigger the code ( the rest is triggered from the 1st method automatically ). This is how the code has to be.

The code triggers the 1st method first below, and triggers one by one upwards. :)

Code: Select all

// 4th Method

public static double CreateGannPercent( double Ratio, double L0, double L1 )
{
double Percent = ( Ratio - L0 ) / ( L1 - L0 );

return Percent;
}

// 3rd Method:

// Here PIVOT is supposed to be assigned!
// Pivot is not passed on with "out" to the next method, which is the last one, at " Tension = CreateGannPercent( Ratio, L1 + Counter, L1 + L2 + Counter ); ".

public double CreateGannRatio( double Ratio, double L1, out int Pivot )
{
// Code for ratio and PIVOT ( and L1 )!

Tension = CreateGannPercent( Ratio, L1 + Counter, L1 + L2 + Counter );

Pivot = Pivot_Number;

return Tension;
}

// 2nd Method:

public double CreateGannSplitUp( double Ratio, out int Pivot )
{
// Code for ratio ( and Increment "I" ).

Tension = CreateGannRatio( Ratio, I, out Pivot );

return Tension;
}

// 1st Method:

// Use of "out" here should be fine. Use of "out" at " Tension = CreateGannSplitUp( Ratio, Pivot ); " for passing it on to other methods is another question.

public void CreateTension( out double Tension, double Span_A, double Span_B, out int Pivot )
{
// Code for ratio.

Tension = CreateGannSplitUp( Ratio, out Pivot );
}


Best regards,
Johannes Hillestad Baumann

Jobauma
Posts: 113
Joined: 16 Apr 2013
Has thanked: 25 times
Been thanked: 6 times

[SOLVED]

Postby Jobauma » 28 Nov 2018

I solved the problem. I just doubled up the "double" methods, executed from the first method "void": I use "out" on "Tension" and "ColorPivot".

Code:

Code: Select all

// 4 Create Gann Percent (Tension)

public static double CreateGannPercent( double Ratio, double L0, double L1 )
{
double Percent = ( Ratio - L0 ) / ( L1 - L0 );

return Percent;
}
#endregion



// 3B Create Gann Ratio ( Color Pivot )

public int CreateGannRatio_ColorPivot( double Ratio, double L1 )
{
int ColorPivot = 0;

return ColorPivot;
}



// 3A Create Gann Ratio (Tension)

public double CreateGannRatio_Tension( double Ratio, double L1 )
{
double Tension = 0;

return Tension;
}



// 2B Create Gann SplitUp ( Color Pivot )

public int CreateGannSplitUp_ColorPivot( double Ratio )
{
int ColorPivot = 0;

return ColorPivot;
}



// 2A Create Gann SplitUp (Tension)

public double CreateGannSplitUp_Tension( double Ratio )
{
double Tension = 0;

return Tension;
}



// 1 Create Tension and Color Pivot

public void CreateTensionColorPivot( out double Tension, out int ColorPivot, double Span_A, double Span_B )
{
if ( Span_A != 0 && Span_B != 0 )
{
double Ratio = 0;

if ( Span_A <= Span_B ) Ratio = Span_B / Span_A;
else Ratio = Span_A / Span_B;

Tension = CreateGannSplitUp_Tension(Ratio);
ColorPivot = CreateGannSplitUp_ColorPivot(Ratio);
}
else
{
Tension = 0;
ColorPivot = 0;
}
}


Best regards,
Johannes Hillestad Baumann


Return to “MultiCharts .NET”