PROCEDURE Cretas( rea: real; VAR asc: PACKED ARRAY [lo..hi: integer] OF char; VAR pos: integer; place: integer); EXTERNAL; {*USER* CRETAS converts an input real number in REA to an output string of ASCII characters in ASC. The real number is assumed to be decimal (base 10). ASC MUST be a valid type0 or type1 string. POS specifies starting point and justification of the output in the string ASC. The string ASC will always be cleared before insertion of the real number conversion, so any previous contents of ASC will be destroyed. If POS is greater than 0 (zero), then the ascii characters will be left justified, starting at position POS. Leading blanks will be inserted before POS if POS is not the beginning of the string. If POS is 0, then the ascii characters will be right justified, using the entire string. Leading blanks will be inserted as needed in front of the converted number. If POS is less than 0, then the ascii characters will be right justified ending at -(POS). Once again, leading blanks will be inserted as needed in front of the converted number. PLACE will indicate the number of places desired after the decimal point. It must be zero or greater. If PLACE is zero, there will be only a trailing decimal point. PLACE can NEVER be negative. If the real number is negative, a leading minus "-" sign will precede the ascii digits. There will be no space between the minus sign and the first digit. A decimal point will ALWAYS be present. Likewise, if the number is less that 1.0, a leading zero before the decimal point will ALWAYS be present. Upon exit from this procedure, POS will be left pointing to the rightmost character placed in the number string. This is generally of value only if POS was greater than zero, indicating left justification was desired, as it now points to the rightmost character that was put in the string. If POS is returned as zero, there was a conversion error. Real numbers can vary from 1E-38 to 1E+38. You can specify a PLACE value larger than 38, however, it will simply return zeros in places beyond 38. Remember that single precision real numbers (4 bytes) will give you about 7 digits of precision, while double precision (8 bytes) will give you about 15 digits. *ERROR CODES* If POS is returned as zero, there was a conversion error. The most likely cause is that the resulting ascii represented real number would not fit in the string ASC provided. In this case, the string has been cleared, but nothing inserted. You as the caller can determine how to handle this case. Less likely conversion errors are due to programmer error, either with POS or PLACE values. These errors will also result in the below documented error messages appearing to aid in program debugging. The following error messages can appear when using CRETAS. They normally indicate a programming error. CRETAS -- ASC string is not a type0 or type1 string ( The ASC string parameter supplied must be a type0 or type1 string. ) CRETAS -- PLACE value (n) cannot be negative (A negative PLACE parameter "n" (number of places after decimal point) was used.) CRETAS -- POS value (n) is not within string' (The POS parameter "n" is in error as it does not fall between the lower and upper bounds of the string array.) }