Deleting certain fields behaves strangely

Pascal Lehner tate83 at gmail.com
Mon Sep 2 08:10:01 EDT 2013


Wow, that was quick :-)
Thanks Alex, it's working fine now

Best,
Pascal

On 2 September 2013 17:34, Alex Tweedly <alex at tweedly.net> wrote:

> I think the problem is that you are referring to the fields by *number* -
> so when you delete the first one - it's gone. So now the (old) "field 2"
> has become "field 1"
>
> Try doing your loop as
>    repeat with tField = the number of fields *on* card targetCard down to 1
>
> -- Alex.
>
>
> On 02/09/2013 12:59, Pascal Lehner wrote:
>
>> Hi all
>>
>> I have a script that creates fields named "Point1", "Point2" ...
>> describing
>> certain data points on a graph. This works fine. However, when the number
>> of Points on the new graphic is smaller than on the old, I have old
>> "PointX" that remain from the previous graphc. Thus I want to implement a
>> delete routine to get rid of all fields and recreate them.
>>
>> In the current example I have 6 data points called
>> Point1 to Point6
>>
>> <code>
>> *repeat* with tField = 1 to the number of fields *on* card targetCard
>> *  put* the short name of field tField into tFieldName
>> *    if* tFieldName contains "Point" *then
>> **      put* "Deleting field no." && tField && "named" && tFieldName
>>        *delete* field tFieldName
>>      *end* *if*
>> *end* *repeat
>> *</code>
>>
>> However, the following shows a very strange behavior I cannot understand
>> just now.
>> When I run it, it deletes Point1, Point3, Point5 but does not care about
>> the even numbers and breaks with an error message "Chunk: no such object".
>> When I run it again just afterwards, Point4 is the only survivor, same
>> error message.
>> When I run it a third time, Point4 is removed and the new graph is drawn
>> correctly.
>>
>> Can you spot the issue? It is LiveCode Community 6.1.1. RC4
>>
>> Thanks,
>>
>> Pascal
>> ______________________________**_________________
>> 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<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<http://lists.runrev.com/mailman/listinfo/use-livecode>
>



More information about the use-livecode mailing list