Home THE HYPERCARD CENTER

HyperTalk Reference
Home » HyperTalk Reference » Keywords

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

global

global variableList


The global keyword makes a variable and its contents available to any handler in HyperCard. Changing the value of a global variable in any handler changes its value everywhere.


Note: You must use the global keyword in each handler to declare the global variables you want to use.


Global variables are not saved between sessions of HyperCard. Global variables are also lost under System 6's single Finder when a user (or handler) suspends HyperCard by launching another application with the open command.


Examples

global myVar

global pages,sections,chapters

Demo Script

on mouseUp
   global theName
   ask "What is your name?"
   if it is empty then exit mouseUp
   put it into theName
   answerReverseName
 end mouseUp
 

 on answerReverseName
   global theName
   repeat with i = the number of chars in theName down to 1
     put char i of theName after reverseName
   end repeat
   answer "Your name spelled backwards is" && reverseName & "."
   -- put empty into the global when you are done with it:
   put empty into theName
 end answerReverseName

Placeholders

variableList
A comma-separated list of global variable names.

The actual names don’t matter as long as they’re not the same as one of HyperCard’s reserved words. (That is, don’t use result as a variable name.)

For example:

var1
var1,var2,var3, var4
fieldName, N, numberOfCharacters


Related Topics

« function | HyperTalk Reference | if (multiple-statement) »


Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Modern View

Home
The HyperCard Center
HyperTalk Reference
Home » HyperTalk Reference » Keywords

Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.

global

global variableList


The global keyword makes a variable and its contents available to any handler in HyperCard. Changing the value of a global variable in any handler changes its value everywhere.


Note: You must use the global keyword in each handler to declare the global variables you want to use.


Global variables are not saved between sessions of HyperCard. Global variables are also lost under System 6's single Finder when a user (or handler) suspends HyperCard by launching another application with the open command.


Examples

global myVar

global pages,sections,chapters

Demo Script

on mouseUp
   global theName
   ask "What is your name?"
   if it is empty then exit mouseUp
   put it into theName
   answerReverseName
 end mouseUp
 

 on answerReverseName
   global theName
   repeat with i = the number of chars in theName down to 1
     put char i of theName after reverseName
   end repeat
   answer "Your name spelled backwards is" && reverseName & "."
   -- put empty into the global when you are done with it:
   put empty into theName
 end answerReverseName

Placeholders

variableList
A comma-separated list of global variable names.

The actual names don’t matter as long as they’re not the same as one of HyperCard’s reserved words. (That is, don’t use result as a variable name.)

For example:

var1
var1,var2,var3, var4
fieldName, N, numberOfCharacters


Related Topics

« function | HyperTalk Reference | if (multiple-statement) »

Version 0.7b1 (March 24, 2022)

Made with Macintosh

Switch to Retro View