SAHPA RACE FORMULA Version 2 Documentation

Free Shareware for Hang Gliding and Paragliding Community from Ulf Arndt

Written in Visual Basic. Download from

Contact for this code is use ulfa instead of

 Based on the RACE Formula Development kit from


SAHPA Formula Info

 Validation (V) = if (V1 > 1) { V=1 } else {V = V1}
where V1 = E/H + J/B - K/B
E = Winners distance
H = Task distance
J = Number of experienced pilots making more than E/3
B = Number of experienced pilots competing
K = Number of experienced pilots who flew < 3km (validation distance)


Score = (S + D) * V
S (speed points) = 600*(G / B)^0.5 * (Winner's elapsed time/ pilot's
elapsed time) ^ 3
G = number of pilots making goal
D (distance points) = (pilot'd distance / winner's
distance)^0.5*1000-(600*(G / B)^0.5)

"600*sqrt(G/B)" is the somewhat arbitrary factor that decides how much is
time points. It uses for time points also only club pilots competing! One
of the reason's time points often count so much! I like it, but does it
make sense? We should probably leave it as it is - get people to fly fast!

Relative distance points = sqrt(distance/winner's distance), giving the
curve (i.e. first part of flight counts most - reason is you're not
penalised as much if it simply doesn't work).

Relative time points = (time/winner's time)^3 - curve in oposite direction
- time count's more the faster you are - for the slow pilots there's little
difference between one slow guy and the next slow guy.

Category and Licence RACE Attributes

Additional one has to define in RACE 2 Attributes,  Category and Licence

Category is usually something like Novice, Intermediate, Serial, Sport and Open.

Idea is to have similar experienced groups of pilots and pilots flying certain wings scored against each other.

To have many winners... Depends on how many trophies you got and what got sponsored.

The Licence info is important for the validity of the SAHPA formula.  Experienced pilots are those that got a certain licence grade, like Sport or Advanced in South Africa. To determine if a task was difficult, look at the number of experienced, sport or advanced rated pilots, how far they got.  And this info one can load with the SAHAP2RACE from the SAHPA database when a pilot registers.



Installation Info

To check if you run the latest Version , use

Competition Properties / Formula / Settings

to see the Software Level  as a Version Number

Or on the last Page of a SAHPA Task Result

Known problem ... when copying a newer .dll file one might have to run the register update.







If you still get a  module could not be found error, make sure you are not referencing the SAHPAFUN Formula somewhere in your ini files.

Without providing the dll for it.


Program Overview

Starting RACE 2000 SP1 and use FILE NEW to create a new Competition.

Select the SAHPA Formula

Choose the SAHPACATALOG200x.mdb file Catalog. 

DO NOT USE the SAHPA.mdb that you might have received from the SAHPA office.

If you use  SAHPA2RACE to fill up the Pilot information in the Catalog then you can tick all options on for Pilot data.
Ok, we do not use Rank, you can do without Rank.

Recommendation is to use SAHPA2RACE to fill in the pilot info ... otherwise you will have fill it in by hand for each pilot.

Rank is not required. Sponsor also is not required.

A must is Birthdate ( for the national ranking) Number, Pilot ID

The SAHPA Catalog got the Attributes called CATEGORY and LICENCE defined

First choose CATEGORY for Attribute1

Choose LICENCE as 2nd Attribute.

Otherwise the program gets mixed up.

You can add TEAM as a 3rd Attribute

The default Attribute assignment, as it comes with RACE SP2 must look like this.
Each attribute and value has got a number assigned within RACE.

RACE SP2 comes with the SAHPA Formula into RACE  Version 1 .

SP2 includes the old version 1 of the code. Where the Category,Licence has to be defined in a fixed order as described.

If you start with an empty Catalog or Competition and make it look the way we got it here in the documentation, do it this way:
 First define Attribute CATEGORY ( attPk=1)
 Then Attribute LICENCE (attPk=2)
 Next add for CATEGORY the Attribute Values

This doc directory contains a file which includes a SAHPACATALOG for RACE that can be used as a basis
for a competition using the SAHPA formula.

This way a catalog, comp should work with Version 1 delivered with RACE SP2.


The  latest SAHPAFORMULA version  2 allows more flexibility in  category and licence assignment

With SAHPAFORMULA Version 2 one can  use other Category Names.
One can now  invent  new names and has to create an  avapk.csv file as a cross reference.

The avapk.csv file is a copy of a table  tblAttribValue in RACE.

Here is an example from the PG 2001 Nationals


RACE uses MS Access.
To setup an avapk cross reference file one can use MS Access to open the RACE competition mdb file.
And look at the tblAttributeValue table

and save it as a csv file

The first value is the RACE avapk value, then the attPk value, and then the characterstring we use

Or one creates the avapk.csv file by hand, while entering the attribute values and keeping track of the sequence as the values got added.

Or use one of those buttons to create an avapk.csv file offered in the 2.3 Version.

To install the latest Version

Make backups of the files that get replaced, then  add / copy into the RACE directory

 RCLangSAHPA.eng    ( this one must say 1 km instead of 3km inside, its a plain text file)


 \Reports\taskresultSAHPA.lst   Task Results template   and other lst files


 In RACE , Properties of a comp
  Pilot Configuration
   Attribute value 1 is CATEGORY
   Attribute value 2  is LICENCE


 the code needs an avapk.csv file in the C:\ directory

  avapk.csv is a csv export of the tblAttributeValue table from the RACE comp database

  copy avapk.csv into C:\avapk.csv


 in case there is an active x , dll error, copy the dll into the system directory and then register it using

  \windows\system\regsvr32 rcformulasahpa.dll

or C:\windows\system32\regsvr32 rcformulasahpa.dll

 or try it via regedit

   ----- Version is set to 1 ---- even when you use 2 -------------------

   the V2 code still says Version 1 is used, there is no choice to choose between 1 or 2, you use Version 2

  -------------- minimum scoring distance is 1 km -------------------------

   not much of a choice in V2.3 , you use 1, even when typing in something else, SAHPA Formula decrees that it has to be 1km
  Even when you type in any other value the code afterwards use 1, at least it is supposed to do so. Unless somewhere else RACE decides different.
  Check in you last page of a Task result to see what the minimum distance is, and what RACE allocates when it says Minimum Distance set.

 ----------------------  if minimum distance is 3 km -----------------------------------------------

To fix this by hand,
open in MS Access the comp database,
select the tblFormulaCompetition, add an entry 1;1;1;
select the  tblCompetition, and choose the comFormulaID 1;1;1;
 the ; at the end is important !

SAHPAFORMULA 2.5.0 - June 2005  for RACE2003

does not count ABS  pilots for the validation factor


SAHPAFORMULA 2.4.0 - April 2004  for RACE2003

to avoid the SAHPA_B = 0 error message
now every pilot gets by default a SPORTS licence rating
Up to the comp organizers to ensure Basic rated pilot are entered correct.
Before by default was BASIC rating for any  pilot.
When defining the comp one had to follow the Attribute sequence
If a RACE admin person does not stick to this then one used to get a SAHPA_B error.
Or if no pilot has been  entered  with a SPORTS rating then there was 0 pilots.
And the formula devides by this value. Resulting in a divide by zero error

Modified the SAHPA Formula code to avoid SAHPA_B=0 error message.

Latest code is located at

Up to now all pilots got by default allocated a BASIC rating in the SAHPA Formula.
The formula counts the amount of SPORTS rated pilots which got a certain distance (SAHPA_B)  and then divides something / SAHPA_B

If the RACE admin person gets the attribute sequence wrong, when defining the comp in RACE then the formula has 0 SPORTS rated pilots.

The change now allocates by default every pilot a SPORTS rating.
As a consequence, if the person who sets up RACE gets it wrong, we will have wrong  validation factors.
Because everyone is a SPORTS rated pilot. If a lot of beginners in a comp bomb out into turkey , which are now SPORTS rated, then it brings down the validation.

To avoid this, when you define the comp one has to stick to the sequence


 when creating your comp in RACE

For  more info ,see

September 2003 update for RACE2003 Sept 06 6.1.1 release
RACE gets shipped with the 401 error for the SAHPA Formula

how to  install the avapk.csv button fix, which causes the RunTime Error 401 when
   creating the avapk.csv file by ...

   locate C:\Program Files\Race  and make a backup copy of the RCFormulaSAHPA.dll file

     locate the C:\comps\software\sahpaformula\code  directory

   copy the RCFormulaSAHPA.dll file into the C:\Program Files\Race  directory

   next run the RegisterSAHPAdll.exe
  !!! DO NOT choose the RCFormulaSAHPA.dll from the SAHPAFormula Directory !!!
    In the RegisterSAHPAdll.exe  change the directory to where RACE is installed,
   so... change to C:\Program Files\Race  and select the RCFormulaSAHPA.dll that is there

   If you do not do the above step, RACE will not start anymore
    If you manage to screw it up, deinstall RACE, delete the RACE directory, start over again

    Once the new dll is in place and has been registered, start RACE again,
     open your competition , like C:\comps\da2003\da2003.mdb
    enter a dummy pilot
    And use Competition - Properties -
     Scoring Formula SAHPA Settings
   and press the "Create an avapk.csv file now" button
    A MSGBOX should appear stating that C:\avapk.csv has been created

    Now you are ready to add more pilots , define tasks,
    and receive results from TP to do the final scores

 ----  add the SAHPA Reports to RACE --------------------

   copy from , but only add, do not replace ,
   all the lst files to
   C:\Program Files\Race\Reports

   and make a backup copy of the
    C:\Program Files\Race\RCReport.ini file
    then copy the
   C:\comps\software\sahpaformula\REPORTS\RCReport.ini file to
   C:\Program Files\Race

   This will give you the possibility to print SAHPA  scores showing Categories

August 2003 update

RACE2003 Create avapk.csv buttons give 401 non-modal error
Code fixed to show only a Msgbox, not a new window

April 2003 update

April 2003 - Open XC tested at NODC 2003. Task Distance has to be the pilot who flew the furthest.
Open the RACE mdb file and enter the value in the tblTask.
But a rescore, change , update might reset this in RACE.

February 2003 update

February 2003 - REPORTS directory added. The files in there have to be added or replace the usual RACE files to see those unique SAHPA scores
New SAHPA logo in the frames

To define a comp in RACE2003 with the SAHPA Formula,  use FILE/NEW/COMP ,
make sure you use SAHPAFORMULA
As Catalog choose a Catalog which has been defined for SAHPA Formula, like SAHPA2003CATALOG
For pilot fields choose everything, except RANK
For User defined Attributes , Attribute 1 is CATEGORY, Attribute 2 is LICENCE, Attribute 3 is TEAM

To make a new CATALOG,  define the Pilot attributes as CATEGORY, LICENCE and TEAM
Then assign for LICENCE as values BASIC, SPORTS and ADVANCED
For CATEGORY use some short names, long values come out truncated on the final result printouts. Use something like OM,OF, SF,SM, or O, SE, SP, N
For teams you do not have to add anything upfront. Teams get added during a comp and every comp got different team names.

January 2003 update

January 2003 - start testing SAHPA 2.3 Formula with RACE2003 Pilot FAI info version.
 avapk.csv buttons introduced inside SAHPA RACE Formula code windows.
 One can now create an avapk.csv file when definining a comp or task.
The code expects you to select the mdb file.
Either the Mastercatalog. Like SAHPA2003CATALOG.mdb or similar name.
Or choose a ready defined Competition. Which contains the correct Pilot Attribute definitions.
Which has all the pilot attributes for CATEGORY and LICENCE attributes set up.

Why does the code use that avapk.csv ????
There is still a problem to access the database direct, getting from RACE the current database object to query any other info besides task and pilot.
In other words   I have not figured out yet how to access this attribute info inside the formula with the info provided by RACE.

How to install the 2.3 over an older version

 - make backup copies of any of the original RACE files, then overwrite/copy
 -  RCFormulaSAHPA.dll
 -  RCLangSAHPA.eng
  you might have to reregister the dll

October 2002 update

RACE2002 downloads give LL error when scoring a task.

The download does not include in the C:\Program Files\Race 2002\Reports the TaskResultSAHPA.lst file.
Add this file into the Reports directory to fix the problem.

July 2002 update

July 2002 - RACE2002

  started 2.2 Version of SAHPA Formula for RACE2002

   - the forms now show the current  software level

   - changed avapk.csv location hardcoded to c:\avapk.csv

   to make the SAHPA Formula work with RACE2002 ...

   in the RACE2002 directory rename RCFormulaSAHPA.dll to something else,     keep it as a backup copy

   copy the  RCFormulaSAHPA.dll from the code directory  into the RACE2002 directory

  in the code directory, click on the "register SAHPA DLL.exe" yellow exclamation mark icon
       use the RCFormulaSAHPA.dll in the RACE2002 directory as target to register

Start RACE and  go to the Tools /  Report Designer
   open the taskResultSAHPA.lst
     redefine your printer
   save it the report

 Use the SAHPA catalog for the correct definitions of the Attributes for the pilots for defining a SAHPA comp

make sure you got a RACE2002.msi install pack that included and  installed  a winmail.dat and cm32l601.lng file
make sure the RCReport.ini file got a SAHPA entry
make sure the TaskResultSAHPA.lst exist in the Reports directory

When you create a catalog, make sure the LICENCE  attPk in tblattributeValue

 Once you got your comp defined, use MS Access and export the tblAtrributeValue table as C:\avapk.csv

 Then you can start scoring a task