Results 1 to 3 of 3
  1. #1
    Join Date
    May 2002

    Angry Unanswered: Help with FoxPro - Calculation of fields in same table

    Hi there! Ok, i have a question.
    I've been doing an application for a taxi company i work for and they requested a pgm in FoxPro...that's sucks cauz i have no fox experience.

    ok let's go right into the subject, i need to know how i can substract a the same field in two different records in the same table.

    table fields---------------------------->fuel
    ticket # - carID - Date of filling - AMt filled - mileage
    100 - 3 - 05/08/02 - 30 liters - 123100 km
    101 - 3 - 05/17/02 - 40 liters - 123600 km

    ok i need to substract the mileage of the last ticket with the previous one
    eg: 123600 -123100 = 500 km

    and so on for all added tickets... I've been brain washing my head on this....can't do it.
    i need to know so that i can calculate how many km the car went on 1 gallon of fuel
    eg : (20*500)/ 30 = 333.33km
    so for 1 gall the car went 333.34 km

    Can anybody give suggestions?

    Thanks i would really appreciate.

  2. #2
    Join Date
    May 2002

    need to know if i should include variable fields in this db

    I forgot to mention, that i'm a newbie in database programming.
    As I explain before,
    I need to know if i should include in the above table more fields to contain variables.
    eg should i make a field to store the result of the mileage calculation and another for the gallon/mile field.

    my problem is that i'm confused about doing a substraction on the last added mileage record with the previous one.

    once i have this issue resolved all the rest should be simple.

    ticket # - idcar- filldate-amtfilled-mileage-totmile-totgal

    so milageB - mileageA = C
    Then i can do E = [C*20] / D

    Ok suggestions on how i can do that in fox? Anyone plz?
    Last edited by LeMagnifique; 05-18-02 at 06:12.

  3. #3
    Join Date
    Nov 2001
    In FoxPro you can use xBase commands like:

    go Bottom - select last record of the table
    Skip 1 - go next record
    Skip -1 go prev record
    go Top - go first record

    So if the table's name is Cars, then

    Private nMileageA, nMileageB

    Select 0
    Use Cars
    go bottom

    nMileageA = cars->AMtfilled
    Skip -1
    nMileageB = cars->AMtfilled

    ? nMileageA - nMileageB

    FoxPro also supports SQL.

    HTH, Igor

Posting Permissions

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