Re: Goofy question #7234

2017-08-23 Thread Mike Bonner via use-livecode
Old question but..  since its a function, whether you use do or not, gotta
have the () at the end.

On Wed, Aug 23, 2017 at 8:57 AM, Jonathan Lynch via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Sorry - old message that randomly popped up in my email!
>
> Sent from my iPhone
>
> > On Aug 23, 2017, at 10:53 AM, jonathandly...@gmail.com wrote:
> >
> > The "do" command converts text into a command. Like this:
> >
> > Put "answer 5" into tcommand
> > Do tcommand
> >
> > This is useful in some situations, but usually it is more efficient to
> just say:
> >
> > Answer 5
> >
> > Sent from my iPhone
> >
> >> On Jul 10, 2017, at 11:23 AM, J. Landman Gay via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >>
> >> I wrote this explanation a long time ago for someone else:
> >> http://www.hyperactivesw.com/resources_function.html
> >>
> >> Also, in your command handler example, you don't need "do" which adds
> unnecessary overhead. This is enough:
> >>
> >> on mouseUp
> >> GoRed
> >> end mouseUp
> >>
> >> --
> >> Jacqueline Landman Gay | jac...@hyperactivesw.com
> >> HyperActive Software   | http://www.hyperactivesw.com
> >>
> >>
> >>
> >>> On July 10, 2017 1:50:39 AM Richmond Mathewson via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >>>
> >>> I am obviously missing something . . .
> >>>
> >>> . . . so badly so that I've been trawling Danny Goodman's "Complete" HC
> >>> 2 . . .
> >>>
> >>> and NOT getting 'it' . . .
> >>>
> >>> SO: one can set up a custom command:
> >>>
> >>> on GoRed
> >>>  set the backGroundColor of card 1 to red
> >>> end GoRed
> >>>
> >>> and one can call it:
> >>>
> >>> on mouseUp
> >>>   do GoRed
> >>> end mouseUp
> >>>
> >>> and one can set up a custom function:
> >>>
> >>> function GoRed
> >>>  set the backGroundColor of card 1 to red
> >>> end function
> >>>
> >>> Now: is the reason I cannot call that function because it takes NO
> >>> parameters?
> >>>
> >>> Richmond.
> >>> ___
> >>> 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
>
___
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: Goofy question #7234

2017-08-23 Thread Jonathan Lynch via use-livecode
Sorry - old message that randomly popped up in my email!

Sent from my iPhone

> On Aug 23, 2017, at 10:53 AM, jonathandly...@gmail.com wrote:
> 
> The "do" command converts text into a command. Like this:
> 
> Put "answer 5" into tcommand
> Do tcommand
> 
> This is useful in some situations, but usually it is more efficient to just 
> say:
> 
> Answer 5
> 
> Sent from my iPhone
> 
>> On Jul 10, 2017, at 11:23 AM, J. Landman Gay via use-livecode 
>>  wrote:
>> 
>> I wrote this explanation a long time ago for someone else:
>> http://www.hyperactivesw.com/resources_function.html
>> 
>> Also, in your command handler example, you don't need "do" which adds 
>> unnecessary overhead. This is enough:
>> 
>> on mouseUp
>> GoRed
>> end mouseUp
>> 
>> --
>> Jacqueline Landman Gay | jac...@hyperactivesw.com
>> HyperActive Software   | http://www.hyperactivesw.com
>> 
>> 
>> 
>>> On July 10, 2017 1:50:39 AM Richmond Mathewson via use-livecode 
>>>  wrote:
>>> 
>>> I am obviously missing something . . .
>>> 
>>> . . . so badly so that I've been trawling Danny Goodman's "Complete" HC
>>> 2 . . .
>>> 
>>> and NOT getting 'it' . . .
>>> 
>>> SO: one can set up a custom command:
>>> 
>>> on GoRed
>>>  set the backGroundColor of card 1 to red
>>> end GoRed
>>> 
>>> and one can call it:
>>> 
>>> on mouseUp
>>>   do GoRed
>>> end mouseUp
>>> 
>>> and one can set up a custom function:
>>> 
>>> function GoRed
>>>  set the backGroundColor of card 1 to red
>>> end function
>>> 
>>> Now: is the reason I cannot call that function because it takes NO
>>> parameters?
>>> 
>>> Richmond.
>>> ___
>>> 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: Goofy question #7234

2017-08-23 Thread Jonathan Lynch via use-livecode
The "do" command converts text into a command. Like this:

Put "answer 5" into tcommand
Do tcommand

This is useful in some situations, but usually it is more efficient to just say:

Answer 5

Sent from my iPhone

> On Jul 10, 2017, at 11:23 AM, J. Landman Gay via use-livecode 
>  wrote:
> 
> I wrote this explanation a long time ago for someone else:
> http://www.hyperactivesw.com/resources_function.html
> 
> Also, in your command handler example, you don't need "do" which adds 
> unnecessary overhead. This is enough:
> 
> on mouseUp
> GoRed
> end mouseUp
> 
> --
> Jacqueline Landman Gay | jac...@hyperactivesw.com
> HyperActive Software   | http://www.hyperactivesw.com
> 
> 
> 
>> On July 10, 2017 1:50:39 AM Richmond Mathewson via use-livecode 
>>  wrote:
>> 
>> I am obviously missing something . . .
>> 
>> . . . so badly so that I've been trawling Danny Goodman's "Complete" HC
>> 2 . . .
>> 
>> and NOT getting 'it' . . .
>> 
>> SO: one can set up a custom command:
>> 
>> on GoRed
>>   set the backGroundColor of card 1 to red
>> end GoRed
>> 
>> and one can call it:
>> 
>> on mouseUp
>>do GoRed
>> end mouseUp
>> 
>> and one can set up a custom function:
>> 
>> function GoRed
>>   set the backGroundColor of card 1 to red
>> end function
>> 
>> Now: is the reason I cannot call that function because it takes NO
>> parameters?
>> 
>> Richmond.
>> ___
>> 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: Goofy question #7234

2017-07-10 Thread J. Landman Gay via use-livecode

I wrote this explanation a long time ago for someone else:
http://www.hyperactivesw.com/resources_function.html

Also, in your command handler example, you don't need "do" which adds 
unnecessary overhead. This is enough:


on mouseUp
 GoRed
end mouseUp

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



On July 10, 2017 1:50:39 AM Richmond Mathewson via use-livecode 
 wrote:



I am obviously missing something . . .

. . . so badly so that I've been trawling Danny Goodman's "Complete" HC
2 . . .

and NOT getting 'it' . . .

SO: one can set up a custom command:

on GoRed
   set the backGroundColor of card 1 to red
end GoRed

and one can call it:

on mouseUp
do GoRed
end mouseUp

and one can set up a custom function:

function GoRed
   set the backGroundColor of card 1 to red
end function

Now: is the reason I cannot call that function because it takes NO
parameters?

Richmond.
___
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: Goofy question #7234

2017-07-10 Thread Bob Sneidar via use-livecode
That is cool. As soon as 9 release candidates are released I will have to look 
hard at v9. Unfortunately I do not develop for a living (exactly) so I do not 
have a lot of time for running a DP through it's paces. 

Bob S


> On Jul 10, 2017, at 06:01 , Mike Kerner via use-livecode 
>  wrote:
> 
> In the newfangled LC world, you can even do things the way the engine can -
> using "return for value" (or just "return") and "return for error" to allow
> commands to return values, too.  Then "it" gets values that are returned,
> and "the result" gets errors that are returned.  9 is fun.
> funfunfunfunfunfunfun


___
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: Goofy question #7234

2017-07-10 Thread Mike Kerner via use-livecode
In the newfangled LC world, you can even do things the way the engine can -
using "return for value" (or just "return") and "return for error" to allow
commands to return values, too.  Then "it" gets values that are returned,
and "the result" gets errors that are returned.  9 is fun.
 funfunfunfunfunfunfun

