ChatGPT for LiveCode Script

I asked ChatGPT:
Write LiveCode script named “Find Prime” to find prime numbers up to the number to be specified.

command FindPrime
put field “Input” into tMax
put “” into field “Output”

if not isNumber(tMax) or tMax < 2 then
answer “Please enter a whole number greater than or equal to 2.”
exit FindPrime
end if

repeat with n = 2 to tMax
if isPrime(n) then
put n & return after field “Output”
end if
end repeat
end FindPrime

function isPrime p
if p = 2 then return true
if p mod 2 = 0 then return false
repeat with i = 3 to sqrt(p) step 2
if p mod i = 0 then return false
end repeat
return true
end isPrime

Somehow, the script misses “3” as a prime number.

Hi @GS.Sunatori Thank you for the feedback! Is this using the built in AI Assistant in Create or directly through Chat GPT?

I used directly through Chat GPT on Safari.app browser, outside of LiveCode.app (macOS).

At this point, I am using only LiveCode Classic Mode for my critical stacks. When LiveCode Create Native becomes rock solid, then I intend to migrate, of course.

1 Like