Re: Training the AI to write better LiveCode

2023-01-13 Thread Kevin Miller via use-livecode
Its far more than a search engine. It can edit copy, write articles and analyse 
multiple inputs for similarities and differences and a lot more. Like all such 
new technologies this is going to be here to stay. So its not a case of trying 
not to train it in order to preserve programmer jobs. There will be plenty left 
for a human to do in building an app, we are just going to get more productive 
as this gets better. What is important is ensuring that LiveCode, which is 
supported already, is not left behind and that you can generate LiveCode code 
at the same standard as other languages. At present its coding abilities in any 
language are interesting but a bit ropy, lets ensure that as it gets better as 
it inevitably will, its LiveCode skills improve too.

Kind regards, 

Kevin 

Kevin Miller ~ ke...@livecode.com ~ http://www.livecode.com/ 
LiveCode: Build Amazing Things 



On 12/01/2023, 17:45, "use-livecode on behalf of harrison--- via use-livecode" 
mailto:use-livecode-boun...@lists.runrev.com> on behalf of 
use-livecode@lists.runrev.com > wrote:


ChatGPT has been called a search engine without the search engine.
I would tend to agree with that. It seems to find bits and pieces of code
or articles that others have written before and tries to put them together.
It uses a text typing output mode to give it the appearance of an
intelligence/person typing at the keyboard, but that is part of the illusion.


ChatGPT claims that it isn’t connected to the internet, but it is, or it 
wouldn’t
be able to respond to your questions over the internet. The database
that it accesses for answers is however compartmentalized, as far as
we have been told.


If by some miracle we were able to train it to be super intelligent at
writing computer code, do we as programmers really want to shoot
ourselves in the foot by giving it the tools to replace our talent?
That’s food for thought. Just because something may be technologically
possible, doesn’t mean we should necessarily do that thing.


Just my two cents.


Enjoy your day!


Rick


> On Jan 12, 2023, at 9:02 AM, Mike Kerner via use-livecode 
> mailto:use-livecode@lists.runrev.com>> wrote:
> 
> yesterday was not a good session for me. all responses were irrelevant, and
> sometimes seemed random.
> we'll see what we find, the next time.


___
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-13 Thread Mike Kerner via use-livecode
"AI" has always been a misleading term, for like 40 years.
gawd, i'm old.
There is pattern matching, tree traversals, bayesian probability, etc.
it's definitely not anything like a wiki.
it might just be helpful at slogging out a lot of the code that we have to
write or include by hand, especially if you are trying to tackle something
new, especially for code that isn't neatly organized and instantly
available.
but, it's also not amazing and mature, either. we can be both surprised at
the program a ten-year-old writes, and recognize that it's...not amazing.


On Fri, Jan 13, 2023 at 5:50 AM Kevin Miller via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Its far more than a search engine. It can edit copy, write articles and
> analyse multiple inputs for similarities and differences and a lot more.
> Like all such new technologies this is going to be here to stay. So its not
> a case of trying not to train it in order to preserve programmer jobs.
> There will be plenty left for a human to do in building an app, we are just
> going to get more productive as this gets better. What is important is
> ensuring that LiveCode, which is supported already, is not left behind and
> that you can generate LiveCode code at the same standard as other
> languages. At present its coding abilities in any language are interesting
> but a bit ropy, lets ensure that as it gets better as it inevitably will,
> its LiveCode skills improve too.
>
> Kind regards,
>
> Kevin
>
> Kevin Miller ~ ke...@livecode.com ~ http://www.livecode.com/
> LiveCode: Build Amazing Things
>
>
>
> On 12/01/2023, 17:45, "use-livecode on behalf of harrison--- via
> use-livecode"  use-livecode-boun...@lists.runrev.com> on behalf of
> use-livecode@lists.runrev.com >
> wrote:
>
>
> ChatGPT has been called a search engine without the search engine.
> I would tend to agree with that. It seems to find bits and pieces of code
> or articles that others have written before and tries to put them together.
> It uses a text typing output mode to give it the appearance of an
> intelligence/person typing at the keyboard, but that is part of the
> illusion.
>
>
> ChatGPT claims that it isn’t connected to the internet, but it is, or it
> wouldn’t
> be able to respond to your questions over the internet. The database
> that it accesses for answers is however compartmentalized, as far as
> we have been told.
>
>
> If by some miracle we were able to train it to be super intelligent at
> writing computer code, do we as programmers really want to shoot
> ourselves in the foot by giving it the tools to replace our talent?
> That’s food for thought. Just because something may be technologically
> possible, doesn’t mean we should necessarily do that thing.
>
>
> Just my two cents.
>
>
> Enjoy your day!
>
>
> Rick
>
>
> > On Jan 12, 2023, at 9:02 AM, Mike Kerner via use-livecode <
> use-livecode@lists.runrev.com >
> wrote:
> >
> > yesterday was not a good session for me. all responses were irrelevant,
> and
> > sometimes seemed random.
> > we'll see what we find, the next time.
>
>
> ___
> 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 <
> 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
>


-- 
On the first day, God created the heavens and the Earth
On the second day, God created the oceans.
On the third day, God put the animals on hold for a few hours,
   and did a little diving.
And God said, "This is good."
___
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-13 Thread Mark Wieder via use-livecode

On 1/13/23 07:30, Mike Kerner via use-livecode wrote:

"AI" has always been a misleading term, for like 40 years.
gawd, i'm old.
There is pattern matching, tree traversals, bayesian probability, etc.
it's definitely not anything like a wiki.
it might just be helpful at slogging out a lot of the code that we have to
write or include by hand, especially if you are trying to tackle something
new, especially for code that isn't neatly organized and instantly
available.
but, it's also not amazing and mature, either. we can be both surprised at
the program a ten-year-old writes, and recognize that it's...not amazing.


I think maybe it's time to stop using the ridiculous "AI" term and refer 
to this more properly as Machine Learning. From my experience using 
TensorFlow the quality of your results depends mainly on the corpus of 
data used in training. Not just the quantity of data used to train the 
system but also the quality of the data used. It doesn't matter whether 
you're training the system for facial recognition or grammar checking or 
code generation, the better quality data you can throw at the system the 
better your results will be. Any ML system will have a bias towards the 
data it was trained on, so it stands to reason that having better code 
to draw on will allow it to make better judgements about code creation.


--
 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


Standalone riddle

2023-01-13 Thread J. Landman Gay via use-livecode
I have a 2-card stack, very simple. The first card has a plain text list field and an editable 
search field. The user types in a string and the resulting match is displayed on card 2 with 
definitions. The stack requires no inclusions and scripts are extremely basic. I use a native 
Android field for the search term, and since mobile controls will be removed when the card 
closes, I place the search term into a hidden LC field for later reference.


I build for Android using LC 10 dp 4, signed for "development only". If I cable the phone to 
the Mac and do a Test build, the apk runs perfectly. If I build an independent standalone and 
install the apk from Google Drive, it runs fine except when putting the search term into the LC 
field, where it claims there is no such object. It is most certainly there on the card.


I can fix this instance by using "field x of me" but then I get the same error in an unrelated 
line in a different handler. If I fix that one, it moves again. The riddle is why does it 
happen in a standalone apk and not in a cabled test run?


The script snippet from cd 1:

on doSearch pText -- pText extracted from native field
  put word 1 to -1 of pText into pText -- strip trailing spaces
  put pText into fld "searchTerm" -- for reference; ERROR: "no such object"
  ... 
  go cd 2

BTW, if I leave the test apk on the phone it continues to work correctly after removing the 
cable. The odd behavior happens consistently on a Pixel 7 phone, an old Huawei tablet and a 
newish Samsung tablet.


If I use Nearby Share to move the working apk from a previously cabled build to another device, 
it also works okay. So something is different when building an independent standalone vs. 
building a test app.