On Mon, Jul 10, 2017 at 4:29 AM, Tore Nilsen via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Here is what I teach my students:
>
> Use the function to return a value to the calling handler, set the
> properties in the handler, not in the function itself, like this:
>
> on mouseUp
>  set backgroundColor of this card to goRed()
> end mouseUp
>
> function goRed
>   return “red”
> end goRed
>
> The benefit of this is that you can call the function from various
> handlers and sending whatever parameter you like. Here is a script that
> returns different colours
> depending on which card you open when you call the function. Everything is
> placed in the stack script:
>
> on preOpenCard
>  put short name of this card into tCard
>  set backgroundColor of card tCard to setColour(tCard)
> end preOpenCard
>
> function setColour pCard
>  if pCard = “One” then
>return “red”
>  else
>return “blue”
>  end if
> end setColour
>
>
> Regards
> Tore Nilsen
>
> > 10. jul. 2017 kl. 10:09 skrev Tim Selander via use-livecode <
> use-livecode@lists.runrev.com>:
> >
> > Hi Richmond
> >
> > This works (both scripts in the button):
> > on mouseUp
> > put goRed()
> > end mouseUp
> >
> > function goRed
> > set the backGroundColor of card 1 to red
> > end goRed
> >
> > I think the general idea is that a function returns information. So
> date() returns the date. But just having a line "date()" in the script
> causes an error because you haven't told it what to do with the info being
> returned. So you need "put data()" and then the info will go to the message
> box.
> >
> > Your function doesn't return any data. That's your choice when you write
> it. But the engine is still expecting a function to return info, so you
> still have to say "put" trigger the function.
> >
> > You could write your function with a parameter:
> > function goRed foo
> > set the backGroundColor of foo to red
> > end goRed
> >
> > Then call the function like this:
> > put goRed("card 1")
> > put goRed("card 3")
> > etc., and the one function can be used to turn both card 1 and card 3
> (and any other object you specify in foo) red.
> >
> > Hope that helps.
> >
> > Tim Selander
> > Tokyo, Japan
> >
> >
> >
> >
> >
> > On 7/10/17, 15:48, Richmond Mathewson via use-livecode wrote:
> >> I am obviously missing something . . .
> >>
> >> . . . so badly so that I've been trawling Danny Goodman's "Complete" HC
> 2 . . .
> >>
> >> and NOT getting 'it' . . .
> >>
> >> SO: one can set up a custom command:
> >>
> >> on GoRed
> >>  set the backGroundColor of card 1 to red
> >> end GoRed
> >>
> >> and one can call it:
> >>
> >> on mouseUp
> >>   do GoRed
> >> end mouseUp
> >>
> >> and one can set up a custom function:
> >>
> >> function GoRed
> >>  set the backGroundColor of card 1 to red
> >> end function
> >>
> >> Now: is the reason I cannot call that function because it takes NO
> parameters?
> >>
> >> Richmond.
> >> ___
> >> 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
>



-- 
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: Goofy question #7234

2017-07-10 Thread Tore Nilsen via use-livecode
Here is what I teach my students:

Use the function to return a value to the calling handler, set the properties 
in the handler, not in the function itself, like this:

on mouseUp
 set backgroundColor of this card to goRed()
end mouseUp

function goRed
  return “red”
end goRed

The benefit of this is that you can call the function from various handlers and 
sending whatever parameter you like. Here is a script that returns different 
colours
depending on which card you open when you call the function. Everything is 
placed in the stack script:

on preOpenCard
 put short name of this card into tCard
 set backgroundColor of card tCard to setColour(tCard)
end preOpenCard

function setColour pCard
 if pCard = “One” then
   return “red”
 else
   return “blue”
 end if
end setColour


Regards
Tore Nilsen

> 10. jul. 2017 kl. 10:09 skrev Tim Selander via use-livecode 
> :
> 
> Hi Richmond
> 
> This works (both scripts in the button):
> on mouseUp
> put goRed()
> end mouseUp
> 
> function goRed
> set the backGroundColor of card 1 to red
> end goRed
> 
> I think the general idea is that a function returns information. So date() 
> returns the date. But just having a line "date()" in the script causes an 
> error because you haven't told it what to do with the info being returned. So 
> you need "put data()" and then the info will go to the message box.
> 
> Your function doesn't return any data. That's your choice when you write it. 
> But the engine is still expecting a function to return info, so you still 
> have to say "put" trigger the function.
> 
> You could write your function with a parameter:
> function goRed foo
> set the backGroundColor of foo to red
> end goRed
> 
> Then call the function like this:
> put goRed("card 1")
> put goRed("card 3")
> etc., and the one function can be used to turn both card 1 and card 3 (and 
> any other object you specify in foo) red.
> 
> Hope that helps.
> 
> Tim Selander
> Tokyo, Japan
> 
> 
> 
> 
> 
> On 7/10/17, 15:48, Richmond Mathewson via use-livecode wrote:
>> I am obviously missing something . . .
>> 
>> . . . so badly so that I've been trawling Danny Goodman's "Complete" HC 2 . 
>> . .
>> 
>> and NOT getting 'it' . . .
>> 
>> SO: one can set up a custom command:
>> 
>> on GoRed
>>  set the backGroundColor of card 1 to red
>> end GoRed
>> 
>> and one can call it:
>> 
>> on mouseUp
>>   do GoRed
>> end mouseUp
>> 
>> and one can set up a custom function:
>> 
>> function GoRed
>>  set the backGroundColor of card 1 to red
>> end function
>> 
>> Now: is the reason I cannot call that function because it takes NO 
>> parameters?
>> 
>> Richmond.
>> ___
>> 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: Goofy question #7234

