strange code problem
Phil Jimmieson
P.Jimmieson at csc.liv.ac.uk
Wed Mar 14 10:03:23 EDT 2007
>Can anyone tell me why the code in red will work if I "Step" through
>it but as soon as I let it run normally I will get blank results??
>It seems to "skip" the second repeat but if I put an answer msg in
>it, it reaches the answer msg!????
Hi Nic,
I don't think you're allowed to use split with a "for each"variable -
you're not allowed to modify the contents of a "for each" variable
yourself, and split effectively munges it into an array, which causes
all sorts of weird problems. This has hit me before in my own code.
Try the modified code below:
>
>put "truckRegNo,totalFuel,totalKM,month" into tHeadings
> split tHeadings with comma
> put "1,2,3,4" into tColumns
> split tColumns with comma
> put the number of lines in thisOne into sRecordCount -- "thisOne"
>is a variable which contains comma seperated values like:-
>B456ADF,1000,2500,2
> put 0 into x
> answer thisOne
> repeat for each line thisLine in thisOne
put thisLine into workingline --use a copy of thisLine
split workingline with comma
> --answer x
> add 1 to x
> repeat for each element thisE in tColumns
> put tHeadings[thisE] into tHeader
put workingline[thisE] into tDetail[x,tHeader]
> --answer sColumn[thisLine,tHeader]
> end repeat
> end repeat
--
Phil Jimmieson phil at csc.liv.ac.uk (UK) 0151 795 4236
Computer Science Dept., Liverpool University, Ashton Building, Ashton Street
Liverpool L69 3BX http://www.csc.liv.ac.uk/~phil/
I used to sit on a special medical board... ...but now I use this ointment.
More information about the use-livecode
mailing list