Re: Training the AI to write better LiveCode

2023-01-14 Thread Kaveh via use-livecode
Quite incredible!

It might be that LiveCode's simple syntax is best suited to ChatGPT.

On Sat, 14 Jan 2023 at 03:24, Geoff Canyon via use-livecode <
use-livecode@lists.runrev.com> wrote:

> So just now I put this in to chatgpt:
>
> "fizz bin" is a program that counts from 1 to 100, replacing every number
> divisible by 5 with "fizz" and every number divisible by 7 with "bin"; and
> numbers divisible by both 5 and 7 with "fizz bin". Write code in the
> programming language livecode to execute "fizz bin"
>
> This is what ChatGPT responded with:
>
> repeat with x = 1 to 100
> if x mod 5 = 0 and x mod 7 = 0 then
> put "fizz bin"
> else if x mod 5 = 0 then
> put "fizz"
> else if x mod 7 = 0 then
> put "bin"
> else
> put x
> end if
> end repeat
>
> That works as-is, but obviously the results fly by in the message box. So I
> put a field and a button on a card, and edited to this, and it works
> perfectly:
>
> on mouseUp
>repeat with x = 1 to 100
>   if x mod 5 = 0 and x mod 7 = 0 then
>  put "fizz bin" & cr after fld 1
>   else if x mod 5 = 0 then
>  put "fizz" & cr after fld 1
>   else if x mod 7 = 0 then
>  put "bin" & cr after fld 1
>   else
>  put x & cr after fld 1
>   end if
>end repeat
> end mouseUp
>
> Then as I was typing this email I realized I was potentially selling
> chatgpt short, so I put this in:
>
> Modify that code so it works as an "on mouseUp" handler in a button, and
> concatenates the results on individual lines, and puts the final result
> into the field "display"
>
> And it output this:
>
>
> on mouseUp
>put "" into fizzbin
>repeat with x = 1 to 100
>   if x mod 5 = 0 and x mod 7 = 0 then
>   put "fizz bin" & return after fizzbin
>   else if x mod 5 = 0 then
>   put "fizz" & return after fizzbin
>   else if x mod 7 = 0 then
>   put "bin" & return after fizzbin
>   else
>   put x & return after fizzbin
>   end if
>end repeat
>put fizzbin into field "display"
> end mouseUp
>
> And it followed that with instructions:
>
> This code uses the "on mouseUp" handler to execute the script when the
> button is clicked. The results are concatenated and separated by a new line
> using the "& return" operator after each output. The final result is placed
> into a field with the name "display" using the "put" command.
>
> I'll save you the trouble: that code executes perfectly right out of the
> box, with no errors, and of course even though I didn't ask it to, it uses
> a variable to store the intermediate values, saving the field update for
> the end.
>
> If I were writing it, I'd probably do something like
>
> on mouseUp
>put "" into fizzbin
>repeat with x = 1 to 100
>   if x mod 5 = 0 then put "fizz " after fizzbin
>   if x mod 7 = 0 then put "bin " after fizzbin
>   if char -1 of fizzbin is space
>   then put return into char -1 of fizzbin
>   else put x & return after fizzbin
>end repeat
>put fizzbin into field "display"
> end mouseUp
>
> That might be a bit faster, but probably not as clear.
>
> Finally, I gave it the input:
>
> Now rewrite the code to be a function named "fizzbin" that takes an
> argument "n", repeats with 1 to n, and returns the results.
>
> function fizzbin n
>put "" into fizzbin
>repeat with x = 1 to n
>   if x mod 5 = 0 and x mod 7 = 0 then
>   put "fizz bin" & return after fizzbin
>   else if x mod 5 = 0 then
>   put "fizz" & return after fizzbin
>   else if x mod 7 = 0 then
>   put "bin" & return after fizzbin
>   else
>   put x & return after fizzbin
>   end if
>end repeat
>return fizzbin
> end fizzbin
>
> This works perfectly, and chat gpt also documents its answer:
>
> This code defines a function named "fizzbin" which takes an argument "n"
> that determines the range of the repeat loop. The function builds the
> result string in a variable "fizzbin" and return the final result. The
> calling script can then use the returned value for further processing or
> for displaying in a field.
>
> Grammatical issue notwithstanding, that's good documentation.
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


