HyperCard Mailing List

[HC] HyperCard global variables
(Msg 1 of 8)
andrewferguson500 <andrewferguson500@[redacted].com>
Monday, 15-Sep-2014 18:14 GMT
Hello everyone,
I was playing with HyperCard today, and I discovered something that puzzled me. As a user of LiveCode, I am used to putting "global" at the top of my script, before any handlers. For example:


global myVariable
on mouseDown
put "HyperCard" into myVariable
end mouseDown


on mouseUp
answer myVariable
end mouseUp


In LiveCode, this script would answer "HyperCard". However in HyperCard, it does not.
"The Complete HyperCard 2.0 Handbook" explains that a solution would be to use this:


on mouseDown
global myVariable

put "HyperCard" into myVariable
end mouseDown


on mouseUp
global myVariable

answer myVariable
end mouseUp


This seems unusual to me. Is this correct? Or is there some other way to get my first script to work in HyperCard?


Thanks,
Andrew


[HC] HyperCard global variables
(Msg 2 of 8)
m.schonewille <m.schonewille@[redacted].com>
Monday, 15-Sep-2014 18:14 GMT
Hi Andrew,

In HyperCard, global variables can be defined inside handlers only,
while in LiveCode they can also be defined outside handlers.

In LiveCode, a global variable defined inside handlers is only available
to those handlers, while a global variable defined outside a handler is
available to all handlers in the current script.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Installer Maker for LiveCode:
http://qery.us/468

Buy my new book "Programming LiveCode for the Real Beginner"
http://qery.us/3fi

LiveCode on Facebook:
https://www.facebook.com/groups/runrev/

On 7/13/2014 14:40, andrewferguson500@[redacted].com[HyperCard] wrote:
>
>
> Hello everyone,
>
> I was playing with HyperCard today, and I discovered something that
> puzzled me. As a user of LiveCode, I am used to putting "global" at the
> top of my script, before any handlers. For example:
>
>
> global myVariable
>
> on mouseDown
>
> put "HyperCard" into myVariable
>
> end mouseDown
>
>
> on mouseUp
>
> answer myVariable
>
> end mouseUp
>
>
> In LiveCode, this script would answer "HyperCard". However in HyperCard,
> it does not.
>
> "The Complete HyperCard 2.0 Handbook" explains that a solution would be
> to use this:
>
>
> on mouseDown
>
> global myVariable
>
> put "HyperCard" into myVariable
>
> end mouseDown
>
>
> on mouseUp
>
> global myVariable
>
> answer myVariable
>
> end mouseUp
>
>
> This seems unusual to me. Is this correct? Or is there some other way to
> get my first script to work in HyperCard?
>
>
> Thanks,
>
> Andrew
[HC] HyperCard global variables
(Msg 3 of 8)
coiin <coiin@[redacted].net>
Monday, 15-Sep-2014 18:14 GMT
I had forgot about how it worked that way. In Director and LiveCode you canput your global lines at the top, but with HyperCard you have to mention them in the handlers that will need them.

For what its worth, you can put the globals in one line:

global this,that,other,somethingelse,a,b,c

and so on, so at least its only taking one extra line per handler that n
eeds them.

[HC] HyperCard global variables
(Msg 4 of 8)
DunbarX <DunbarX@[redacted].com>
Monday, 15-Sep-2014 18:14 GMT
Hi.


Similarly, script local variables in LC may be declared ABOVE any handler that needs them in a script. This was a feature entirely missing in HC.


Craig



-----Original Message-----
From: Colin Holgate coiin@[redacted].net[HyperCard] <HyperCard-Mailing-List>
To: HyperCard <HyperCard-Mailing-List>
Sent: Sun, Jul 13, 2014 9:03 am
Subject: Re: [HC] HyperCard global variables


I had forgot about how it worked that way. In Director and LiveCode you can put
your global lines at the top, but with HyperCard you have to mention them in the
handlers that will need them.

For what it’s worth, you can put the globals in one line:

global this,that,other,somethingelse,a,b,c

