[comp.sys.mac.hypercard] HyperCard Linking

ric@islenet.UUCP (Frederick Lee) (03/10/88)

I received some helpful hints concerning linking during the past couple of 
weeks and am indebted to share what I've learned:

*******************************************************************

From: Keith Rollin <ihnp4!sun!Apple.Com!hyperbug>
Subject: Re:  Prob. with RETURN trapping in text field.

Ric,

	It sounds like you are on the right track with your "move-to-next-
field-on- RETURN-character" scripts; I've never heard anyone get so close 
before.

	There is no System message when a return character is pressed. There 
has been a great demand for it, so maybe in a future version.

	I'm not sure I quite understand your current problem - something 
about getting HyperCard's attention when you switch fields when the return 
key is pressed. You say that you click at the location of the next field. If
this 
isn't working, try the 'tabkey' command. This is just like pressing the TAB 
key from the key- board. Then you can do your current field/next field 
management in an "OpenField" handler.
********************************************************************


	I found that Steve Drazga of ART Incorporated, provided the the best 
solution I received to date (I put the following script in the index-card 
background):
--
--This will capture the return key when it is pressed in the active field.
--Each line of code is explained directly beneath it.
--Created 1/7/88 by Steve Drazga, ART Incorporated.
--
--This script segment may be put into the card, background, or stack scripts.
--To make it work, the fields should pass the global variables
--'currentfield', and 'nextfield'
-------------------------------------------------------------------------------
-

on idle
  --
  global nextfield, currentfield
  
  if currentfield is empty then exit idle
  
  if last char of field currentfield is return then
    delete last char of field currentfield
    
    if nextfield is "***" then
      push this card
      get currentfield
      visual effect scroll left
      get field "Detail Link"
      if it is not empty then go card id it --go to detail card.
      get rect of field "memo"
      delete item 4 of it
      delete item 3 of it
      click at it    -- put cursor at first charactor of field.
      
      pass idle
      exit idle
      
    end if
    
    put rect of field nextfield into it
    delete item 4 of it  -- remove last two coordinates of next field.
    delete item 3 of it
    click at it -- select the next field.
  end if
  pass idle    -- always pass the idle up through the hierarchy
  
end idle

The following a script of one of the index card's fields:

on openField
  global currentfield, nextfield
  put 1 into currentfield
  put 2 into nextfield
end openField


> P.S. I'm not clear on your other question -- about creating two cards a 
linking then 
 each other. What problems are you having?

	I eventually solved my problem about creating & trashing pairs of 
cards.  I got the technical idea correct, but needed to figure out how the 
hierarchy of cards actually play.  Essentially I wanted to create an a primary
index card linked to a particular secondary memo card with a scroll field & 
and a title field. 

	Basically you have to have the background card contain the engine of 
the logic; having each field sending its name back to it via global variables.
I 
found out the hard way that you have to declare the variables global prior to 
each use.  Not merely at a higher-level in the hyperarchy.  Once you got the 
basic engine running, then you can add to the logic by having the second 
card positioned and ready for input after the last field of the first card is 
complete and the user presses the <RETURN>:

on OpenField
  
  global currentfield, theArtist, theTitle
  get currentfield
  
  if it is "ad" then
    put theArtist into field "artist"
    put theTitle into field "title"
    put empty into currentField
    get rect of field "memo"
    delete item 4 of it
    delete item 3 of it
    click at it
  end if
  
end OpenField


	Now All I need to figure out is how to trap the TAB key so I can do 
indenting in a field without popping into another field!  Any Suggestions?

	I wish to express my sincere gratitude to everyone who shared their 
knowledge with me, by sharing my knowledge with my fellow hypercarders.


Cheers & Aloha,

    Ric Lee, Honolulu, O'ahu.