curiosities in object reference

Peter M. Brigham pmbrig at gmail.com
Mon Apr 20 21:47:11 EDT 2015


On Apr 20, 2015, at 4:08 AM, David Bovill wrote:

> You need to force the type of fRef to be a string.
> 
> LiveCode assumes a string that lukes like a long id is a reference to a
> control. It's duck-typing.
> 
> This is useful in many circumstances.
> 
> To get round it you don't need "do", but you need to assemble the reference
> as a string - and do mess around a bit.
> 
> Try deleting the first word if fRef, then manipulating it, then adding the
> first word back?

Yes, I tried that. No go. It seems to depend entirely on the context of the command. If the engine sees something that can only be done to an object reference, it resolves the reference. If it doesn't, it treats it as an ordinary container with a text string content.

-- Peter

Peter M. Brigham
pmbrig at gmail.com
http://home.comcast.net/~pmbrig


> On Mon, 20 Apr 2015 at 06:58, Kay C Lan <lan.kc.macmail at gmail.com> wrote:
> 
>> Maybe this will help:
>> 
>> put the long id of fld "text" into fRef
>> put word 3 of fRef into fFldID
>> put word 7 of fRef into fCdID
>> put word -1 of fRef into fStackName
>> replace quote with empty in fStackName
>> put "deux" into word 2 of fld id fFldID of card id fCdID of stack
>> fStackName
>> 
>> 
>> 
>> On Mon, Apr 20, 2015 at 4:20 AM, Peter M. Brigham <pmbrig at gmail.com>
>> wrote:
>> 
>>> So I have a field, let's say field "text", with the contents "one two
>>> three four".
>>> 
>>> if I do this:
>>>   put the long id of fld "text" into fRef
>>>   put "deux" into word 2 of fRef
>>> 
>>> it puts "deux" into word 2 of "field id 1022 of stack…" and doesn't
>>> resolve fRef as a field reference.
>>> 
>>> But if I do:
>>>   put the text of fRef into tText
>>> 
>>> it *does* resolve fRef as a field reference, as I would expect. It
>> appears
>>> that the engine only resolves these references when the context/syntax
>>> indicates that it should expect an object reference, and not otherwise.
>>> 
>>> Is there any way I can put "deux" into word 2 of the field without
>> jumping
>>> through hoops, like
>>>   put "deux" into newWord
>>>   do "put newWord into word two of" && fRef
>>> ??
>>> 
>>> I don't want to do:
>>>   put the text of fRef into tText
>>>   put "deux" into word 2 of tText
>>>   set the text of fRef to tText
>>> because the field may contain formatted text that I want to preserve.
>>> 
>>> ideas? or am I stuck with hoops?
>>> 
>>> -- Peter
>>> 
>>> Peter M. Brigham
>>> pmbrig at gmail.com
>>> http://home.comcast.net/~pmbrig
>>> 
>>> 
>>> _______________________________________________
>>> use-livecode mailing list
>>> use-livecode at lists.runrev.com
>>> Please visit this url to subscribe, unsubscribe and manage your
>>> subscription preferences:
>>> http://lists.runrev.com/mailman/listinfo/use-livecode
>>> 
>> _______________________________________________
>> use-livecode mailing list
>> use-livecode at lists.runrev.com
>> Please visit this url to subscribe, unsubscribe and manage your
>> subscription preferences:
>> http://lists.runrev.com/mailman/listinfo/use-livecode
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode





More information about the Use-livecode mailing list