home *** CD-ROM | disk | FTP | other *** search
- (*****************************************************************************)
- (* _RFORM.PAS is a Turbo 4.0 unit to mimic the form funuction of Turbo 3.x. *)
- (* The underline in the name is a convention I've started to separate my unit*)
- (* files from everything else. *)
- (* *)
- (* _RFORM follows the numeric formating conventions of 3.0 except for *)
- (* two items. *)
- (* *)
- (* 1. A decimal '.' is the only way to define the decimal position in *)
- (* a real. Trailing decimal points are suppressed. I just spent *)
- (* to much time taking them off under 3.0. *)
- (* *)
- (* 2. Stand alone '.' and ',' are not mistaken for start of a field. *)
- (* *)
- (* Although written for a real input the parameter type, the 4.0 automatic *)
- (* type conversion allows you to pass any numeric type to the procedure. *)
- (* *)
- (* function Form(Picture : string; {Takes Real,Integer} *)
- (* R : real) : string; {LongInt,Word,Byte} *)
- (* *)
- (* Where a Picture can be a string such as: *)
- (* *)
- (* 'This is a picture of a real number @##,###.## with ''0'' left fill' *)
- (* 'This is a picture of a real number *##,###.## with ''*'' left fill' *)
- (* 'This is a picture *$#,###.## with ''*'' left fill and floating $' *)
- (* 'This is a picture +###,###.## with a leading sign character' *)
- (* 'This is a picture ###,###.##- with a trailing sign character' *)
- (* *)
- (*****************************************************************************)
-
- program _RFORM_DEMO;
-
- uses crt,_RFORM;
-
- var C : char;
-
- begin
- clrscr;
- writeln('Form Demo');
- writeln('@##,###.## This is a picture of a real number with ''0'' left fill');
- writeln(form('@##,###.## "0" left fill',pi*100));
- writeln;
- writeln('*##,###.## This is a picture of a real number with ''*'' left fill');
- writeln(form('*##,###.## "*" left fill.',pi*1000));
- writeln;
- writeln('*$#,###.## This is a picture with ''*'' left fill and floating $');
- writeln(form('*$#,###.## "*" left fill and floating "$"',pi*100));
- writeln;
- writeln('+###,###.## This is a picture with a leading sign character');
- writeln(form('+###,###.## leading sign character.',pi*10000));
- writeln;
- writeln('+###,###.## This is a picture with a leading sign character and * fill.');
- writeln(form('+##*,###.## leading sign character and "*" fill.',pi*1000));
- writeln;
- writeln('###,###.##- This is a picture with a trailing sign character');
- writeln(form('###,###.##- trailing sign character.',-pi*10000));
- writeln;
- writeln('###,###. This is a Picture with trailing decimal suppression');
- writeln(form('###,###. trailing decimal suppression.',-pi*10000));
- writeln;
- writeln('###,### Or no decimal and the comma is not mistaken for a decimal.');
- writeln(form('###,### No decimal.',-pi*10000));
- write('Press any key . . . ');
- C:=ReadKey;
- clrscr;
- end.