2017-07-10 Thread Richmond Mathewson via use-livecode
It does help a lot: even if only to stop me looking totally 'Stpid' 
in front

of the kids in my Summer classes.

Thanks.

Richmond.

On 7/10/17 11:09 am, Tim Selander via use-livecode wrote:

Hi Richmond

This works (both scripts in the button):
on mouseUp
put goRed()
end mouseUp

function goRed
set the backGroundColor of card 1 to red
end goRed

I think the general idea is that a function returns information. So 
date() returns the date. But just having a line "date()" in the script 
causes an error because you haven't told it what to do with the info 
being returned. So you need "put data()" and then the info will go to 
the message box.


Your function doesn't return any data. That's your choice when you 
write it. But the engine is still expecting a function to return info, 
so you still have to say "put" trigger the function.


You could write your function with a parameter:
function goRed foo
set the backGroundColor of foo to red
end goRed

Then call the function like this:
put goRed("card 1")
put goRed("card 3")
etc., and the one function can be used to turn both card 1 and card 3 
(and any other object you specify in foo) red.


Hope that helps.

Tim Selander
Tokyo, Japan





On 7/10/17, 15:48, Richmond Mathewson via use-livecode wrote:

I am obviously missing something . . .

. . . so badly so that I've been trawling Danny Goodman's "Complete" 
HC 2 . . .


and NOT getting 'it' . . .

SO: one can set up a custom command:

on GoRed
  set the backGroundColor of card 1 to red
end GoRed

and one can call it:

on mouseUp
   do GoRed
end mouseUp

and one can set up a custom function:

function GoRed
  set the backGroundColor of card 1 to red
end function

Now: is the reason I cannot call that function because it takes NO 
parameters?


Richmond.
___
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: Goofy question #7234

2017-07-10 Thread Tim Selander via use-livecode

Hi Richmond

This works (both scripts in the button):
on mouseUp
put goRed()
end mouseUp

function goRed
set the backGroundColor of card 1 to red
end goRed

I think the general idea is that a function returns information. So 
date() returns the date. But just having a line "date()" in the script 
causes an error because you haven't told it what to do with the info 
being returned. So you need "put data()" and then the info will go to 
the message box.


Your function doesn't return any data. That's your choice when you write 
it. But the engine is still expecting a function to return info, so you 
still have to say "put" trigger the function.


You could write your function with a parameter:
function goRed foo
set the backGroundColor of foo to red
end goRed

Then call the function like this:
put goRed("card 1")
put goRed("card 3")
etc., and the one function can be used to turn both card 1 and card 3 
(and any other object you specify in foo) red.


Hope that helps.

Tim Selander
Tokyo, Japan





On 7/10/17, 15:48, Richmond Mathewson via use-livecode wrote:

I am obviously missing something . . .

. . . so badly so that I've been trawling Danny Goodman's "Complete" 
HC 2 . . .


and NOT getting 'it' . . .

SO: one can set up a custom command:

on GoRed
  set the backGroundColor of card 1 to red
end GoRed

and one can call it:

on mouseUp
   do GoRed
end mouseUp

and one can set up a custom function:

function GoRed
  set the backGroundColor of card 1 to red
end function

Now: is the reason I cannot call that function because it takes NO 
parameters?


Richmond.
___
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