-- 
Kaveh Bazargan PhD
Director
River Valley Technologies  ● Twitter
 ● LinkedIn
 ● ORCID
 ● @kaveh1000@mastodon.social

*Accelerating the Communication of Research*
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscrib

Re: Training the AI to write better LiveCode

2023-01-14 Thread Beda via use-livecode
It seems to be more inspiring for me than talking to a rubber duck 
sitting on my desk, at least for simple problems.


For harder problems there will be, hopefully for ever, the user forum 
and this newslist.


Beda

Am 14.01.23 um 11:17 schrieb Kaveh via use-livecode:

Quite incredible!

It might be that LiveCode's simple syntax is best suited to ChatGPT.

On Sat, 14 Jan 2023 at 03:24, Geoff Canyon via use-livecode <
use-livecode@lists.runrev.com> wrote:


So just now I put this in to chatgpt:

"fizz bin" is a program that counts from 1 to 100, replacing every number
divisible by 5 with "fizz" and every number divisible by 7 with "bin"; and
numbers divisible by both 5 and 7 with "fizz bin". Write code in the
programming language livecode to execute "fizz bin"

This is what ChatGPT responded with:

repeat with x = 1 to 100
 if x mod 5 = 0 and x mod 7 = 0 then
 put "fizz bin"
 else if x mod 5 = 0 then
 put "fizz"
 else if x mod 7 = 0 then
 put "bin"
 else
 put x
 end if
end repeat

That works as-is, but obviously the results fly by in the message box. So I
put a field and a button on a card, and edited to this, and it works
perfectly:

on mouseUp
repeat with x = 1 to 100
   if x mod 5 = 0 and x mod 7 = 0 then
  put "fizz bin" & cr after fld 1
   else if x mod 5 = 0 then
  put "fizz" & cr after fld 1
   else if x mod 7 = 0 then
  put "bin" & cr after fld 1
   else
  put x & cr after fld 1
   end if
end repeat
end mouseUp

Then as I was typing this email I realized I was potentially selling
chatgpt short, so I put this in:

Modify that code so it works as an "on mouseUp" handler in a button, and
concatenates the results on individual lines, and puts the final result
into the field "display"

And it output this:


on mouseUp
put "" into fizzbin
repeat with x = 1 to 100
   if x mod 5 = 0 and x mod 7 = 0 then
   put "fizz bin" & return after fizzbin
   else if x mod 5 = 0 then
   put "fizz" & return after fizzbin
   else if x mod 7 = 0 then
   put "bin" & return after fizzbin
   else
   put x & return after fizzbin
   end if
end repeat
put fizzbin into field "display"
end mouseUp

And it followed that with instructions:

This code uses the "on mouseUp" handler to execute the script when the
button is clicked. The results are concatenated and separated by a new line
using the "& return" operator after each output. The final result is placed
into a field with the name "display" using the "put" command.

I'll save you the trouble: that code executes perfectly right out of the
box, with no errors, and of course even though I didn't ask it to, it uses
a variable to store the intermediate values, saving the field update for
the end.

If I were writing it, I'd probably do something like

on mouseUp
put "" into fizzbin
repeat with x = 1 to 100
   if x mod 5 = 0 then put "fizz " after fizzbin
   if x mod 7 = 0 then put "bin " after fizzbin
   if char -1 of fizzbin is space
   then put return into char -1 of fizzbin
   else put x & return after fizzbin
end repeat
put fizzbin into field "display"
end mouseUp

That might be a bit faster, but probably not as clear.

Finally, I gave it the input:

Now rewrite the code to be a function named "fizzbin" that takes an
argument "n", repeats with 1 to n, and returns the results.

function fizzbin n
put "" into fizzbin
repeat with x = 1 to n
   if x mod 5 = 0 and x mod 7 = 0 then
   put "fizz bin" & return after fizzbin
   else if x mod 5 = 0 then
   put "fizz" & return after fizzbin
   else if x mod 7 = 0 then
   put "bin" & return after fizzbin
   else
   put x & return after fizzbin
   end if
end repeat
return fizzbin
end fizzbin

This works perfectly, and chat gpt also documents its answer:

This code defines a function named "fizzbin" which takes an argument "n"
that determines the range of the repeat loop. The function builds the
result string in a variable "fizzbin" and return the final result. The
calling script can then use the returned value for further processing or
for displaying in a field.

Grammatical issue notwithstanding, that's good documentation.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your
subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode





___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Mark Wieder via use-livecode

On 1/14/23 03:35, Beda via use-livecode wrote:
It seems to be more inspiring for me than talking to a rubber duck 
sitting on my desk, at least for simple problems.


For harder problems there will be, hopefully for ever, the user forum 
and this newslist.


I am *not* giving up my rubber duck.

--
 Mark Wieder
 ahsoftw...@gmail.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Geoff Canyon via use-livecode
On Fri, Jan 13, 2023 at 7:22 PM Geoff Canyon  wrote:

>
> If I were writing it, I'd probably do something like
>
> [my code]
>
> That might be a bit faster, but probably not as clear.
>

I just checked, and my code is about 20% *slower* and still less clear.
Good grief, I'm about to be replaced by a machine.
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Mark Wieder via use-livecode

On 1/14/23 09:30, Geoff Canyon via use-livecode wrote:

On Fri, Jan 13, 2023 at 7:22 PM Geoff Canyon  wrote:



If I were writing it, I'd probably do something like

[my code]

That might be a bit faster, but probably not as clear.



I just checked, and my code is about 20% *slower* and still less clear.
Good grief, I'm about to be replaced by a machine.


Keep in mind,though, that there's lots of example fizzbuzz code for the 
algorithms to draw from.


--
 Mark Wieder
 ahsoftw...@gmail.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread harrison--- via use-livecode
I charge all of my clients for training.

I charge a lot more to train Artificial Intelligence Chatbots!

Unfortunately, chatbots don’t yet know how to pay me,
and until someone is willing to pay me to train it, that isn’t
going to happen.

Until they are willing and able to pay me for training, I have 
better things to do with my time.

Just my 2 cents. ;-)

Rick



___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread harrison--- via use-livecode
The rules for fizzbin were intended to be complex, so that Kirk could lull his 
audience into lowering their defenses long enough to be overwhelmed.

The game can be played with a standard Earth deck of cards, despite the 
slightly differing deck on Beta Antares IV 
.
Each player gets six cards, except for the player on the dealer's right, who 
gets seven.
The second card is turned up, except on Tuesdays.
Two jacks are a "half-fizzbin".
If you have a half-fizzbin:
a third jack is a "shralk" and results in disqualification;
one wants a king and a deuce, except at night, when one wants a queen and a 
four;
if a king had been dealt, the player would get another card, except when it is 
dark, in which case he'd have to give it back.
The top hand is a "royal fizzbin", but the odds of getting one are said to be 
"astronomical".
Give those rules to ChatGPT. Command it to create the game using LiveCode, and 
see what happens!  ;-)

Rick

> On Jan 14, 2023, at 12:43 PM, Mark Wieder via use-livecode 
>  wrote:
> 
> Keep in mind,though, that there's lots of example fizzbuzz code for the 
> algorithms to draw from.

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Mark Smith via use-livecode
We live in interesting times. 

