10-16-2024, 02:57 PM
I've been having so/so results using the IMP logical operator, mostly falling back on all the other operators or Select Case. Recently, because we now have Co-Pilot and Gemini I have revisited my IMP failures. Gemini is now telling me that QB64PE either has a bug or mishandles string values with the IMP logical operator. It starts back with the following simple code:
Gemini feels this code is correct and should generate the correct response however the IDE highlights an error on the ' If C$ = "Pink" IMP "Girl" then' line. The error message reads that I cannot convert a number to a string. It seems the left side of the IMP operator is fine ( ie If C$ = "Pink" but the right side of IMP is looking for a number and does not recognize a string value.
Tried changing the right side to a Boolean comparison ( ie If C$ = "Pink" IMP NOT("Girl" = "") but still can't come up with the correct answer. Trying to get Gemini to keep correcting the code to make IMP work with this set of conditions it became frustrated with me (of course that's how I took it and not real frustration on its part) and gave a very simple Select Case routine to deal with this simple color question.
While Gemini was thinking the above was an issue for IMP dealing with string values it told me QB64PE could have a bug in its application of IMP after the following code using IMP was tested :
The above code was Gemini's answer to a previous attempt on the use of IMP and touts that this code gives the correct answer. Gemini's actual defense of this code reads " The issue was that the isADULT variable was being assigned the result of the comparison age >= 18. This means that isADULT would be True only if the age is greater than or equal to 18. However, the IMP operator was being used incorrectly. The IMP operator should be used to check if the condition "age is greater than or equal to 18 implies adult" is True.
But Gemini's "corrected code" still does NOT give the correct answer.
Moral of the story : To And, Or or XOR is devine to IMP is just gossip.
Code: (Select All)
Input "Which color do you prefer? Pink or Blue: ",C$
If C$ = "Pink" IMP "Girl" then
Print "You're a Girl!"
Elseif C$ = "Blue" IMP "Boy" then
Print "You"re a Boy!"
Else
Print " Invalid color choice"
End If
Gemini feels this code is correct and should generate the correct response however the IDE highlights an error on the ' If C$ = "Pink" IMP "Girl" then' line. The error message reads that I cannot convert a number to a string. It seems the left side of the IMP operator is fine ( ie If C$ = "Pink" but the right side of IMP is looking for a number and does not recognize a string value.
Tried changing the right side to a Boolean comparison ( ie If C$ = "Pink" IMP NOT("Girl" = "") but still can't come up with the correct answer. Trying to get Gemini to keep correcting the code to make IMP work with this set of conditions it became frustrated with me (of course that's how I took it and not real frustration on its part) and gave a very simple Select Case routine to deal with this simple color question.
While Gemini was thinking the above was an issue for IMP dealing with string values it told me QB64PE could have a bug in its application of IMP after the following code using IMP was tested :
Code: (Select All)
Input "Enter your age: ", age
isADULT = age >= 18
If isADULT Imp True Then
Print "You are an Adult"
Else
Print "You are a minor"
End If
The above code was Gemini's answer to a previous attempt on the use of IMP and touts that this code gives the correct answer. Gemini's actual defense of this code reads " The issue was that the isADULT variable was being assigned the result of the comparison age >= 18. This means that isADULT would be True only if the age is greater than or equal to 18. However, the IMP operator was being used incorrectly. The IMP operator should be used to check if the condition "age is greater than or equal to 18 implies adult" is True.
But Gemini's "corrected code" still does NOT give the correct answer.
Moral of the story : To And, Or or XOR is devine to IMP is just gossip.