TweetFollow Us on Twitter

HyperCard OOP
Volume Number:6
Issue Number:8
Column Tag:HyperChat™

Object Oriented Programming

By Tom Trinko, Ph.D., Colleen Trinko, Fremont, CA

Note: Source code files accompanying article are located on MacTech CD-ROM or source code disks.

Object Oriented Programming in HyperCard™

While HyperCard provides a rich set of tools for developing applications and for rapidly prototyping complex systems, it is not a true object oriented computing environment. We’re not going to go into a detailed discussion of object oriented programming, but a little overview, with an example of creating pop-up menus, should illuminate the basic concepts for those who haven’t had a chance to become familiar with this relatively new approach to developing, and thinking about, software.

The first key concept in object oriented programming is that the elements of the program interact by sending each other messages. These messages cause the recipient to take certain actions. The same message can cause different actions to occur depending upon the identity of the message recipient. For example, if one says “Hi” to a dog it might bark, while if you say “Hi” to a friend they are unlikely to bark, unless of course the friend is a programmer in which case anything is possible. The important point is that how the recipient responds is dependent upon the nature of the recipient; the sender does not need to be aware of the internal details of the target of its message. In HyperTalk each “on something....end something” message handler defines how an object--button, field, card, background, stack, home--will respond to a message. So if you were to call one field a man and one a dog you could define two different handlers called “on hi....end hi” to describe their behaviors. The behavior of an object is also affected by its instance variables. Instance variables are just the values which describe the object’s characteristics. For example an instance variable for a dog might be its hair color. All dogs have a “slot” for this value but each specific dog has a different value. Another instance variable would be the dog’s proclivity to barking. The instance variable would reflect how likely a dog is to bark and would be used by the “on hi...end hi” handler as illustrated in this script:

--1

on hi
      global barkingprobability
      if the random of 100 < barkingprobability then
          put “woof” into message
          play “woof”
      end if
end hi

This object oriented approach lets you develop your program as a set of self-contained elements whose activities and interfaces with the other objects in your system are well defined. It’s an approach which lends itself to rapidly developing complex systems as well as supporting the development of reusable software. Once you’ve defined an object that performs a certain function you can use it in any program which needs that ability.

The second key concept is the concept of a class structure. This simply means you have a hierarchy of objects with subclasses of any class inheriting the characteristics of their parent class. A simple example would be if you were to model a zoo. Your root class might be called “Animal” and your subclasses might be “Mammals” and “Reptiles”. Any behavior (message handler) shared by both subclasses could belong to the root class and be inherited by the subclasses. For example since both mammals and reptiles weigh something the weigh behavior, which just prints out the weight of an animal in the message box, could be in the root class. Similarly the instance variable, weight, would be in the root class as well. When you make an instance of the Mammal class it would inherit a slot for an instance variable called weight and the behavior weigh. This saves you the trouble of writing the routine twice. When you realize that the class structure can be very deep it becomes clear that inheritance can save you a lot of programming.

The simplest way to understand this is to think of an example which already exists in HyperCard. If you send a message to a field, HyperCard first looks for a message handler for that message in the field script. If HyperCard finds a handler it executes it and that ends the sequence--unless you’ve included a “pass” command to pass the message on. If the correct handler is not in the field script HyperCard looks in the card script. This means that the field “inherits” the message handlers in its card. If HyperCard fails to find the correct handler in the card it will check the background, then the stack, and finally home. We see then that we can think of a card field as a subclass of the card, the card as a subclass of the background, the background as a subclass of the stack and the stack as a subclass of home. The analogy is only partially correct however because the field does not inherit the instance variables--HyperCard properties--of its parent classes. The net result is that instead of writing many versions of a routine which protects you from deleting buttons by mistake, you can write just one and place it in your home stack.

Now all of this sounds really nice, but unfortunately HyperCard does not support true object oriented programming. It lacks a flexible class structure and true instance variables among other things. The most obvious failing is that you cannot make new types of objects, such as a field with an icon or a button with multiple lines of text.

It is possible however to surmount these difficulties and use object oriented programming techniques in HyperCard. This is not very surprising since many of the programming concepts embedded in HyperCard and HyperTalk are based on conventional object oriented approaches to program control. Messages handlers are an obvious example, as is the inheritance hierarchy for message handlers. The rest of this article will describe simple HyperTalk techniques which will let you get some of the benefits of object oriented programming.

The first step is to decide what we should use as our basic object. Interestingly enough we can rule out every HyperCard object--buttons, cards, stacks, and backgrounds--except for fields by simply noting that fields are the only HyperCard construct that have the ability to store instance variables. Suppose we want to have several dogs in our stack. Each has a different hair color. Only fields give us a place to store the “color of hair” instance variable. The trick is to use the lines in the field to store the instance variables. Put the type of object the field represents in line 1, say dog, the first instance variable for that type of object in line 2, say the hair color, etc. There is no similar mechanism for buttons, cards, or backgrounds.