> On 14 Jan 2023, at 3:22 am, Geoff Canyon via use-livecode 
>  wrote:
> 
> So just now I put this in to chatgpt:
> 
> "fizz bin" is a program that counts from 1 to 100, replacing every number
> divisible by 5 with "fizz" and every number divisible by 7 with "bin"; and
> numbers divisible by both 5 and 7 with "fizz bin". Write code in the
> programming language livecode to execute "fizz bin"
> 
> This is what ChatGPT responded with:
> 
> repeat with x = 1 to 100
>if x mod 5 = 0 and x mod 7 = 0 then
>put "fizz bin"
>else if x mod 5 = 0 then
>put "fizz"
>else if x mod 7 = 0 then
>put "bin"
>else
>put x
>end if
> end repeat
> 
> That works as-is, but obviously the results fly by in the message box. So I
> put a field and a button on a card, and edited to this, and it works
> perfectly:
> 
> on mouseUp
>   repeat with x = 1 to 100
>  if x mod 5 = 0 and x mod 7 = 0 then
> put "fizz bin" & cr after fld 1
>  else if x mod 5 = 0 then
> put "fizz" & cr after fld 1
>  else if x mod 7 = 0 then
> put "bin" & cr after fld 1
>  else
> put x & cr after fld 1
>  end if
>   end repeat
> end mouseUp
> 
> Then as I was typing this email I realized I was potentially selling
> chatgpt short, so I put this in:
> 
> Modify that code so it works as an "on mouseUp" handler in a button, and
> concatenates the results on individual lines, and puts the final result
> into the field "display"
> 
> And it output this:
> 
> 
> on mouseUp
>   put "" into fizzbin
>   repeat with x = 1 to 100
>  if x mod 5 = 0 and x mod 7 = 0 then
>  put "fizz bin" & return after fizzbin
>  else if x mod 5 = 0 then
>  put "fizz" & return after fizzbin
>  else if x mod 7 = 0 then
>  put "bin" & return after fizzbin
>  else
>  put x & return after fizzbin
>  end if
>   end repeat
>   put fizzbin into field "display"
> end mouseUp
> 
> And it followed that with instructions:
> 
> This code uses the "on mouseUp" handler to execute the script when the
> button is clicked. The results are concatenated and separated by a new line
> using the "& return" operator after each output. The final result is placed
> into a field with the name "display" using the "put" command.
> 
> I'll save you the trouble: that code executes perfectly right out of the
> box, with no errors, and of course even though I didn't ask it to, it uses
> a variable to store the intermediate values, saving the field update for
> the end.
> 
> If I were writing it, I'd probably do something like
> 
> on mouseUp
>   put "" into fizzbin
>   repeat with x = 1 to 100
>  if x mod 5 = 0 then put "fizz " after fizzbin
>  if x mod 7 = 0 then put "bin " after fizzbin
>  if char -1 of fizzbin is space
>  then put return into char -1 of fizzbin
>  else put x & return after fizzbin
>   end repeat
>   put fizzbin into field "display"
> end mouseUp
> 
> That might be a bit faster, but probably not as clear.
> 
> Finally, I gave it the input:
> 
> Now rewrite the code to be a function named "fizzbin" that takes an
> argument "n", repeats with 1 to n, and returns the results.
> 
> function fizzbin n
>   put "" into fizzbin
>   repeat with x = 1 to n
>  if x mod 5 = 0 and x mod 7 = 0 then
>  put "fizz bin" & return after fizzbin
>  else if x mod 5 = 0 then
>  put "fizz" & return after fizzbin
>  else if x mod 7 = 0 then
>  put "bin" & return after fizzbin
>  else
>  put x & return after fizzbin
>  end if
>   end repeat
>   return fizzbin
> end fizzbin
> 
> This works perfectly, and chat gpt also documents its answer:
> 
> This code defines a function named "fizzbin" which takes an argument "n"
> that determines the range of the repeat loop. The function builds the
> result string in a variable "fizzbin" and return the final result. The
> calling script can then use the returned value for further processing or
> for displaying in a field.
> 
> Grammatical issue notwithstanding, that's good documentation.
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription 
> preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Mark Smith via use-livecode
Thanks for posting this Geoff. It’s the first time I've seen a ongoing dialog 
between a programmer and Chat GPT and the first thing I am struck by (but not 
the only thing) is it’s ability to deal with human ambiguity. For example, you 
ask it to modify the code to be an “on mouseUp handler in a button". But 
nowhere in its response is there any sign of a button. It just totally ignored 
that part of your request. The code it provides works in a card, a stack, a 
graphic image, an svg widget, in fact, in anything that accepts mouseUp input. 
And yet, it didn’t worry itself about that. Very interesting. It’s kind of 
like, “this works in a button, so good enough”. That is not the kind of 
“nuance” I am used to expecting from an AI. So, progress has clearly been made 
in interpreting what humans say (or ask) in a very loose way. 

