[comp.sys.mac.hypercard] fields script

musa@cs.arizona.edu (Musa J. Jafar) (10/29/90)

Hello there,  
It does not mean that if the question is not Challenging 
then let some one else answer it.

I am reading about fields in HC
Till now I can not find a reason why we need  field scripts.
I would like some one to give me an example if possible?

Another question: when you load from a file into a field
how to make HC load the next word into the next line
while maintaining the values in the previous lines of the 
field?

Still I have not got an answer to make HC understand that the
file to be loaded is not in the HC folder.
I mean that the file is on the drive.

thanks.

ollef@sics.se (Olle Furberg) (10/29/90)

In <485@caslon.cs.arizona.edu> musa@cs.arizona.edu (Musa J. Jafar) writes:

  OK here we go, note that there probably a lot of errors in the scripts
below, but the main ideas are (hopefully) right.

>Till now I can not find a reason why we need  field scripts.
>I would like some one to give me an example if possible?

 A simple, but very common usage of fld scripts: If a user selects/clicks on 
a word in the field, the script could do something to give some information
to the user about that word. In HC 2.0 this hypertext capability is extended
by "Hot Text" and "Group text style". In this way you could put the following
script into the fld: 

on mouseup
 put the clickedtext into TheString
 <do whatever you want with the text in TheString>
end mouseup

 In HC 1.* you could define clickedtext by a HT-script but it's a bit slow. You
could argue for putting this script into the cd script: OK, but then you will
end up with a very, very long and ungraspable cd script.


>how to make HC load the next word into the next line
>while maintaining the values in the previous lines of the 

  put "MyDisk:OneOfMyFolders:YetAnotherFolder:myfile" into filename
  open file filename
  put 1 into i
  repeat for ever
    read from file filename until space
    if it is empty then exit repeat
    put it into line i of fld myfield
    put i+1 into i 
  end repeat

>file to be loaded is not in the HC folder.
>I mean that the file is on the drive.

open file "MyDisk:OneOfMyFolders:YetAnotherFolder:myfile"


>thanks.

Y're welcome

av@woo.oulu.fi.oulu.fi (Ari Vaulo, LuTK/TOL) (10/30/90)

From article <1990Oct29.002315.3491@sics.se>, by ollef@sics.se (Olle Furberg):
> In <485@caslon.cs.arizona.edu> musa@cs.arizona.edu (Musa J. Jafar) writes:
> 
>   OK here we go, note that there probably a lot of errors in the scripts
> below, but the main ideas are (hopefully) right.
> 
>>Till now I can not find a reason why we need  field scripts.
>>I would like some one to give me an example if possible?
> 
>  A simple, but very common usage of fld scripts: If a user selects/clicks on 
> a word in the field, the script could do something to give some information
> to the user about that word. In HC 2.0 this hypertext capability is extended
> by "Hot Text" and "Group text style". In this way you could put the following
> script into the fld: 
> 

Another way to use field scripts is format and error control. For example
if you have a field with money or date information, following little
scripts may be useful.

on closeField
   set numberFormat to "0.00"
   add 0 to me
end closeField

on closeField
   convert me to short date
end closeField

Other useful or necessary message handlers for field scripts are
returnInField, enterInField, tabKey. 

Ari Vaulo ---------------------------------------- eMail: av@tolsun.oulu.fi
University of Oulu --------------------------------------------------------
Department of Information Processing Science ------------------------------
Finland --------------------------------------------- voice: +358-81-352647

dwiggins@atsun.a-t.com (Don Dwiggins) (11/02/90)

Yet another use for a field script:

To help me in looking for a job, I have a stack with several backgrounds,
with several cards per bkgnd.  For example, the "company" cards have fields
for name, address, contacts, interactions I've had with them, etc.  At the
front of the stack is an index card with fields for each of the backgrounds.
On it is a button that extracts the name field from each of the cards and
puts it into the appropriate field, one line per card.  Now for the fun
part: I want to be able to go to the card for a company by clicking on the
company's name in the index field.  The following script does this for me:

on MouseUp
  set lockScreen to true
  put (item 1 of rect of me) & "," & the mouseV into thisLine
  set lockText of me to false   -- the field is normally locked
  click at thisLine
  set lockText of me to true
  put word 2 of the selectedLine into i
  go to card i of bkgnd "Company Info"
  set lockScreen to false
end mouseUp

There may be a better way to do this in 2.0; I haven't seen that version
yet.

I've used variations of this in a couple of stacks.

--
Don Dwiggins				"If you think training is expensive,
Ashton-Tate, Inc.			 try ignorance"
dwiggins@ashtate.a-t.com		 -- Derek Bok, Harvard U.