-Note: There is a clugy way to get the same effect for buttons. Define a global variable, haircolor. Assign the hair color of dog 1 to item 1 of haircolor. This approach still requires that you be able to associate a given button with a given dog. You can do this in two ways: put the dog number in the button name “dog 1”, or define another global variable, dogindex, where the number of the dog represented by card button x is item x of dogindex. While this approach will work, it is a real pain and not recommended since you can make your fields behave just like buttons by setting their locktext to true. If your objects just have to have icons though you might try this approach.

To implement an object structure in HyperCard means establishing a class system--including inheritance--and developing a way to construct fields which act as instances of a given class. Doing this in general requires a bit of effort and maybe we’ll document it in a future article but for now let’s just walk through an example of an object structuring without explicit inheritance or classes.

The example we’ve used is an implementation of pop-up menus. All of the scripts listed here require HyperCard 1.2.2 or later to work properly. It also shows which instance variables are contained in which lines in the field. If you make a field with these scripts and enter the default values for the instance variables, you can make a new instance by merely copying the field while holding down the option key (HyperCard 1.2.2 and beyond only) and then edit the instance variables.

The pop-up menu object is useful because it can be used in many programs. Listing 1 shows the scripts for the object assuming you use the PopUp Menu XFCN by Andrew Gilmartin. (Later we’ll cover the information needed if you don’t have this XFCN.) Notice since the field invokes a handler with the name of the menu item you can place the code to execute the menu option anywhere in the inheritance path--field(recommended), card, background, stack, home. This field was developed in a stack which supports a full class structure and was made into a stand alone item usable in any stack by adding the class Export in as one of its parent classes. When you see a reference to OVERRIDE it means that a given handler in a subclass is replacing one in one of its parent classes. To ease your typing burden we’ve excised all of the duplicate handlers but left in the override messages for your information.

There are three different ways to interact with the field, each supported by a different mouse/key combination. If you merely hold the mouse button down on the field you’ll get a pop-up menu with all of the available options shown. Selecting one causes the option to be executed. If you hold down the option key and the mouse button you’ll get a list of the instance variables and selecting one of them will let you change its value. The only instance variables in the pop-up menu class is “menuitems” and it just contains the list of choices that will appear in the menu. Finally if you hold down the shift key you’ll get a list of all of the handlers in the field. By selecting one of the handlers you’ll cause that handler to be executed. This will not work if the handler expects parameters.

For those of you who don’t have access to the PopUp Menu XFCN we’ve included a set of handlers/functions which allow you to get a similar effect using only HyperTalk™. It is slower--much slower!-- but it does have the advantage of being modeless. After you generate a menu, using the same techniques as above with the exception that you don’t have to hold the mouse button down until you make your selection, you can move the menu or do anything else you want. When you want to use the menu just click on the selection you want. One minor point is that the menu field deletes itself. If you have a handler in your hierarchy which intercepts “deletefield” messages you might want to modify it to ignore the message when the target’s name is “popmenu” to avoid having to confirm deleting the field every time you use the pop-up menu.

Once you set up this script you’ll be able to define pop-up menus and their activities by just editing the menu list--easily accessible by holding the option key and the mouse button down on the field--and then inserting handlers with the same name as the menu options anywhere in the hierarchy--field, card, background, stack, home.

Just as we were finishing this article, SuperCard™ by Silicon Beach Software came out; therefore we imported these scripts into SuperCard to check for compatibility. The XFCN version worked as is with no changes. The HyperCard-only version required a few changes which are generally instructive.

First whenever you import a stack to SuperCard check all of the doMenu commands. The menu options are different in SuperCard. For example there is no “new field” menu command. Now you could add a menu yourself that had that command but that would mean that your pop-up menu would no longer really be self-contained. This is a good example of the utility of programming using self-contained objects. The XFCN version makes no assumptions about the environment it’s residing in, other than the fact that you brought over the XFCN! while the HyperCard-only version assumes that the menu options are present. Not surprisingly the HyperCard-only version had problems with SuperCard while the self-contained version did not.

Listing 2 contains the three handlers that had to be changed in order to make the HyperCard-only version work in SuperCard. The most troubling thing was the send command because if you use

--2

 send “itempicked itemchosen,cmdflag” to destination

the values of the parameters at the destination will be the strings “itemchosen” and “cmdflag” not the values of the variables. After much experimenting, we finally discovered that making a concatenated string with the variables gets the job done. Interestingly from what we’ve read the command

--3

 send itempicked itemchosen,cmdflag to destination

should work but from our experience it doesn’t. The quotes make it work in HyperCard but not in SuperCard. It could be we’re missing something.

As an aside SuperCard seems to be very nice. The one major problem we’ve seen after only a cursory inspection is that there is no simple command key mouse button combination to get to the scripts of objects. There is a tool included that searches through all of the objects in a project to see which one is under the mouse when the button is depressed. The script then opens the objects script for editing. It doesn’t seem as convenient as the new mouse shortcuts in HyperCard. We’ve developed a little window that lets you access the script of any object with just one mouseclick and if anyone is interested, we can write an article about that for a future issue.