and so on, so at least it’s only taking one extra line per handler that needs
them.

[HC] HyperCard global variables
(Msg 5 of 8)
andrewferguson500 <andrewferguson500@[redacted].com>
Monday, 15-Sep-2014 18:14 GMT
Hi everyone,
Thank you for the info!
Andrew


On 13 July 2014 14:08, DunbarX@[redacted].com[HyperCard] <
HyperCard-Mailing-List> wrote:

>
>
> Hi.
>
> Similarly, script local variables in LC may be declared ABOVE any
> handler that needs them in a script. This was a feature entirely missing in
> HC.
>
> Craig
>
>
> -----Original Message-----
> From: Colin Holgate coiin@[redacted].net[HyperCard] <
> HyperCard-Mailing-List>
> To: HyperCard <HyperCard-Mailing-List>
> Sent: Sun, Jul 13, 2014 9:03 am
> Subject: Re: [HC] HyperCard global variables
>
> I had forgot about how it worked that way. In Director and LiveCode you can put
> your global lines at the top, but with HyperCard you have to mention them in the
> handlers that will need them.
>
> For what it’s worth, you can put the globals in one line:
>
> global this,that,other,somethingelse,a,b,c
>
> and so on, so at least it’s only taking one extra line per handler that needs
> them.
>
>
[HC] HyperCard global variables
(Msg 6 of 8)
Witness.of.TeachText <Witness.of.TeachText@[redacted].net>
Monday, 15-Sep-2014 18:14 GMT
On 13 Jul 2014, at 15:08, DunbarX@[redacted].com[HyperCard] <HyperCard-Mailing-List> wrote:
> Similarly, script local variables in LC may be declared ABOVE any handlerthat needs them in a script. This was a feature entirely missing in HC.

Also, keep in mind that globals in HyperCard are more like universal variables in LiveCode. Theyre available to all stacks until HyperCard quits.

I think the first one to allow variable declarations outside handlers was CompileIt!. It had script-globals for an XCMD that were separate from
HyperCards globals.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://zathras.de



[HC] HyperCard global variables
(Msg 7 of 8)
ka4hjh <ka4hjh@[redacted].com>
Monday, 15-Sep-2014 18:14 GMT
On Jul 13, 2014, at 11:20 AM, Uli Kusterer Witness.of.TeachText@[redacted].net[HyperCard] <HyperCard-Mailing-List> wrote:

> I think the first one to allow variable declarations outside handlers wasCompileIt!. It had script-globals for an XCMD that were separate fro
m HyperCards globals.


Yes. This was done to avoid having to use a callback to access an actual global variable, which wasted lots of time.

I forget exactly what they were called. I have the manual around here somewhere...


Terry Bowman, KA4HJH
"The Mac Doctor"



[HC] HyperCard global variables
(Msg 8 of 8)
Witness.of.TeachText <Witness.of.TeachText@[redacted].net>
Monday, 15-Sep-2014 18:14 GMT
On 13 Jul 2014, at 22:57, KA4HJH ka4hjh@[redacted].com[HyperCard] <HyperCard-Mailing-List> wrote:
> On Jul 13, 2014, at 11:20 AM, Uli Kusterer Witness.of.TeachText@[redacted].net[HyperCard] <HyperCard-Mailing-List> wrote:
>
>> I think the first one to allow variable declarations outside handlers was CompileIt!. It had script-globals for an XCMD that were separate fr
om HyperCards globals.
>
>
> Yes. This was done to avoid having to use a callback to access an actual global variable, which wasted lots of time.
>
> I forget exactly what they were called. I have the manual around here somewhere

I scanned my copy and put it up on http://hypercard.org :-) Its called a
shared variable in there.

Cheers,
-- Uli Kusterer
The Witnesses of TeachText are everywhere...
http://zathras.de



HyperCard® and HyperTalk™ remain trademarks of Apple, Inc.; other trademarked products and terms mentioned in this archive are the property of their respective trademark holders. Individual messages remain the intellectual property of their respective authors.