![]() |
Max2 |
[ < Prev | Contents | Next > ] |
This appendix describes the main data types which are used in the Max system: in particular, the key data types which appear as fields in transactions.
A sequence of characters. Typically used for things like account "numbers", members' names, glider registrations and so on.
In most cases strings are stored in fixed length fields. Where appropriate, this manual uses the notation "string * nnn" to indicate the length, with "nnn" being either the actual maximum number of characters or a symbol for that maximum.
Whole numbers: ...-1, 0, 1, 2, 3... Used for fields such as aerotow-height (in feet), month and day numbers, and counts of various things. Also used for index numbers as discussed below.
Numbers used to index various data types. These are integers which are used in a special way.
Of particular interest are those which are used to index members of various sets of objects which can be added to and removed from by transactions. In these cases, the index number is allocated at the time that the transaction to create an object is posted. Examples include the various types of symbol, membership types, course types, trial lesson types and charging rules.
In the case of symbols and membership, course and trial lesson types the index allocated is simply the first free (unallocated) value for that set. For charging rules things are a little more complicated: the index is initially set to 1000 times the month number modulo 24 and the search starts from there and proceeds upwards until a free number is found.
A consequence of this mechanism is that problems can arise if objects are created in one month then objects of the same type are created in the preceding month. For example, suppose that for a few months there are no membership type creation or deletion transactions and that at the beginning of October there are 20 types numbered 0 to 19 when a new membership is created. The new type will be allocated index number 20. If we then go back to September and create another membership type it too will be allocated index number 20. There will not be any immediate problems until the state file for October is rebuilt when an error will be displayed because there is a transaction to create a membership type with a number which has already been allocated.
Because of the way the numbers are allocated for charging rules the problem is much less likely to apply. It could if you went back two years (unlikely) or created a thousand charging rules in one month (also unlikely).
The use of large index numbers to identify charging rules can't easily be applied to the other indexed types because the numbers are widely used to directly address arrays. (One partial solution which has been considered but not implemented with the symbols would be to start the search for free numbers at either end of the range of available indexes depending on whether it is an odd or even numbered month).
An amount of money. Stored as an integer number of pennies. Always displayed and entered as decimal number of pounds with two digits after the decimal point.
Sometimes, typically in the charging rules, also used as a rate in which case the value is interpreted as an amount of money per hour. This happens, for example, when a glider soaring rate is multiplied by a flight time to get the soaring charge for a flight.
A time of day (such as a glider take-off time) or a period of time (such as the flight time). Times of day are limited to a maximum of 24 hours, periods can be much larger (e.g., the accumulated flight time of an aircraft or a tachometer reading).
Values can be displayed and entered in either hours and minutes or hours and decimals of an hour depending on the context. For example, in the glider flight entry window only hours and minutes are accepted whereas in the power flight entry window either can be used.
A colon can be used to separate the hours from the minutes. A period (full-stop) is used to separate hours from decimals of an hour. On entry, if neither separator is used and the number of digits entered is three or four then the digits are interpreted as hours and minutes; i.e., as h:mm or hh:mm. Without a separator, any other number of digits is an error.
A single number of minutes can be entered. E.g., 12:5 is interpreted as 12:05 (though 125 would be taken as 01:25). The number of minutes cannot be 60 or greater or consist of more than two digits.
The fractional part of an hour must be either one or two digits.
Internally, times are stored in 1/300ths of an hour. This ensures that both numbers of minutes and 1/100ths of an hour can be stored without loss of accuracy. A minute is five 1/300ths of an hour and a 1/100th of an hour is, of course, 3 1/300ths of an hour.
When times are displayed the format used depends on the value and the preferred format for the context. The preferred format for glider flight information is normally hours and minutes. For power flights, it is often determined by the setting of the various input fields for the particular aircraft: chocks-input, flight-input, tacho-input and hobbs-input.
There are four possibilities:
The last case is unlikely but could arise if, for example, a value entered in hours and minutes is added to a value entered in hours and decimals. E.g., 0:01 + 0.01 is 5/300 + 3/300 = 8/300 which would display as 0:01.6. The fractional minute will always be a single digit: one of "2", "4", "6" or "8".
For both display and input, when the number of hours is 1000 or greater commas can be inserted every third digit from the right to improve readability.
Symbols don't form a type of their own - they are a class of types. Examples of the actual symbol types are: Heading, Cash Heading, Property and Special Rule Code.
A symbol type consists of a set of symbols made up of:
For each symbol set there is a set of transaction types to create, delete and rename the symbols in the set. The integer for a symbol is allocated at the time that the symbol is created (i.e., when the symbol creation transaction is posted) and is used to reference it later transactions.
A Max2 (sales) heading. These are symbols and, as such, are stored as small integers.
A Max2 cash heading. These are symbols and, as such, are stored as small integers.
A Max2 account property. These are symbols and, as such, are stored as small integers.
Values used in the special-rule-code field of glider flight transactions. These are symbols and, as such, are stored as small integers.
[ < Prev | Contents | Next > ] |