Line 1: Code will be fully free.
Line 3: This is a non-cycle program.
Line 5: Variable to hold num1 which is not a prime number.
Line 6: Variable to hold num2 which is a prime number.
Line 8: Begin of main procedure.
Line 9: Procedure interface.
Lines 11-18: This select has num1 as operand. So the value of num1 will be checked in every when sentence.
First when is when-is and it will check if the value that returns primeNum function is equal to the value that holds num1.
Second when is when-in and it is used to check if the value that holds num1 is in the list of %list built-in function.
Third when is when-in and it is used to check if the value that holds num1 is in the range of %range built-in function.
Lines 20-24: As the first select will execute the second when, this if is here to demonstrate the use of %range when the number is in the range specified.
Lines 26-33:
This select has num2 as operand. So the value of num2 will be checked in every when sentence.
First when is when-is and it will check if the value that returns primeNum function is equal to the value that holds num2.
Second when is when-in and it is used to check if the value that holds num2 is in the list of %list built-in function.
Third when is when-in and it is used to check if the value that holds num2 is in the range of %range built-in function.
Lines 35-39: As this second select will execute the first when, this if is here to demonstrate the use of %range when the number is NOT in the range specified.
Line 41: A message is sent to the message line of the screen so the user can see where to look for the messages.
Lines 46-59: A procedure that returns whether a number is a prime number. It simply calculates the remainder by dividing all numbers less than num until the result is 0 (zero), so it is not a prime number, or 1, so it is a prime number.
Lines 64-75: Since when-is checks whether the value of the select statement’s operand is equal to a value and the types must match, it is required to compare it with a value of the same type, but the isPrimeNum procedure returns an indicator, not a number, so they cannot be compared. This procedure returns the value of num if the number is prime or a different value, num+1, for example, otherwise and in this way the comparison can be made.