strange error in a repeat loop
Andre.Bisseret
Andre.Bisseret at inria.fr
Mon Feb 23 10:33:56 EST 2009
YEsss !
Thanks a lot Thierry and Robert ; both of you where right : I had a
couple of spaces in item 9 of line 1 of my field !!
Kind of things I should have suspected ; but I was really "brain
stuck" (not sure this is a good expression ;-)))
Now, my handler is working nicely
Robert thanks also for the revision of the first part of the handler
and your suggestion of a simpler coding.
I am continuously learning thanks to the conviviality of this list :-).
Tanks again to both of you
Best regard from Grenoble
André
Le 23 févr. 09 à 15:51, Robert Brenstein a écrit :
> Is it possible that item 9 in one of the lines of fld
> "chRécapDuMois" is not a valid number? An invisible char sneaked in?
>
> This loop seems curious
>
> REPEAT FOR each item meti in tLesVars
> put empty into meti
> END repeat
>
> I think you mean
>
>
> REPEAT FOR each item meti in tLesVars
> do "put empty into" && meti
> END repeat
>
> You might want to rewrite this keeping your subtotals as elements of
> an array. This will make your code simpler. For example, the above
> repeat will be replace with
>
> put empty into tLesVars
>
> and the summation can be replaced with a repeat
>
> repeat with i=5 to 12
> add item i of enil to tLesVars["total"&i]
> end repeat
>
> Robert
>
>
> On 23.02.09 at 15:27 +0100 Andre.Bisseret apparently wrote:
>> Bonjour,
>> I am completely stuck with a silly error I keep getting in a simple
>> handler.
>> Here it is :
>> --------------------------------------
>> ON totaliser
>> local
>> total5
>> ,total6
>> ,total7
>> ,total8,total9,totalPort,totalGéné,totalAnnul,cmdeDuMois,tLesVars
>> ---------------------
>> -- EMPTY IN VARIABLES
>> put
>> "total5,total6,total7,total8,total9,totalPort,totalGéné,totalAnnul"
>> into tLesVars
>> REPEAT FOR each item meti in tLesVars
>> put empty into meti
>> END repeat
>> put fld "chRécapDuMois" into cmdeDuMois -- field "chRécapDuMois"
>> is a list with items separated by tab
>>
>> -- SUM OF COLUMNS
>> set the itemdel to tab
>> REPEAT FOR each line enil in cmdeDuMois
>> add item 5 of enil to total5
>> add item 6 of enil to total6
>> add item 7 of enil to total7
>> add item 8 of enil to total8
>> add item 9 of enil to total9 -- THE ERROR IS POINTED OUT HERE
>> add item 10 of enil to totalPort
>> add item 11 of enil to totalGéné
>> add item 12 of enil to totalAnnul
>> END repeat
>> put total5 & tab & total6 & tab & total7 & tab & total8 & tab &
>> total9\
>> & tab & totalPort & tab & totalGéné & tab & totalAnnul
>> into fld "chTotaux"
>> end totaliser
>> ------------------------------------------
>> For an hour now (at least) I got an error :
>> Error 10: add: error in source expression
>> Hint : repeat: error in statement
>> Error at char 1 of line 246 in handler totaliser
>> Code: 1
>> --------------------
>> this error is pointed out at line "add item 9 of enil to total9"
>> If I suppress (comment) this only line the handler works well
>> (except I don't get the total for column 9 !! ;-((
>>
>> I wrote a lot of times such an handler ; first time I am stuck like
>> this ! I don't understand at all and have no idea.
>>
>> Hoping some of you will see something (could be evident) I am
>> missing ?
>>
>> Thanks a lot in advance for any idea
>>
>> Best regards from Grenoble
>> André
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-revolution
>
>
More information about the use-livecode
mailing list