The 2nd, and perhaps more astounding example, is when you ask it to "rewrite 
the code to be a function that takes an argument "n", repeats with 1 to n, and 
returns the results”. 

The really clever bit here is not that it rewrites the previous code into a 
function, but that it removes the bit about "put fizzbin into field “display””. 
How does it know that putting the result in a field is NOT the typical 
responsibility of a function? How does it know that that step needs to occur 
AFTER the function call? That is so high-level that I am sure lots of beginning 
programmers have made that mistake. It even comments on it in the 
documentation. So there is some very deep semantic understanding of programming 
code that is going on here. Because,  you did not ask it to do that, but the 
fact that it did it anyway indicates it clearly understands what the purpose of 
a function is. 

Quite weird for me to comprehend how it knows that. Unless of course, you were 
somehow more specific than your examples illustrate. 

Mark

> On 14 Jan 2023, at 3:22 am, Geoff Canyon via use-livecode 
>  wrote:
> 
> So just now I put this in to chatgpt:
> 
> "fizz bin" is a program that counts from 1 to 100, replacing every number
> divisible by 5 with "fizz" and every number divisible by 7 with "bin"; and
> numbers divisible by both 5 and 7 with "fizz bin". Write code in the
> programming language livecode to execute "fizz bin"
> 
> This is what ChatGPT responded with:
> 
> repeat with x = 1 to 100
>if x mod 5 = 0 and x mod 7 = 0 then
>put "fizz bin"
>else if x mod 5 = 0 then
>put "fizz"
>else if x mod 7 = 0 then
>put "bin"
>else
>put x
>end if
> end repeat
> 
> That works as-is, but obviously the results fly by in the message box. So I
> put a field and a button on a card, and edited to this, and it works
> perfectly:
> 
> on mouseUp
>   repeat with x = 1 to 100
>  if x mod 5 = 0 and x mod 7 = 0 then
> put "fizz bin" & cr after fld 1
>  else if x mod 5 = 0 then
> put "fizz" & cr after fld 1
>  else if x mod 7 = 0 then
> put "bin" & cr after fld 1
>  else
> put x & cr after fld 1
>  end if
>   end repeat
> end mouseUp
> 
> Then as I was typing this email I realized I was potentially selling
> chatgpt short, so I put this in:
> 
> Modify that code so it works as an "on mouseUp" handler in a button, and
> concatenates the results on individual lines, and puts the final result
> into the field "display"
> 
> And it output this:
> 
> 
> on mouseUp
>   put "" into fizzbin
>   repeat with x = 1 to 100
>  if x mod 5 = 0 and x mod 7 = 0 then
>  put "fizz bin" & return after fizzbin
>  else if x mod 5 = 0 then
>  put "fizz" & return after fizzbin
>  else if x mod 7 = 0 then
>  put "bin" & return after fizzbin
>  else
>  put x & return after fizzbin
>  end if
>   end repeat
>   put fizzbin into field "display"
> end mouseUp
> 
> And it followed that with instructions:
> 
> This code uses the "on mouseUp" handler to execute the script when the
> button is clicked. The results are concatenated and separated by a new line
> using the "& return" operator after each output. The final result is placed
> into a field with the name "display" using the "put" command.
> 
> I'll save you the trouble: that code executes perfectly right out of the
> box, with no errors, and of course even though I didn't ask it to, it uses
> a variable to store the intermediate values, saving the field update for
> the end.
> 
> If I were writing it, I'd probably do something like
> 
> on mouseUp
>   put "" into fizzbin
>   repeat with x = 1 to 100
>  if x mod 5 = 0 then put "fizz " after fizzbin
>  if x mod 7 = 0 then put "bin " after fizzbin
>  if char -1 of fizzbin is space
>  then put return into char -1 of fizzbin
>  else put x & return after fizzbin
>   end repeat
>   put fizzbin into field "display"
> end mouseUp
> 
> That might be a bit faster, but probably not as clear.
> 
> Finally, I gave it the input:
> 
> Now rewrite the code to be a function name

