Page 1 of 1
Pretty basic division question
Posted: Tue Apr 22, 2014 11:10 pm
by DavJans
I got 2 fields, workers(field u) and quantity(field q), Field a is the answer
workers will be input like this 24,58,34
and quantity is just a number 2 for example
here is my code for dividing quantity based on workers
Code: Select all
on mouseUp
put fld "u" into tempu
replace "," with cr in tempu
put number of lines of tempu into tempu2
put fld "q" into tempq
put tempq / tempu2 into tempq2
put tempu2 & tempq2 into fld "a"
end mouseUp
my question is, is there a better way to do this, it seems kind of ugly

Re: Pretty basic division question
Posted: Wed Apr 23, 2014 1:25 am
by dunbarx
Hi.
Well, in one sense I have no idea what you are up to. But your script seems sound, as far as it goes.
So without knowing, as I say, why not just:
put fld "q" / number of items of fld "u" into fld "a"
Now I am not trying to be cute or coy. What I am really getting at is, how are you managing your data?
Craig Newman
Re: Pretty basic division question
Posted: Wed Apr 23, 2014 4:07 pm
by DavJans
I can elaborate a little more, as for what I'm up to, this specific question has to do with welder's, sometimes we have very big welds that take up to 4 or 5 hours to complete, so one worker starts at night and one finishes in the morning, so in this case 2 welders worked on one weld, we keep track of this because these welds (CJP's) need to pass NDT testing and if they fail we keep track of that as well and we keep track of who in return has to re-weld it. As far as managing my data, it is all stored in a mysql database. My main goal i guess is to get a variable, using this example, that would have one worker number per line and one variable with .5 in it. then use a repeat for each line and send it to my mysql server.
I all ready have it working for one worker at a time, but my Quality control guys want me to dd this as an option. its easy enough to do, I just thought maybe I was making it more complicated than it had to be.
Re: Pretty basic division question
Posted: Wed Apr 23, 2014 6:15 pm
by dunbarx
Fair enough. I really asked because I thought it odd that you had a string of integers separated by commas, that you turned into a return delimited list. I really does not matter how you arrange your data, only that you can manage it easily. So your method is verbose, but that is not intrinsically bad. Whatever works.
When you have a moment, consider creating an array with welders and their hours linked. This would be a fooling-around exercise.
Craig