Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Script Calculation error

Script Calculation error

Script Calculation error

To be clear, the error is mine, I know that much, I just cannot put my finger on it.

The story:

We have a semi-automated fuelpump, which gives us some basic data about usage.
From that, I get a list of vehicles, their owner, milage and how much fuel they took and when.
I made some forms for the end-users to display a list summarized by NR (vehicleNR) or owner etc.
One form, the 'Per vehicleNR', the list is in a Portal, where the fuelstops are sorted descending.

I use a script to modify table data as I cannot retain data, because of the way the fuelpump works, it’s all or nothing, so on each check,every so many days or weeks, I purge the database and read the lot in again by script. That import works fine, no issues there.
So far, so good…

I now need to calculate the average (AV consumption of each vehicule between 2 fuelstops.
Easy as pie in Excel, but I am stuck in Filemaker with this.
Below is the script.

The first record gets a ’0” in AV, that is fine.
The problem is, after that, I get ’?’ until the next NR is reached and then they all become ’X’.
I know about the ’X’, but I wonder where my mistake is that I get a ’?’ as result.
All fields are numbers except NR, which is Text (the licenseplate).

Go to Layout [ “ListTBPV” (TBPV) ]
View As [ View as Table ]
Sort Records [ Specified Sort Order: TBPV::NR; ascending ] [ Restore; No dialog ]
Go to Record/Request/Page [ First ]
Set Field [ TBPV::AV; If ( Get(RecordNumber) = 1;0; If ( TBPV::NR = GetNthRecord ( TBPV::NR; +1); TBPV::Quantity/((TBPV::KM-(GetNthRecord ( TBPV::KM; -1)))/100);"X")) ]
Go to Record/Request/Page [ Next; Exit after last ]
End Loop

The idea is: take the current records mileage, deduct the previous (except the first) which gives me the the number of KM driven since the last fuelstop. I alread y have the Quantity, so I divide Quantity by the result and by 100, to get the x L/100KM

Does anyone know where my blunder is?

If 'something' 'somewhere' gives 'some' error, expect random guesses or no replies at all.
Free Tip: The F1 Key does NOT destroy your PC!

RE: Script Calculation error

Duh, I found my own mistake, a Copy & Paste mistake:
GetNthRecord ( TBPV::NR; +1)
Has to be
GetNthRecord ( TBPV::NR; Get(RecordNumber)+ 1)

If 'something' 'somewhere' gives 'some' error, expect random guesses or no replies at all.
Free Tip: The F1 Key does NOT destroy your PC!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close