--
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


Re: Standalone riddle

2023-01-13 Thread J. Landman Gay via use-livecode
I take back the "no inclusions" part, I do include the browser widget on card 2. I see now I 
also include the native Android field widget but it isn't placed anywhere and isn't used. The 
native field I do use is created with mobileControlCreate.


On 1/13/23 3:42 PM, J. Landman Gay via use-livecode wrote:
I have a 2-card stack, very simple. The first card has a plain text list field and an editable 
search field. The user types in a string and the resulting match is displayed on card 2 with 
definitions. The stack requires no inclusions and scripts are extremely basic. I use a native 
Android field for the search term, and since mobile controls will be removed when the card 
closes, I place the search term into a hidden LC field for later reference.


I build for Android using LC 10 dp 4, signed for "development only". If I cable the phone to 
the Mac and do a Test build, the apk runs perfectly. If I build an independent standalone and 
install the apk from Google Drive, it runs fine except when putting the search term into the LC 
field, where it claims there is no such object. It is most certainly there on the card.


I can fix this instance by using "field x of me" but then I get the same error in an unrelated 
line in a different handler. If I fix that one, it moves again. The riddle is why does it 
happen in a standalone apk and not in a cabled test run?


The script snippet from cd 1:

on doSearch pText -- pText extracted from native field
   put word 1 to -1 of pText into pText -- strip trailing spaces
   put pText into fld "searchTerm" -- for reference; ERROR: "no such object"
   ... 
   go cd 2

BTW, if I leave the test apk on the phone it continues to work correctly after removing the 
cable. The odd behavior happens consistently on a Pixel 7 phone, an old Huawei tablet and a 
newish Samsung tablet.


If I use Nearby Share to move the working apk from a previously cabled build to another device, 
it also works okay. So something is different when building an independent standalone vs. 
building a test app.




--
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


RE: Standalone riddle

2023-01-13 Thread Ralph DiMola via use-livecode
I would try to install the "Test version" on another Android device and see
if it runs OK. Then it would narrow it to the building process.
The "test" apk will be in some temp folder. I will look for it you can't
find it.

Ralph DiMola
IT Director
Evergreen Information Services

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of J. Landman Gay via use-livecode
Sent: Friday, January 13, 2023 4:42 PM
To: LiveCode Mailing List
Cc: J. Landman Gay
Subject: Standalone riddle

I have a 2-card stack, very simple. The first card has a plain text list
field and an editable search field. The user types in a string and the
resulting match is displayed on card 2 with definitions. The stack requires
no inclusions and scripts are extremely basic. I use a native Android field
for the search term, and since mobile controls will be removed when the card
closes, I place the search term into a hidden LC field for later reference.

I build for Android using LC 10 dp 4, signed for "development only". If I
cable the phone to the Mac and do a Test build, the apk runs perfectly. If I
build an independent standalone and install the apk from Google Drive, it
runs fine except when putting the search term into the LC field, where it
claims there is no such object. It is most certainly there on the card.

I can fix this instance by using "field x of me" but then I get the same
error in an unrelated line in a different handler. If I fix that one, it
moves again. The riddle is why does it happen in a standalone apk and not in
a cabled test run?

The script snippet from cd 1:

on doSearch pText -- pText extracted from native field
   put word 1 to -1 of pText into pText -- strip trailing spaces
   put pText into fld "searchTerm" -- for reference; ERROR: "no such object"
   ... 
   go cd 2

BTW, if I leave the test apk on the phone it continues to work correctly
after removing the cable. The odd behavior happens consistently on a Pixel 7
phone, an old Huawei tablet and a newish Samsung tablet.

If I use Nearby Share to move the working apk from a previously cabled build
to another device, it also works okay. So something is different when
building an independent standalone vs. 
building a test app.

-- 
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


___
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: Standalone riddle

2023-01-13 Thread J. Landman Gay via use-livecode
Did that. The test version runs okay when moved to another device. It's 
something in the build process or else it's something I can't identify yet.

--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On January 13, 2023 5:02:13 PM Ralph DiMola via use-livecode 
 wrote:



I would try to install the "Test version" on another Android device and see
if it runs OK. Then it would narrow it to the building process.
The "test" apk will be in some temp folder. I will look for it you can't
find it.

Ralph DiMola
IT Director
Evergreen Information Services

-Original Message-
From: use-livecode [mailto:use-livecode-boun...@lists.runrev.com] On Behalf
Of J. Landman Gay via use-livecode
Sent: Friday, January 13, 2023 4:42 PM
To: LiveCode Mailing List
Cc: J. Landman Gay
Subject: Standalone riddle

I have a 2-card stack, very simple. The first card has a plain text list
field and an editable search field. The user types in a string and the
resulting match is displayed on card 2 with definitions. The stack requires
no inclusions and scripts are extremely basic. I use a native Android field
for the search term, and since mobile controls will be removed when the card
closes, I place the search term into a hidden LC field for later reference.

I build for Android using LC 10 dp 4, signed for "development only". If I
cable the phone to the Mac and do a Test build, the apk runs perfectly. If I
build an independent standalone and install the apk from Google Drive, it
runs fine except when putting the search term into the LC field, where it
claims there is no such object. It is most certainly there on the card.

I can fix this instance by using "field x of me" but then I get the same
error in an unrelated line in a different handler. If I fix that one, it
moves again. The riddle is why does it happen in a standalone apk and not in
a cabled test run?

The script snippet from cd 1:

on doSearch pText -- pText extracted from native field
  put word 1 to -1 of pText into pText -- strip trailing spaces
  put pText into fld "searchTerm" -- for reference; ERROR: "no such object"
  ... 
  go cd 2

BTW, if I leave the test apk on the phone it continues to work correctly
after removing the cable. The odd behavior happens consistently on a Pixel 7
phone, an old Huawei tablet and a newish Samsung tablet.

If I use Nearby Share to move the working apk from a previously cabled build
to another device, it also works okay. So something is different when
building an independent standalone vs.
building a test app.

--
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


___
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: Standalone riddle

2023-01-13 Thread Paul Dupuis via use-livecode

Fully qualified object references are your friend.

Have you tried referring to the field as:

put pText into field "searchTerm" of cd 1 of stack "stackName" -- of 
instead of the card number, use name or ID


On 1/13/2023 4:42 PM, J. Landman Gay via use-livecode wrote:
I have a 2-card stack, very simple. The first card has a plain text 
list field and an editable search field. The user types in a string 
and the resulting match is displayed on card 2 with definitions. The 
stack requires no inclusions and scripts are extremely basic. I use a 
native Android field for the search term, and since mobile controls 
will be removed when the card closes, I place the search term into a 
hidden LC field for later reference.


I build for Android using LC 10 dp 4, signed for "development only". 
If I cable the phone to the Mac and do a Test build, the apk runs 
perfectly. If I build an independent standalone and install the apk 
from Google Drive, it runs fine except when putting the search term 
into the LC field, where it claims there is no such object. It is most 
certainly there on the card.


I can fix this instance by using "field x of me" but then I get the 
same error in an unrelated line in a different handler. If I fix that 
one, it moves again. The riddle is why does it happen in a standalone 
apk and not in a cabled test run?


The script snippet from cd 1:

on doSearch pText -- pText extracted from native field
  put word 1 to -1 of pText into pText -- strip trailing spaces
  put pText into fld "searchTerm" -- for reference; ERROR: "no such 
object"

  ... 
  go cd 2

BTW, if I leave the test apk on the phone it continues to work 
correctly after removing the cable. The odd behavior happens 
consistently on a Pixel 7 phone, an old Huawei tablet and a newish 
Samsung tablet.


If I use Nearby Share to move the working apk from a previously cabled 
build to another device, it also works okay. So something is different 
when building an independent standalone vs. building a test app.





___
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: Standalone riddle

2023-01-13 Thread J. Landman Gay via use-livecode
That's how I fixed the first two errors, though each fix moves the error 
somewhere else. This stack ran fine the last time I compiled it, maybe 2 
years ago. And when the error occurs, the card has not changed and by 
default, without a full object reference, the current card should be the 
reference.


Looking farther down the list in the error dialog, it references line 
numbers in the 400-600 range. My scripts barely have 150 lines at the most, 
which seems to imply an error somewhere in the LC scripts, though the top 
error points to line 89 in the handler I posted part of. I tried building 
with LC 9.x and I'm still getting the same error(s). Also, when I dismiss 
the error dialog, the scripts have run successfully and I end up on card 2 
with the correct data in the browser widget.


The riddle remains. Why does a standalone behave differently from a test 
build? The error never occurs in the IDE either. I'd file a but report, but 
I'm afraid I may have done something stupid and I don't want to embarrass 
myself yet.


--
Jacqueline Landman Gay | jac...@hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com
On January 13, 2023 6:42:35 PM Paul Dupuis via use-livecode 
 wrote:



Fully qualified object references are your friend.

Have you tried referring to the field as:

put pText into field "searchTerm" of cd 1 of stack "stackName" -- of
instead of the card number, use name or ID

On 1/13/2023 4:42 PM, J. Landman Gay via use-livecode wrote:

I have a 2-card stack, very simple. The first card has a plain text
list field and an editable search field. The user types in a string
and the resulting match is displayed on card 2 with definitions. The
stack requires no inclusions and scripts are extremely basic. I use a
native Android field for the search term, and since mobile controls
will be removed when the card closes, I place the search term into a
hidden LC field for later reference.

I build for Android using LC 10 dp 4, signed for "development only".
If I cable the phone to the Mac and do a Test build, the apk runs
perfectly. If I build an independent standalone and install the apk
from Google Drive, it runs fine except when putting the search term
into the LC field, where it claims there is no such object. It is most
certainly there on the card.

I can fix this instance by using "field x of me" but then I get the
same error in an unrelated line in a different handler. If I fix that
one, it moves again. The riddle is why does it happen in a standalone
apk and not in a cabled test run?

The script snippet from cd 1:

on doSearch pText -- pText extracted from native field
  put word 1 to -1 of pText into pText -- strip trailing spaces
  put pText into fld "searchTerm" -- for reference; ERROR: "no such
object"
  ... 
  go cd 2

BTW, if I leave the test apk on the phone it continues to work
correctly after removing the cable. The odd behavior happens
consistently on a Pixel 7 phone, an old Huawei tablet and a newish
Samsung tablet.

If I use Nearby Share to move the working apk from a previously cabled
build to another device, it also works okay. So something is different
when building an independent standalone vs. building a test app.




___
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: Standalone riddle

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

On 1/13/23 17:53, J. Landman Gay via use-livecode wrote:
without a full object reference, the current card should be the
reference.

Heh. I think *should be* is the key phrase there.



Looking farther down the list in the error dialog, it references line 
numbers in the 400-600 range. My scripts barely have 150 lines at the 


It sounds like something in an IDE script is not properly dereferencing 
the object/card/stack.


--
 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-13 Thread Jim Lambert via use-livecode
> Kevin wrote:
> What is important is ensuring that LiveCode, which is supported already, is 
> not left behind and that you can generate LiveCode code at the same standard 
> as other languages. 

Exactly!

> Rick wrote:

> Just because something may be technologically
> possible, doesn't mean we should necessarily do that thing.

Ah! But humans always do. ;)

Jim Lambert


___
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-13 Thread Geoff Canyon via use-livecode
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


Re: Standalone riddle

2023-01-13 Thread Geoff Canyon via use-livecode
This doesn't solve the puzzle, but: use a stack property to store the value
instead?
___
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