Click or drag to resize

CommandListAppendBranchList(Int32, String, Boolean) Method

Conditionally branches to the specified list.


Namespace: RAYLASE.SPICE3.ClientLib
Assembly: RAYLASE.SPICE3.ClientLib (in RAYLASE.SPICE3.ClientLib.dll) Version: 3.6.0
Syntax
C#
public void AppendBranchList(
	int listID,
	string booleanVariableName,
	bool ifNotTrue = false
)

Parameters

listID  Int32
The target list identifier.
booleanVariableName  String
The name of the boolean variable.
ifNotTrue  Boolean  (Optional)
false (default)
The branch is taken if the condition is true.
true
The branch is taken if the condition is false.
Remarks

Appends a BRANCH_LIST_COND_FLAG command to the list.

The calling list becomes idle and as a result triggers a ListIdle event. Furthermore, as execution control is surrendered by the calling list, it is no longer busy, but instead the target list becomes busy.

For every Execute(Int32) only one ListDone event will be sent along with the list ID of the final list that was executing.

Caution note  Caution

Conditional BRANCH commands do NOT automatically de-activate the laser.

See also: 12.9 Notes on Flow-Control Commands.

Example
Common CallList and BranchList Command Examples
int sublistID = 333;

uint bitmask = 0x5AA5;

string varname = "var";

CommandList list = new CommandList();
list.AppendJumpAbs( 0, 0 );
list.AppendMarkAbs( 500, 500 );
list.AppendJumpAbs( 100, 200 );

// Append a CallList or BranchList command at the end of the main list:
for ( int i = 0; i < 6; i++ )
{
    switch ( i )
    {
        case 0:
            list.AppendCallList( sublistID ); // Unconditional
            break;

        case 1:
            list.AppendCallList( sublistID, bitmask, IOPort.PortB, true ); // Conditional on value read from port.
            break;

        case 2:
            list.AppendCallList( sublistID, varname ); // Conditional on value of the boolean variable on the card.
            break;

        case 3:
            list.AppendBranchList( sublistID ); // Unconditional
            break;

        case 4:
            list.AppendBranchList( sublistID, bitmask, IOPort.PortB, true ); // Conditional on value read from port.
            break;

        case 5:
            list.AppendBranchList( sublistID, varname ); // Conditional on value of the boolean variable on the card.
            break;

        default:
            break;
    };

    Console.WriteLine( $"{i + 1}: list commands:" );
    int count = 0;
    foreach ( var cmd in list )
        if ( count < ( list.Count - 2 ) )
            Console.Write( $" {count++}: {cmd.ToString()} " );
        else
            Console.WriteLine( $" {count++}: {cmd.ToString()}" );

    list.RemoveAt( list.Count - 1 ); // we're going to replace the call or branch command, but re-use the rest of the list
};

// output should be:
// 1: list commands:
//  0: { JA, P2D[ X=0 Y=0 ] }  1: { MA, P2D[ X=500 Y=500 ] }  2: { JA, P2D[ X=100 Y=200 ] }
//  3: { CL, I32[ 333 ] }
// 2: list commands:
//  0: { JA, P2D[ X=0 Y=0 ] }  1: { MA, P2D[ X=500 Y=500 ] }  2: { JA, P2D[ X=100 Y=200 ] }
//  3: { CLC, I32[ 333 ], U32[ 23205 ], I32[ 1 ], Bool[ False ], Bool[ True ], U32[ 4294967295 ] }
// 3: list commands:
//  0: { JA, P2D[ X=0 Y=0 ] }  1: { MA, P2D[ X=500 Y=500 ] }  2: { JA, P2D[ X=100 Y=200 ] }
//  3: { CLCF, I32[ 333 ], U32[ 2317739966 ], Bool[ False ] }
// 4: list commands:
//  0: { JA, P2D[ X=0 Y=0 ] }  1: { MA, P2D[ X=500 Y=500 ] }  2: { JA, P2D[ X=100 Y=200 ] }
//  3: { BRL, I32[ 333 ] }
// 5: list commands:
//  0: { JA, P2D[ X=0 Y=0 ] }  1: { MA, P2D[ X=500 Y=500 ] }  2: { JA, P2D[ X=100 Y=200 ] }
//  3: { BRLC, I32[ 333 ], U32[ 23205 ], I32[ 1 ], Bool[ False ], Bool[ True ], U32[ 4294967295 ] }
// 6: list commands:
//  0: { JA, P2D[ X=0 Y=0 ] }  1: { MA, P2D[ X=500 Y=500 ] }  2: { JA, P2D[ X=100 Y=200 ] }
//  3: { BRLCF, I32[ 333 ], U32[ 2317739966 ], Bool[ False ] }
See Also