Please send any comments, bug reports, etc. to us at

GEnie T.Trinko

AppleLink Trinko

AppleLink Personal Edition Trinko or Trinko2

Mousehole Tom Trinko

Listing 1

To build a pop-up menu field:

1) create a card field

2) put the name you want the user to see in line 1

3) put these scripts into the fields scripts

4) type “menuitems” into line 3

5) resize the field so only the first line is showing

6) set the locktext of the field to true

Note: If you use a script where the user level has been set so that the menu option for “new field” is not available you should insert the set user level commands at the places marked in the scripts. This is necessary only for the HyperCard™ only version.

------------------------------------------------------------
--FUNCTIONS & HANDLERS FROM THE “POP UP MENU CLASS
on mousedown
  --OVERRIDE:POPUP MENU: This is the mousedown handler for the pop-up
  --menu class.  Holding the mouse down on the field gives the user defined
  --pop-up menu.  Holding the mouse and option key down gives a menu 
to
  --change the values of the instance variables. Holding the mouse and
  --shift key down gives a menu of the messages (methods) that the
  --instance can handle.
  put 0 into cmdflag
  --Let the user know something is going on
  set the cursor to watch
  --This gives the user a menu of the instance variables and lets the 
user change   
  --them
  if the optionkey is down then
    put 1 into cmdflag
    put instancelistmenu() into list
    --This gives the user a menu of the instance methods (message handlers)
    --and lets the user execute them
  else if the shiftkey is down then
    put 2 into cmdflag
    put methodlistmenu() into list
    --This gives the pop-up menu of options the user has specified
  else
    put getinstanceval(menuitems,line 2 of me) into list
  end if
  put the clickloc into loc
  --Change the cursor for the user’s selection of a menu option
  set the cursor to arrow
  put popmenu(list,loc) into itemchosen
  --Let the user know something is happening
  set the cursor to watch
  --The last item in the list is the cancel option
  if itemchosen > 0 and itemchosen is not the number of items in list 
¬
  then
    if cmdflag = 0 then
      handlemenu itemchosen,list
    else if cmdflag= 1 then
      executeinstancelistmenu itemchosen,list
    else if cmdflag=2 then
      executemethodmenu itemchosen,list
    end if
  end if
end mousedown

on handlemenu itemchosen, list
  --this handler is what you customize to take action based on which
  -- menu option the user chooses.  It is not called if the user selects
  -- the cancel option.
  --  if you’ve set up the menu items as handlers in the class methods
  -- then this script will work
  send (item itemchosen of list) to me
end handlemenu

on test
  --This is just a test to show that the menu works.  For every menu
  --item you should have a handler somewhere in the inheritance chain
  --(field, card, background, stack, home) to handle the message
  put “see it works” into message
end test
------------------------------------------------------------------------------------------------
--FUNCTIONS AND HANDLERS FROM THE “EXPORT” CLASS

function getinstancelist classname
  --OVERRIDE:CLASS EXPORT:THIS OVERRIDES THE STANDARD   
  --GETINSTANCELIST IN THE OBJECT CLASS IN ORDER TO ALLOW CLASS 
  --INSTANCES TO BE EXPORTED.IN AN EXPORTED FIELD THE INSTANCE 
  --VARIABLE NAMES ARE IN THE LAST LINE OF THE FIELD
  -- this returns the instance list for a given classname  The item number 
in the    
  -- instance list is 2 less than the
  -- line number of the instance variable in the field
  put empty into instancelist
  if classname is not line 2 of me then
    return “error”
  else
    return line (the number of lines in me) of me
  end if
end getinstancelist
------------------------------------------------------------------------------------------------
--FUNCTIONS & HANDLERS FROM THE ROOT CLASS OBJECTS

on executeinstancelistmenu hit,list
  --input number of item selected from instance list,instance list
  --This lets the user change the value of instance variables
  put word 3 to (the number of words in item hit of list) of list into¬
  temp
  ask “Enter value for “ & temp with line hit +2 of me
  if it is not empty then
    put it into line hit+2 of me
  end if
end executeinstancelistmenu

on executemethodmenu hit,list
  --input number of item selected from method list,method list
  --this just sends the selected message to the instances
  send (item hit of list) to me
end executemethodmenu

function instancelistmenu
  --output the instance list
  put getinstancelist (line 2 of me) into temp
  put the number of items in temp into numinstancevars
  put empty into list
  repeat with x=1 to numinstancevars
    put “Set the “ & item 1 of item x of temp into item x of list
  end repeat
  put “,Cancel” after list
  return list
end instancelistmenu

function methodlistmenu
  --output the method list
  put getinstancehandlernames(the short name of me) into temp
  repeat with i=2 to the number of lines in temp
    put line i of temp into item i-1 of list
  end repeat
  put “,Cancel” after list
  return list
end methodlistmenu

function popmenu list,loc
  -- input: list of options,location of menu
  -- output: number of menu item picked 0 if none or cancel
  -- this takes a list of options,and a menu location and displays
  -- a menu.  It also checks to see if the user picks the cancel option
  if the number of items in list < 1 then
    put “Cancel” into list
  end if
  put ((the number of items in list) + 10) into nlist
  put redolist (list) into list
  put item 1 of  loc+50 into h
  put item 2 of  loc+50 into v
  --This is Andrew Gilmartin’s XFCN
  get PopUpMenu(list,nlist, v, h)
  --This is message to let the user know that he has to hold the mouse
  --down on the field until the menu appears
  if it is 0 then
    put “You must hold the mouse button down on this button to see the 
menu”
  end if
  return it
end popmenu

function redolist list
  --input list in format “a,b,c,d”
  --output list in format “a;b;c;d”
  -- this just reformats the list for popupmenu to use “;” as the
  -- item separator not “,”
  put empty into newlist
  repeat with x=1 to the number of items in list
    put item x of list & “;” after newlist
  end repeat
  return newlist
end redolist

on deleteme
  -- this allows an object to be deleted
  if the userlevel is not 5 then
    put the userlevel into temp1
    set the userlevel to 5
  else
    put empty into temp1
  end if
  select me
  domenu “cut field”
  if temp1 is not empty then
    set the userlevel to 5
  end if
  choose browse tool
end deleteme

on removecomments
--NOTE:  This is a generally useful script not specifically required 
for the pop-up --menu functionality. This removes all comments from a 
script.
  set the cursor to watch
  put the script of me into temp
  repeat with i=1 to the number of lines in temp
    if line i of temp is not empty then
      put “ “ into ctemp
      put 0 into j
      repeat until ctemp is not “ “
        add 1 to j
        put char j of line i of temp into ctemp
      end repeat
      if ctemp is “-” then
        put empty into line i of temp
      end if
    end if
  end repeat
  put removeemptylines (temp) into temp
  set the script of me to temp
end removecomments

function getinstanceval instancevarname,classname
  --input:  instance variable name,name of class
  --output:  value for the instance variable of target
  -- this function gets the value of any instance variable for an
  -- object. This is better than using line numbers because you
  -- don’t have to change any scripts if you change the number or order
  -- of instance variables in a class
  put getinstancelist (classname,0) into temp
  put findinstancenum (instancevarname,temp) into tempnum
  put the short name of the target into fieldname
  put line (tempnum+2) of card field fieldname into value
  return value
end getinstanceval

on setinstanceval instancevarname,classname,value
  --input:  instance variable name,name of class,value
  --output:  set instance variable of target to value
  -- this function sets the value of any instance variable for an
  -- object. This is better than using line numbers because you
  -- don’t have to change any scripts if you change the number or order
  -- of instance variables in a class
  put getinstancelist(classname,0) into temp
  put findinstancenum(instancevarname,temp) into tempnum
  put the short name of the target into fieldname
  put value into line (tempnum+2) of card field fieldname
end setinstanceval

function findinstancenum instancevarname,list
  --input: instance variable name,list of instance variables in class
  --output: sequence number of instance variable in list
  --error:  returns  -1 if name not found
  -- given an instance variable name it and a list of instance names
  -- this returns the item number of the instance name
  put -1 into hit
  repeat with x=1 to the number of items in list
    if item x of list is instancevarname then
      return x
      put 0 into hit
      exit repeat
    end if
  end repeat
  if hit < 0 then
    put “Error:findinstacenum: Instance Name not found”
  end if
  return -1
end findinstancenum

function class objectname
  -- this returns the class of an object
  put objectname
  wait 2 seconds
  return line 2 of card field (objectname)
end class

function classnumber classname
  -- this returns the item number of the argument in the class list
  global classnames
  put -1 into classnum
  repeat with i=1 to the number of items in classnames
    if classname is item i of classnames then
      put i into classnum
      exit repeat
    end if
  end repeat
  return classnum
end classnumber

function getinstancehandlernames iname
  --input  instance name
  --output list of all of the message handlers in script
  put the script of card field iname into temp
  put scanhandlers(temp) into methodlist
  return methodlist
end getinstancehandlernames

function scanhandlers temp
  --input script
  --output list with the names of the message handlers (1/line)
  put 0 into nummethods
  put empty into methodlist
  repeat with i=1 to  number of lines in temp
    if word 1 of line i of temp is “on” then
      add 1 to nummethods
      put word 2 of line i of temp into line nummethods of methodlist
    end if
  end repeat
  return methodlist
end scanhandlers

These are the handlers and functions necessary to eliminate the need 
for the XFCN.  Just replace the handlers with the same name in the above 
listing by these and add those that don’t appear in the above listing 
and the field will work as a pop-up menu.
on mouseup
  --this is here to override the subsequent mouseup handler which will
  -- be placed in the field containing the popup menu.  If this weren’t 
here
  -- then everytime you click the mouse on the original field the mouseup 

  --  handler for the menu field would be activated.
end mouseup

on mouseup
  --this script is placed in the menu field to handle the users selection
  --  name of chosen item is returned (avoid handler in
  --  the original field (itempicked) from having to know what the
  --  possible choices were.  The cmdflag(which notes whether you’re
  --  working with menu choices,instance variable setting,or firing
  --  handlers) is also returned.
  --  Name of original field is contained in second to
  --  last line in the menu,while the cmdflag value is contained in the
  --  last line.  Both of which are kept invisible by 
  --  the selected sizing for the menu field
  put the clickloc into loc
  put linechoosenfixed (loc) into itemchosen
  put line itemchosen of me into itemchosen
  put  last line of me into cmdflag
  put number of lines in me -1 into temp
  put line temp of me into dest
  send “itempicked itemchosen,cmdflag” to dest
  -- now that we’re done with it let’s delete the menu field
  --  NOTE:   If you want the menu to hang around just eliminate the 
next
  -- three lines and included a menu option to eliminate the menu.
  --if the userlevel is not 5 then <==========  To insure menu options 
available
  --  put the userlevel into temp1 <==========  To insure menu options 
available
  --  set the userlevel to 5       <==========  To insure menu options 
available
  -- else                                                  <========== 
 To insure menu options available
  --   put empty into temp1        <==========  To insure menu options 
available
  -- end if                        <==========  To insure menu options 
available
   select me
  domenu “cut field”
  -- if temp1 is not empty          <==========  To insure menu options 
available
  --   set the userlevel to temp1   <==========  To insure menu options 
available
  -- end if <==========  To insure menu options available
  choose browse tool
  --set the userlevel to temp1       <==========  To insure menu options 
available
end mouseup

function linechoosenfixed loc
  --input  x,y location of the mouse click(use the clickloc)
  -- This is a generally useful function which takes the clickloc as
  -- input and finds out line in a field was clicked on
  put second item of loc into pos
  put pos - the top of the target into pos
  get the textheight of the target
  put it into size
  put trunc(pos/size)+1 into linehit
  return linehit
end linechoosenfixed

on mousedown
  --OVERRIDE:POPUP MENU: This is the mousedown handler for the popup
  --menu HC only class.  Holding the mouse down on gives the user defined
  --pop-up menu.  Holding the mouse and option key down gives a menu 
to
  --change the values of the instance variables. Holding the mouse and
  --shift key down gives menu of messages (methods) that 
  --instance can handle.
  put 0 into cmdflag
  set the cursor to watch
  -- handle user setting value of the instance variables
  if the optionkey is down then
    put 1 into cmdflag
    put instancelistmenu() into list
    -- handlethe user firing the handlers
  else if the shiftkey is down then
    put 2 into cmdflag
    put methodlistmenu() into list
    -- handle the user using the pop-up menu
  else
    put getinstanceval(menuitems,line 2 of me) into list
  end if
  put the clickloc into loc
  -- build and display the pop-up menu
  popHCmenu list,loc,cmdflag
end mousedown

on itempicked itemchosen,cmdflag
  --input  name of the menu item selected,command flag
  -- since the HC version is modeless the handler has to be broken into
  -- two pieces,one to make the menu field and one to handle the message
  -- that the user has picked an item.
  set the cursor to watch
  if itemchosen is not “empty” and itemchosen is not “cancel” then
    -- This actually implements menu action.  Note that
    -- we’re using the handlemenu and executemenu handlers a little
    -- differently than they were designed for.  They were designed to
    -- make a selection from a list but by sending them a 1 item list
    -- we avoid having to make the list a global variable,or regenerate
    -- it which could be very slow,and we also avoid writing 3 new
    -- handlers for this class
    if cmdflag = 0 then
      handlemenu 1,itemchosen
    else if cmdflag= 1 then
      executeinstancelistmenu 1,itemchosen
    else if cmdflag=2 then
      executemethodmenu 1,itemchosen
    end if
  end if
end itempicked

on popHCmenu list,loc,cmdflag
  --input list of menu options,location of menu,command flag
  -- This handler sets up the menu
  --first convert the list into a variable with each item in 1 line
  put listtoline(list) into list
  put the number of lines in list into temp
  --compute the height and width of the field
  -- Note if you change the font size in the makefield handler you
  --  need to change the width and height computations
  put (temp*9)+3 into height
  put the target into line temp+1 of list
  put cmdflag into line temp+2 of list
  put 0 into maxchar
  repeat with i=1 to temp
    if the number of chars in line i of list > maxchar then
      put the number of chars in line i of list into maxchar
    end if
  end repeat
  put maxchar*6 into width
  -- This actually makes the field
  makefield “Popmenu”,width,height,loc
  -- Fill the field with the menu options
  put list into card field “Popmenu”
  -- Here find the the beginning and end of the script for the menu field
  --  The menu field has one handler,mouseup,and one function,linechoosen
  --  handleraddress returns line at which a handler or 
  --  function starts and the line at which it ends
  put the script of me into temp
  put handleraddress (temp,”mouseup”,3,0) into templine
  put handleraddress (temp,”linechoosenfixed”,item 2 of templine,1) into 
temp1
  put item 1 of templine into tempstart
  put item 2 of temp1 into lastone
  put tempstart - 1 into templine1
  repeat with x=tempstart to lastone
    put line x of temp into line (x-templine1) of temp1
  end repeat
  set the script of card field “Popmenu” to temp1
end popHCmenu

on makefield fieldname,xsize,ysize,dest
  -- Input field name,width,height,location
  -- General handler which will make a field with the
  -- default characteristics 
  --if the userlevel is not 5 then              <==========  To insure 
menu options available
  --  put the userlevel into temp1            <==========  To insure 
menu options available
  --  set the userlevel to 5                       <==========  To insure 
menu options available
  -- else <==========  To insure menu options available
  --   put empty into temp1                     <==========  To insure 
menu options available
  -- end if                                               <========== 
 To insure menu options available
  domenu “new field”
  --if temp1 is not empty then <==========  To insure menu options available
  --  set the userlevel to temp1 <==========  To insure menu options 
available
  --end if <==========  To insure menu options available
  set the width of card field “” to xsize
  set the height of card field “” to ysize
  set loc of card field “” to dest
  set the textfont of card field “” to “new york”
  set the textsize of card field “” to 9
  set the textstyle of card field “” to “condense”
  set the textheight of card field “” to 9
  set the style of card field “” to “shadow”
  set the textalign of card field “” to “center”
  put the  id of card field “” into fid
  set the locktext of card field “” to true
  set name of  card field “” to fieldname
  set the locktext of card field fieldname to true
  choose browse tool
end makefield

function listtoline list
  -- input  a list “c,x,y,35,100,d”
  -- output a variable with item 1 in line 1...item n in line n
  repeat with x=1 to the number of items in list
    put item x of list into line x of temp
  end repeat
  return temp
end listtoline
Listing 2
WARNING:  The comments we’ve made about problems with SuperCard™ should be 
taken with a grain of salt.  we’ve only been using it a few days and the only documentation 
we have is the manuals that come with it which are not a full blown course for SuperTalk™. 
 The scripts shown below do work but there might be other,better,ways to get the same 
effect.

on mouseup
  --script is placed in menu field to handle selection
  --name of chosen item is returned(to avoid handler in
  --  the original field (itempicked) from having to know what the
  --  possible choices were).  The cmdflag(which notes whether you’re
  --  working with menu choices,instance variable setting,or firing
  --  handlers) is also returned.
  --    The name of the original field is contained in the second to
  --  last line in the menu,while the cmdflag value is contained in the
  --  last line.  Both of which are kept invisible by the selected
  --  sizing for the menu field
  put the clickloc into loc
  put linechoosenfixed (loc) into itemchosen
  put line itemchosen of me into itemchosen
  put  last line of me into cmdflag
  put number of lines in me -1 into temp
  put line temp of me into dest
  -- These next two lines had to be changed to be compatible with SuperCard™
  put itemchosen & “,” & cmdflag into tempstring                     
                          <============
  send “itempicked” && tempstring to dest                            
                              <============
  -- now that we’re done with it let’s delete the menu field
  -- In HyperCard™ we used doMenu “cut field” in SuperCard™ you have 
to use
  --  doMenu “cut”
  select me
  domenu “cut”                                                       
                                              <============
  choose browse tool
end mouseup

on popHCmenu list,loc,cmdflag
  --input list of menu options,location of menu,command flag
  -- This handler sets up the menu
  --first convert the list into a variable with each item in 1 line
  --Note we also changed some of the text sizes in the SuperCard™ version
  put listtoline(list) into list
  put the number of lines in list into temp
  --compute the height and width of the field
  put (temp*10)+3 into height
  put the target into line temp+1 of list
  put cmdflag into line temp+2 of list
  put 0 into maxchar
  repeat with i=1 to temp
    if the number of chars in line i of list > maxchar then
      put the number of chars in line i of list into maxchar
    end if
  end repeat
  put maxchar*8 into width
  -- This actually makes the field
  makefield “Popmenu”,width,height,loc
  -- Fill the field with the menu options
  put “Popmenu” into fieldname
  put list into card field fieldname
  --  In SuperCard™ setting these parameters before entering the text 
didn’t seem to   
  --  work so we moved them here.
  set the textfont of card field fieldname to “monaco”
  set the textsize of card field fieldname to 9
  set the textstyle of card field fieldname to “condense”
  set the textheight of card field fieldname to 10
  set the style of card field fieldname to “shadow”
  set the textalign of card field fieldname to “center”
  
  -- Here find the the begining and end of the script for the menu field
  --  The menu field has one handler,mouseup,and one function,linechoosen
  --  handleraddress returns the line at which a handler or function
  --  starts and the line at which it ends
  put the script of me into temp
  put handleraddress (temp,”mouseup”,3,0) into templine
  put handleraddress (temp,”linechoosenfixed”,item 2 of templine,1) into 
temp1
  put item 1 of templine into tempstart
  put item 2 of temp1 into lastone
  put tempstart - 1 into templine1
  repeat with x=tempstart to lastone
    put line x of temp into line (x-templine1) of temp1
  end repeat
  set the script of card field “Popmenu” to temp1
end popHCmenu
on makefield fieldname,xsize,ysize,dest
  -- Input field name,width,height,location
  -- This is a general handler which will make a field with the
  -- default characteristics
  -- In HyperCard™ we used doMenu “new field” but SuperCard™ doesn’t 
have
  -- such a menu command.  In SuperCard™ you can create a new field in 
a script
  -- by using the field rectangle tool
  choose field rectangle tool
  put dest into start
  put item 1 of dest + xsize into item 1 of  finish
  put item 2 of dest + ysize into item 2 of  finish
  drag from start to finish
  -- It seems that you have to go back to the browse  
  -- tool in SuperCard™ before using the field
  choose browse tool
  --  Unlike HyperCard™ SuperCard™ doesn’t seem to be able to address 
fields 
  --   with no nameby using the name “”.  But you know that the field 
you’ve just
  --    made will always have the highest field number 
  set name of  card field (the number of card fields) to fieldname
  set the locktext of card field fieldname to true
  choose browse tool
end makefield

 
AAPL
$98.77
Apple Inc.
-0.26
MSFT
$44.00
Microsoft Corpora
+0.03
GOOG
$589.11
Google Inc.
-1.49

MacTech Search:
Community Search:

Software Updates via MacUpdate

OS X Yosemite Wallpaper 1.0 - Desktop im...
OS X Yosemite Wallpaper is the gorgeous new background image for Apple's upcoming OS X 10.10 Yosemite. This wallpaper is available for all screen resolutions with a source file that measures 5,418... Read more
Acorn 4.4 - Bitmap image editor. (Demo)
Acorn is a new image editor built with one goal in mind - simplicity. Fast, easy, and fluid, Acorn provides the options you'll need without any overhead. Acorn feels right, and won't drain your bank... Read more
Bartender 1.2.20 - Organize your menu ba...
Bartender lets you organize your menu bar apps. Features: Lets you tidy your menu bar apps how you want. See your menu bar apps when you want. Hide the apps you need to run, but do not need to... Read more
TotalFinder 1.6.2 - Adds tabs, hotkeys,...
TotalFinder is a universally acclaimed navigational companion for your Mac. Enhance your Mac's Finder with features so smart and convenient, you won't believe you ever lived without them. Tab-based... Read more
Vienna 3.0.0 RC 2 :be5265e: - RSS and At...
Vienna is a freeware and Open-Source RSS/Atom newsreader with article storage and management via a SQLite database, written in Objective-C and Cocoa, for the OS X operating system. It provides... Read more
VLC Media Player 2.1.5 - Popular multime...
VLC Media Player is a highly portable multimedia player for various audio and video formats (MPEG-1, MPEG-2, MPEG-4, DivX, MP3, OGG, ...) as well as DVDs, VCDs, and various streaming protocols. It... Read more
Default Folder X 4.6.7 - Enhances Open a...
Default Folder X attaches a toolbar to the right side of the Open and Save dialogs in any OS X-native application. The toolbar gives you fast access to various folders and commands. You just click... Read more
TinkerTool 5.3 - Expanded preference set...
TinkerTool is an application that gives you access to additional preference settings Apple has built into Mac OS X. This allows to activate hidden features in the operating system and in some of the... Read more
Audio Hijack Pro 2.11.0 - Record and enh...
Audio Hijack Pro drastically changes the way you use audio on your computer, giving you the freedom to listen to audio when you want and how you want. Record and enhance any audio with Audio Hijack... Read more
Intermission 1.1.1 - Pause and rewind li...
Intermission allows you to pause and rewind live audio from any application on your Mac. Intermission will buffer up to 3 hours of audio, allowing users to skip through any assortment of audio... Read more

Latest Forum Discussions

See All

To The End Review
To The End Review By Lee Hamlet on July 29th, 2014 Our Rating: :: A VICIOUS CYCLEUniversal App - Designed for iPhone and iPad To The End will test players’ patience, timing, and dedication as they try to navigate all 13 levels in... | Read more »
Traps n’ Gemstones Review
Traps n’ Gemstones Review By Campbell Bird on July 28th, 2014 Our Rating: :: CASTLEVANIA JONESUniversal App - Designed for iPhone and iPad Fight mummies, dig tunnels, and ride a runaway minecart to discover ancient secrets in this... | Read more »
The Phantom PI Mission Apparition Review
The Phantom PI Mission Apparition Review By Jordan Minor on July 28th, 2014 Our Rating: :: GHOSTS BUSTEDUniversal App - Designed for iPhone and iPad The Phantom PI is an exceedingly clever and well-crafted adventure game.   | Read more »
More Stubies Are Coming Your Way in a Ne...
More Stubies Are Coming Your Way in a New Update Posted by Jessica Fisher on July 28th, 2014 [ permalink ] Universal App - Designed for iPhone and iPad | Read more »
The Great Prank War Review
The Great Prank War Review By Nadia Oxford on July 28th, 2014 Our Rating: :: PRANKING IS SERIOUS BUSINESSUniversal App - Designed for iPhone and iPad Though short, The Great Prank War offers an interesting and fun mix of action and... | Read more »
Marvel Contest of Champions Announced at...
Marvel Contest of Champions Announced at Comic-Con Posted by Jennifer Allen on July 28th, 2014 [ permalink ] Announced over the weekend at San Diego Comic-Con was the fairly exciting looking Marvel Contest of Champions. | Read more »
Teenage Mutant Ninja Turtles Review
Teenage Mutant Ninja Turtles Review By Jennifer Allen on July 28th, 2014 Our Rating: :: DULL SWIPINGUniversal App - Designed for iPhone and iPad The pizza power is weak when it comes to this Teenage Mutant Ninja Turtles game.   | Read more »
Exploration Focused Puzzle Game Beatbudd...
Exploration Focused Puzzle Game Beatbuddy Set to Make Transition from PC to iOS this September Posted by Jennifer Allen on July 28th, 2014 [ permalink ] | Read more »
PlanetHD
PlanetHD By Nadia Oxford on July 28th, 2014 Our Rating: :: SPACE MADNESSUniversal App - Designed for iPhone and iPad PlanetHD will keep players busy for a while, though its unpredictable physics are a handful to deal with.   | Read more »
This Week at 148Apps: July 21-25, 2014
Another Week of Expert App Reviews   At 148Apps, we help you sort through the great ocean of apps to find the ones we think you’ll like and the ones you’ll need. Our top picks become Editor’s Choice, our stamp of approval for apps with that little... | Read more »

Price Scanner via MacPrices.net

Apple updates MacBook Pros with slightly fast...
Apple updated 13″ and 15″ Retina MacBook Pros today with slightly faster Haswell processors. 13″ models now ship with 8GB of RAM standard, while 15″ MacBook Pros ship with 16GB across the board. Most... Read more
Apple drops price on 13″ 2.5GHz MacBook Pro b...
The Apple Store has dropped their price for the 13″ 2.5GHz MacBook Pro by $100 to $1099 including free shipping. Read more
Apple drops prices on refurbished 2013 MacBoo...
The Apple Store has dropped prices on Apple Certified Refurbished 13″ and 15″ 2013 MacBook Pros, with model now available starting at $929. Apple’s one-year warranty is standard, and shipping is free... Read more
iOS 8 and OS X 10.10 To Support DuckDuckGo As...
Writing for Quartz, Dan Frommer reports that Apple’s forthcoming iOS 8 and OS X 10.10 operating systems version updates will allow users to select DuckDuckGo as their default search engine. He notes... Read more
U.K. Hospital Using iPods and iPads To Record...
British news journal GazetteLive’s. Ian McNeal notes that the old “an apple a day keeps the doctor away” proverb is being turned on its head at http://southtees.nhs.uk/hospitals/james-cook/ James... Read more
13-inch 2.5GHz MacBook Pro on sale for $1099,...
Best Buy has the 13″ 2.5GHz MacBook Pro available for $1099.99 on their online store. Choose free shipping or free instant local store pickup (if available). Their price is $100 off MSRP. Price is... Read more
Roundup of Apple refurbished MacBook Pros, th...
The Apple Store has Apple Certified Refurbished 13″ and 15″ MacBook Pros available for up to $400 off the cost of new models. Apple’s one-year warranty is standard, and shipping is free. Their prices... Read more
Record Mac Shipments In Q2/14 Confound Analys...
A Seeking Alpha Trefis commentary notes that Apple’s fiscal Q3 2014 results released July 22, beat market predictions on earnings, although revenues were slightly lower than anticipated. Apple’s Mac’... Read more
Intel To Launch Core M Silicon For Use In Not...
Digitimes’ Monica Chen and Joseph Tsai, report that Intel will launch 14nm-based Core M series processors specifically for use in fanless notebook/tablet 2-in-1 models in Q4 2014, with many models to... Read more
Apple’s 2014 Back to School promotion: $100 g...
 Apple’s 2014 Back to School promotion includes a free $100 App Store Gift Card with the purchase of any new Mac (Mac mini excluded), or a $50 Gift Card with the purchase of an iPad or iPhone,... Read more

Jobs Board

Sr Software Lead Engineer, *Apple* Online S...
Sr Software Lead Engineer, Apple Online Store Publishing Systems Keywords: Company: Apple Job Code: E3PCAK8MgYYkw Location (City or ZIP): Santa Clara Status: Full Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
Sr. Product Leader, *Apple* Store Apps - Ap...
**Job Summary** Imagine what you could do here. At Apple , great ideas have a way of becoming great products, services, and customer experiences very quickly. Bring Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
*Apple* Solutions Consultant (ASC) - Apple (...
**Job Summary** The ASC is an Apple employee who serves as an Apple brand ambassador and influencer in a Reseller's store. The ASC's role is to grow Apple Read more
All contents are Copyright 1984-2011 by Xplain Corporation. All rights reserved. Theme designed by Icreon.