Re: Training the AI to write better LiveCode

2023-01-14 Thread Geoff Canyon via use-livecode
On Sat, Jan 14, 2023 at 12:08 PM Mark Smith  wrote:

>
> Quite weird for me to comprehend how it knows that. Unless of course, you
> were somehow more specific than your examples illustrate.
>

I posted the exact prompts I gave it, no hidden tricks :-)
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Geoff Canyon via use-livecode
On Sat, Jan 14, 2023 at 9:44 AM Mark Wieder via use-livecode <
use-livecode@lists.runrev.com> wrote:

>
> Keep in mind,though, that there's lots of example fizzbuzz code for the
> algorithms to draw from.
>

Definitely. I'll have to think about a (possibly) original challenge.

gc
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Training the AI to write better LiveCode

2023-01-14 Thread Kaveh via use-livecode
I just tried Google to the answer to a problem. Didn't get it first time,
so tried ChatGPT. I asked:

*How do I add a button to a group in LiveCode using a script?*

I got:

*create button "myButton" in group "myGroup"*


*This command creates a new button object with the name "myButton" and
places it inside the group "myGroup".*
Just what I needed.

You can also set properties of the button

On Sat, 14 Jan 2023 at 20:09, Mark Smith via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Thanks for posting this Geoff. It’s the first time I've seen a ongoing
> dialog between a programmer and Chat GPT and the first thing I am struck by
> (but not the only thing) is it’s ability to deal with human ambiguity. For
> example, you ask it to modify the code to be an “on mouseUp handler in a
> button". But nowhere in its response is there any sign of a button. It just
> totally ignored that part of your request. The code it provides works in a
> card, a stack, a graphic image, an svg widget, in fact, in anything that
> accepts mouseUp input. And yet, it didn’t worry itself about that. Very
> interesting. It’s kind of like, “this works in a button, so good enough”.
> That is not the kind of “nuance” I am used to expecting from an AI. So,
> progress has clearly been made in interpreting what humans say (or ask) in
> a very loose way.
>
> The 2nd, and perhaps more astounding example, is when you ask it to
> "rewrite the code to be a function that takes an argument "n", repeats with
> 1 to n, and returns the results”.
>
> The really clever bit here is not that it rewrites the previous code into
> a function, but that it removes the bit about "put fizzbin into field
> “display””. How does it know that putting the result in a field is NOT the
> typical responsibility of a function? How does it know that that step needs
> to occur AFTER the function call? That is so high-level that I am sure lots
> of beginning programmers have made that mistake. It even comments on it in
> the documentation. So there is some very deep semantic understanding of
> programming code that is going on here. Because,  you did not ask it to do
> that, but the fact that it did it anyway indicates it clearly understands
> what the purpose of a function is.
>
> Quite weird for me to comprehend how it knows that. Unless of course, you
> were somehow more specific than your examples illustrate.
>
> Mark
>
> > On 14 Jan 2023, at 3:22 am, Geoff Canyon via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > So just now I put this in to chatgpt:
> >
> > "fizz bin" is a program that counts from 1 to 100, replacing every number
> > divisible by 5 with "fizz" and every number divisible by 7 with "bin";
> and
> > numbers divisible by both 5 and 7 with "fizz bin". Write code in the
> > programming language livecode to execute "fizz bin"
> >
> > This is what ChatGPT responded with:
> >
> > repeat with x = 1 to 100
> >if x mod 5 = 0 and x mod 7 = 0 then
> >put "fizz bin"
> >else if x mod 5 = 0 then
> >put "fizz"
> >else if x mod 7 = 0 then
> >put "bin"
> >else
> >put x
> >end if
> > end repeat
> >
> > That works as-is, but obviously the results fly by in the message box.
> So I
> > put a field and a button on a card, and edited to this, and it works
> > perfectly:
> >
> > on mouseUp
> >   repeat with x = 1 to 100
> >  if x mod 5 = 0 and x mod 7 = 0 then
> > put "fizz bin" & cr after fld 1
> >  else if x mod 5 = 0 then
> > put "fizz" & cr after fld 1
> >  else if x mod 7 = 0 then
> > put "bin" & cr after fld 1
> >  else
> > put x & cr after fld 1
> >  end if
> >   end repeat
> > end mouseUp
> >
> > Then as I was typing this email I realized I was potentially selling
> > chatgpt short, so I put this in:
> >
> > Modify that code so it works as an "on mouseUp" handler in a button, and
> > concatenates the results on individual lines, and puts the final result
> > into the field "display"
> >
> > And it output this:
> >
> >
> > on mouseUp
> >   put "" into fizzbin
> >   repeat with x = 1 to 100
> >  if x mod 5 = 0 and x mod 7 = 0 then
> >  put "fizz bin" & return after fizzbin
> >  else if x mod 5 = 0 then
> >  put "fizz" & return after fizzbin
> >  else if x mod 7 = 0 then
> >  put "bin" & return after fizzbin
> >  else
> >  put x & return after fizzbin
> >  end if
> >   end repeat
> >   put fizzbin into field "display"
> > end mouseUp
> >
> > And it followed that with instructions:
> >
> > This code uses the "on mouseUp" handler to execute the script when the
> > button is clicked. The results are concatenated and separated by a new
> line
> > using the "& return" operator after each output. The final result is
> placed
> > into a field with the name "display" using the "put" command.
> >
> > I'll save you the trouble: that code executes perfectly right out of the
> > box, with no errors, and of 

