Click or drag to resize

CommandListAppendCaseBranchList(Int32, Int32) Method

Used in a switch-block, specifies a test case and the id of a target list.


Namespace: RAYLASE.SPICE3.ClientLib
Assembly: RAYLASE.SPICE3.ClientLib (in RAYLASE.SPICE3.ClientLib.dll) Version: 3.5.2
Syntax
C#
public void AppendCaseBranchList(
	int listID,
	int value
)

Parameters

listID  Int32
The target list identifier.
value  Int32
The value against which the integer variable will be tested. This case will apply if the comparison is an exact match.
Remarks

Appends a CASE_BRANCH_LIST 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.

Example

Please note that this is a contrived example, illustrating very naive usage of the switch-block.

Switch by Variable Value Example
// Arbitrary values for demo only:
string varname = "var";                                 // the name of an integer-variable (on the card) whose value will be tested.

uint lowSpeedMarkingTestValue = 3;                      // a case-value used to test the variable-value.
uint mediumSpeedMarkingTestValue = 6;                   // another case-value used to test the port-value.

// Arbitrary values for demo only:
int lowSpeedMarkingListID = 333;
int mediumSpeedMarkingListID = 444;
int highSpeedMarkingListID = 555;

CommandList listBranch = new CommandList();
listBranch.AppendJumpAbs( 0, 0 );
listBranch.AppendSwitch( varname );
listBranch.AppendCaseBranchList( lowSpeedMarkingListID, lowSpeedMarkingTestValue );
listBranch.AppendCaseBranchList( mediumSpeedMarkingListID, mediumSpeedMarkingTestValue );
listBranch.AppendDefaultBranchList( highSpeedMarkingListID );

Console.WriteLine( $"ListBranch commands:" );
int count = 0;
foreach ( var cmd in listBranch )
    Console.WriteLine( $" {count++}: {cmd.ToString()}" );

CommandList listCall = new CommandList();
listCall.AppendJumpAbs( 0, 0 );
listCall.AppendSwitch( varname );
listCall.AppendCaseCallList( lowSpeedMarkingListID, lowSpeedMarkingTestValue );
listCall.AppendCaseCallList( mediumSpeedMarkingListID, mediumSpeedMarkingTestValue );
listCall.AppendDefaultCallList( highSpeedMarkingListID );

Console.WriteLine( $"ListCall commands:" );
count = 0;
foreach ( var cmd in listCall )
    Console.WriteLine( $" {count++}: {cmd.ToString()}" );

// output should be:
// ListBranch commands:
//  0: { JA, P2D[ X=0 Y=0 ] }
//  1: { SWIV, I32[ 0 ], U32[ 2317739966 ] }
//  2: { CASBL, I32[ 333 ], I32[ 3 ] }
//  3: { CASBL, I32[ 444 ], I32[ 6 ] }
//  4: { DEFBL, I32[ 555 ] }
// ListCall commands:
//  0: { JA, P2D[ X=0 Y=0 ] }
//  1: { SWIV, I32[ 0 ], U32[ 2317739966 ] }
//  2: { CASCL, I32[ 333 ], I32[ 3 ] }
//  3: { CASCL, I32[ 444 ], I32[ 6 ] }
//  4: { DEFCL, I32[ 555 ] }
See Also