Want to get rid of Google Ads, click here.
+ Reply to Thread
Results 1 to 5 of 5

Thread: Calculated field in a list

  1. #1
    Member
    Join Date
    Nov 2001
    Location
    Boston, MA - United States
    Posts
    79

    Default

    Hi All,



    I have added some of my own fields to the cm3t dbdict in the labor array for tracking telecom costs related to a work order. One of fields I've added is labor cost and another called rate.



    I would like to calculate the total cost by multiplying the rate times the number of hours worked. Does anyone have any idea how to do this? Keep in mind that we're working with an array displayed as a table on the task.



    On DVD dep.g demo form they have a function that calculates meters based on the # of feet you enter, it seems to me that I need something similar to that.



    thanks in advance,

    Aaron

  2. #2
    Senior Member eisefr's Avatar
    Join Date
    Nov 2001
    Location
    Germany
    Posts
    538

    Default

    when you work with arrays you need to know how 'long' your array is.



    That you can find out with the lng-command.

    (expample: $lng=lng(fieldname in $file)



    I tryed around with the following fields:

    aa

    bb

    cc



    all those fields are numeric arrays.



    I build a expression like this:



    $lng=lng(aa in $file);for $xyz = 1 to $lng do ($xyz in cc in $file=$xyz in aa in $file*$xyz in bb in $file)



    I am not quiet sure if I understood your question right.. but maybe I was able to help you with this.



    Bye from Germany

    Frank

  3. #3
    Senior Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    930

    Default

    Set the expression on "delete" - so you're sure that it's run when the work is done. You could set it in cm3t (formatctrl) so it will execute for all tasks.



    As the condition you could use:

    lng(denull(hours.worked in $file))>0 and lng(denull(rate in $file))



    If you don't have a default rate, change the expression given by "eisefr" to:



    for $xi=1 to lng(denull(hours.worked in $file)) do (if ($xi in rate in $file>0) then ($xi in labor.cost in $file=$xi in hours.worked in $file*$xi in rate in $file))



    If there is a default rate, expand the expression with an "else":

    for $xi=1 to lng(denull(hours.worked in $file)) do (if ($xi in rate in $file>0) then ($xi in labor.cost in $file=$xi in hours.worked in $file*$xi in rate in $file) else ($xi in labor.cost in $file=$xi in hours.worked in $file*$default.rate.for.operator))



    Assuming that hours.worked is a non-date (number) field (using digits is applicable), rate is the rate for the particular operator (number) and labor.cost (number) is the product of hours.worked and rate.



    Regards,

    Jos

  4. #4
    Senior Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    930

    Default

    Small correction on the condition:



    ...

    As the condition you could use:

    lng(denull(hours.worked in $file))>0 and lng(denull(rate in $file))>0



    Unless there is a default rate, than just use:

    As the condition you could use:

    lng(denull(hours.worked in $file))>0

    ...



    Regards,

    Jos

  5. #5
    Senior Member
    Join Date
    Jan 2002
    Location
    The Netherlands
    Posts
    930

    Default

    Additionally, you might want to use "subtotals" to generate a "Total" of all tasks on the change.



    From change FC (i.e. cm3r) call subtotal, with the following names (and default or variable values)



    NAMES - VALUES

    name - Work Total [flexible]

    prompt - X [flexible]

    boolean1 - false [fixed value]



    The name and prompt should be set according to the way you'll set up the subtotals record. Where "name" is equal to "name" and prompt is equal to "area".



    In your calculations, use $filew as a reference to the taks currently selected.



    Regards,

    Jos

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

     

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts