How can I pass a handler a long ID as a string?
livfoss at mac.com
Wed Mar 22 17:16:58 EST 2006
Yes, Dave's suggestion works in context - but my problem that the
context of the handler is different from that of the field whose id I
want to pass as a parameter: this has to be true if the handler is to
be at all worthwhile, as it does its work on ids of objects from
various stacks etc. That's where the difficulty lies. Geoff Canyon's
idea of making sure the RR engine can't parse the id reference seems
to be the way to go:
> I've hit this before. I generally postfix a cr like so:
> put (the long id of fld "myField" of cd "myCard" of stack
> "myStack") & cr into tParam
> myHandler tParam
> Then in myHandler:
> on myHandler pID
> delete char -1 of pID -- ready to go now
> or if it could be a list:
> on myHandler pIDList
> repeat for each line tID in pIDList
Although somehow I would expect there to be a way of passing a 'parse-
able' string **as** a string, but apparently not.
Thanks to both of you.
On Wed, 22 Mar 2006 17:09:33 +0000, David Burgun
<dburgun at dsl.pipex.com> wrote:
> Instead of doing:
> myHandler (the long id of fld "myField" of cd "myCard" of stack
> myHandler (the long id of me)
> That should fix it!
> All the Best
> On 22 Mar 2006, at 14:47, Graham Samuel wrote:
>> I've never come across this before, and it's got me confused. I
>> have a handler, say "myHandler" that has a couple of parameters
>> which are intended to be the long ids of objects (actually fields).
>> The handler manipulates the fields, something like
>> on myHandler para1
>> do "put empty into"&¶1
>> end myHandler
>> I find that this works if the parameters are set in the same
>> context as the handler itself - for example in a 'mouseUp' handler
>> on the card where I've put the code of myHandler, but if I call it
>> from elsewhere with a call like
>> myHandler (the long id of fld "myField" of cd "myCard" of stack
>> I find that during the call the engine evaluates the parameter and
>> passes me the contents of the field, and not the reference to the
>> field. What I want is to pass the long id to my handler as a
>> **string**. I can't see why this doesn't work, and more importantly
>> so far I'm stuck for a way round it. I've tried
>> put the long id of fld "myField" of cd "myCard" of stack
>> "myStack" into temp
>> myHandler temp
>> but it has exactly the same effect.
>> What am I doing wrong?
Graham Samuel / The Living Fossil Co. / UK and France
More information about the Use-livecode