Passing arrays, etc.

1999-07-29 Thread Raymond E. Griffith

I have been trying to pass a variable which contains an array with no 
success.

One button has a handler like this

on mouseUp
  put empty into fld "thekeys"
  put fld "thelist" into xx-- a 100-line field, 2 items per line
  repeat with i = 1 to the number of lines of xx
repeat with j = 1 to the number of items of line i of xx
  put item j of line i of xx into tl[i,j]
end repeat
  end repeat
  put keys(tl) into fld "thekeys"
  call "getvar"  tl of fld "getit"
end mouseUp

The keys() function correctly identifies the parts of the array that are
filled.

The call function in the above handler reaches this one (I put the beep in
to be sure).

on getvar x
  beep
  answer keys(x)
end getvar

But x is read as empty. So, why can't I pass associative arrays? I notice I
can't pass fields either.

One of the great strengths of Hypercard is its ability to pass fields and
complex variables. Of course, it doesn't have the ability to do "call"
statements or even create arrays. Ah, for the best of both ...

Raymond



Re: Passing arrays, etc.

1999-07-29 Thread Scott Raney

On Thu, 29 Jul 1999, Raymond E. Griffith wrote:

 I have been trying to pass a variable which contains an array with no 
 success.
 
 One button has a handler like this
 
 on mouseUp
   put empty into fld "thekeys"
   put fld "thelist" into xx-- a 100-line field, 2 items per line
   repeat with i = 1 to the number of lines of xx
 repeat with j = 1 to the number of items of line i of xx
   put item j of line i of xx into tl[i,j]
 end repeat
   end repeat
   put keys(tl) into fld "thekeys"
   call "getvar"  tl of fld "getit"
 end mouseUp
 
 The keys() function correctly identifies the parts of the array that are
 filled.
 
 The call function in the above handler reaches this one (I put the beep in
 to be sure).
 
 on getvar x
   beep
   answer keys(x)
 end getvar
 
 But x is read as empty. So, why can't I pass associative arrays? I notice I
 can't pass fields either.
 
 One of the great strengths of Hypercard is its ability to pass fields and
 complex variables. Of course, it doesn't have the ability to do "call"
 statements or even create arrays. Ah, for the best of both ...

You can only pass arrays in handlers called directly, i.e., not using
"send", "call", or "do", all of which evaluate their arguments and so
destroy their "arrayness".  So, you'll either have to put the "getvar"
function in the script of some object in the normal message-passing
hierarchy, or use "insert script" to insert the script of that field
into the hierarchy.
  Regards,
Scott

 Raymond
 


Scott Raney  [EMAIL PROTECTED]  http://www.metacard.com
MetaCard: You know, there's an easier way to do that...