Page 3 of 3
Re: Sorting numbers by mathematicals properties
Posted: Tue May 07, 2013 5:07 pm
by Klaus
Hi Mat,
### fld "proP[newL]???
How are the fields named?
proP1, proP2 etc?
In that case you need to concatenate the correct field names with parens like this:
Code: Select all
...
repeat with newL = 1 to the number of lines in tNewlist
put line newL of tNewlist & cr after transList
put transList into fld ("proP" & newL)
end repeat
...
Hope I got it right
Best
Klaus
Re: Sorting numbers by mathematicals properties
Posted: Wed May 08, 2013 10:20 am
by matgarage
Hi Klaus,
Yes ! You got it...
I need now to set correctly the rest of the script to fit what I want.
I wille certainly be back soon... with a new problem.

Re: Sorting numbers by mathematicals properties
Posted: Wed May 08, 2013 1:42 pm
by matgarage
I got a problem
In this part :
Code: Select all
repeat with indexL =1 to 7 ## I would like to set it to the number of lines in tArray
repeat for each key tKey2 in tArray
put tKey2 into fld ("qp"&indexL) ## Even with the loop indexL I allready get the same value (???)
put tArray[tKey2] & CR after tNewList
--put empty into tKey2
end repeat
end repeat
I did something wrong but I can't find where...
Re: Sorting numbers by mathematicals properties
Posted: Wed May 08, 2013 3:02 pm
by Klaus
Sorry, no capisce!
What are you trying to do?
Re: Sorting numbers by mathematicals properties
Posted: Wed May 08, 2013 3:17 pm
by matgarage
You're right it's not clear.
So.
With the whole script I take datas from the data grid and I put the name of each equal value in a different field by value.
I'm trying now to put the value in a title field for each set of values.
The problem is that my script already return the same value for each title field.
Code: Select all
on mouseUp
set itemdel to TAB
put the dgText of group "listProd" into tList
put empty into tArray
repeat for each line i in tList
put item 1 of i into tContent
put item 2 of i into tKey
put tContent & tab after tArray[tKey]
end repeat
repeat with indexL =1 to the number of lines of the keys of tArray
repeat for each key tKey2 in tArray
put tKey2 into fld ("qp"&indexL)
put tArray[tKey2] & CR after tNewList
--put empty into tKey2
end repeat
end repeat
repeat with newL = 1 to 7
put empty into transList
put line newL of tNewlist & cr after transList
put transList into fld ("proP" & newL)
end repeat
end mouseUp
What's wrong ?
Re: Sorting numbers by mathematicals properties
Posted: Wed May 08, 2013 3:32 pm
by Klaus
Sorry, still dont get it?!
Which of the repeat loops does not do what you want? What goes into what field?
Please give a little example with REAL numbers

Re: Sorting numbers by mathematicals properties
Posted: Wed May 08, 2013 4:10 pm
by matgarage
Here are the data grid
Produit 1 2000
Produit 2 2500
Produit 3 2500
Produit 4 3500
Produit 5 3500
Produit 6 4000
Produit 7 4000
Produit 8 5000
Produit 9 7000
Produit 10 8000
Produit 11 8000
I want to put the quantity name ("4000" for example) in a text field at the top of the field that contain Produit 10 and Porduit 11.
The script place the product nam of each equal values in the same field (1 by value), but I want this value to be displayed in a other field on top of the products container.
My script already give me "2500" as value.
I don't know why ?
PS : In french we say literally "Speaking french like a spanish cow". I think I speak english like an italian one .

Re: Sorting numbers by mathematicals properties
Posted: Wed May 15, 2013 7:10 pm
by matgarage
Sorry Klaus,
Few days of raining holidays make me understand where I was wrong.
I did this
Code: Select all
on mouseUp
set itemdel to TAB
put the dgText of group "listProd" into tList
put empty into tArray
repeat for each line i in tList
put item 1 of i into tContent
put item 2 of i into tKey
put tContent & tab after tArray[tKey]
end repeat
put tList into field "Fieldtext"
repeat for each key tKey2 in tArray
put tKey2 & CR after tNewList
end repeat
repeat with newL=1 to the number of lines of the keys of tArray
put empty into transList
put line newL of tNewlist into transList
put transList into fld ("qp" & newL)
end repeat
repeat with newP=1 to the number of lines of the keys of tArray
put fld ("qp" & newp) into valMulti
put empty into transprod
repeat for each key tkey3 in tArray
put tKey3 into valDyn
if valDyn mod valMulti =0 then put (tarray[tkey3] && X &&(valDyn / valMulti)) & cr & "--" & cr after transProd
put transProd into fld ("proP" & newP)
end repeat
end repeat
end mouseUp
I take datas from my datagrid "listProd", sort them by quantity, then by multiple and I add the factor.
It's a little start... but I'm very proud.
Now I'm going to enhance this backbone to optimise the code, first by function, then by adding other rules of sorting.
Thank you for your help and thank to jmburnot and jaque too.