On Sun, Aug 5, 2012 at 6:37 AM, Dr. Hawkins <[email protected]> wrote:
> > In several places, the names of the fields are actually being > constructed by string manipulation (e.g., val_sbt comes from [ fldNam > & "_sbt" ], and then I want to add the $123.45 in val (or possibly > fld fal) to the $852.87 already in fld_sbt.) > > OK let me try and explain this again. Whilst it is possible to add a number to 'the target', as you've discovered if you take 'the target' and then try to build a reference to another field you can't use the same syntax to add a number to it: put the long name of the target into tStartFldName -- field "fld1" of card "cd1" of stack "stk1" put Value(the target) into tAmount -- 50 put tStartFldName into tSummaryFldName put quote & "Sum" & quote into word 2 of tSummaryFldName put quote & "Sum" & quote into word 5 of tSummaryFldName put quote & "Sum" & quote into word 8 of tSummaryFldName -- field "Sum" of card "Sum" of stack "Sum" You can't: put tAmount into tSummaryFldName All that happens is tSummaryFldName now contains 50 rather than putting 50 into the field. Now some have suggested that the problem is that tSummaryFldName already contains the word 'field' so you can't put tAmount into field tSummaryFldName But it doesn't matter if you: put word 2 to -1 of tSummaryFldName into tSummaryFldName -- "Sum" of card "Sum" of stack "Sum" put tAmount into field tSummaryFldName results in an execution error 'no such object' (at least is does for me with Rev 5.5.1 on OS X 10.6.8) BUT, if we go back to the situation where tSummaryFldName contains a full name reference: field "Sum" of card "Sum" of stack "Sum" then you can: set tSummaryFldName to tAmount This is the same syntax you'd use if you wanted to change the 'visible' or 'lockText', or any other property/custom property of a field. So, as I said in a previous post, treat the numbers in each field the same as you would if you were trying to get and set any other property of that field. So as long as you correctly build your full name references, with all the quotes in the right place, it is possible to create a generic math handler that will work regardless of where the numbers are coming from and where you want them to go. HTH _______________________________________________ use-livecode mailing list [email protected] Please visit this url to subscribe, unsubscribe and manage your subscription preferences: http://lists.runrev.com/mailman/listinfo/use-livecode
