Hi @Kitt,
To achieve your goal without increasing the size of your code significantly, you can utilize function calls or a structured approach that avoids duplication while maintaining clarity. Below is a sample implementation in pseudocode that demonstrates how to encapsulate the logic for outputs 1 and 2 in functions:
//pseudo code
function processOutput1() // Steps for output 1 abc end function
function processOutput2() // Steps for output 2 xyz end function
if opt == 1 then processOutput1() elseif opt == 2 then processOutput2() else if rand() < 0.5 then processOutput1() // Calls the function for output 1 else processOutput2() // Calls the function for output 2 end if end if
By defining processOutput1 and processOutput2, you encapsulate the steps associated with each output. This avoids repetition in your main logic.The initial conditional checks (if opt == 1, elseif opt == 2) remain clear and straightforward, directing the flow appropriately based on the value of opt. So, in the case where opt is equal to 3, you simply call one of the two functions based on a random choice, maintaining clarity and preventing redundancy.
Hope this helps.