Re: Standalone riddle

2023-01-14 Thread J. Landman Gay via use-livecode

On 1/14/23 1:55 AM, Geoff Canyon via use-livecode wrote:

This doesn't solve the puzzle, but: use a stack property to store the value
instead?


The value is entered correctly and displays after I dismiss the error dialog. I have finally 
found where the issue is, but I don't know why it happens. The normal sequence is pretty simple:


1. Enter a search term and hit the return key on the virtual keyboard. This triggers the 
inputReturnKey message.


2. InputReturnKey calls handler doSearch, which looks up the definition, populates a browser 
widget on card 2, and goes to card 2.


What is happening is that inputReturnKey is being sent twice. The first time it works as 
expected, but the second time we are already on card 2 and the controls on card 1 are no longer 
available. Ergo, I get the "no such object" error. I found this by inserting "checkCd the 
params" at the beginning of doSearch. CheckCd does this:


on checkCd pParams -- track inputReturnKey error
  put pParams &cr&cr into tData -- the calling handler params
  put the executionContexts after tData
  answer tData
end checkCd

...and I got two dialogs in a row. I could see card 2 behind the second one, which was a debug 
errorDialog instead of an answer dialog.


So the burning question is why does a single tap on the return key send two duplicate 
inputReturnKey messages, and why does that happen only in a built standalone?


Maybe I won't embarrass myself if I enter a bug report now.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software   | http://www.hyperactivesw.com


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode