home *** CD-ROM | disk | FTP | other *** search
- CROSSREFERENCE UTILITY
-
- STARTUP:
- simply call crossref.com by entering CROSSREF<cr>.
-
- The application will comeup to a signon/data entry screen.
- This screen expects a valid complete filename (with
- extension).
-
- Most of the standard crossref/listing utilities ask for a
- filename and take off;
- Printing in 80 column format,
- Printing a variable crossref list,
- And perform no type of logical indenting.
-
- Well I tired of waiting for the listing of variables when all
- I had changed was syntax or some other such non variable bug.
-
-
- Printer Wide - default Y - (wide being 132 col.)
-
- I like to write lines as a single line of code. Must be a
- throwback to my damm basic days. But reading up to the semi-
- colon just helps me. Now there are those times when that is
- not possible but I hate to break a line just because we are
- nearing the 80 col. mark. Example:
-
- Has to be shorten to fit on this 80 col manual
-
-
- Write(lst,name:20,address:20,city:20,state:2,zip:5);
-
- The above is easier to see that all the data items are printed
- on the same line. However this does the same job and is a bit
- more involved paper wise and speed reading wise.
-
- Write(lst,name:20);
- Write(lst,Address:20);
- ETc.
-
- And of course the the problem with this is that most almost
- all Pascal code I have seen is written to fit on 80 col stock.
- But Turbo's own editor lets you create lines out to 128????
- Suffice it to say the crossref here is designed to be usable
- in either mode and you can toggle back to the 80 col standard
- is you so desire.
-
- Print CrossReference - Default N
-
- Another thing that frustrates me is all crossref/listing
- utilities I have come across always give you that cross
- reference. Well many times I have not changed variable usage
- and do not wish to wait for another copy of what I already
- have. I have made the printing of the crossreference
- selectable by you.
-
-
- Doing Include Files - Default N
-
- If you are not changing your include files why reprint them
- during development. You can turn this on when doing a final
- listing of a system. If you are working on an include then
- name that file for Crossref to list.
-
- Create New Formated File - Default N;
-
- I may be the only guy who thinks this is necessary but I am
- sure from looking at other programers code I am not the only
- one who suffers from source-format-lazies. This reoccuring
- affliction causes programers to become so engrossed in the
- task at hand they forget about (or think they will come back
- to) the job of proper indentation and line structure. Well
- when I suffer from this condition I never get back to it, or
- think "This little diddy is only for me so who cares.". Six
- months later while I am trying to figure out my own
- code...yeah you know. So this formater is designed to rewrite
- your source and indent it according to the rules laid down in
- the section of Printed Listing/Format File Appearance.
-
- This is probably where the world will find the most use or
- most fault with this application. I am still wondering why I
- have never found a public domain utility to do this work I
- can't have overlooked them. I am sure there are some but most
- programers have been told about the official indenting rules
- and how you should follow the rules. Well I have looked at
- lots and lots of other peoples code..(Good programers are
- included here) and no two listing have been alike...many times
- even from the same programer. So the reason a indenting
- formater has not been listed is because they are so hard to
- write.... Bunk. what's hard to do is please everybody.
-
- If you reply with Y for yes you will open another field on the
- same line expecting the filename to write to. You do not have
- to give an extension for the system forces one of .FMT.
-
- THE PRINTED LISTING/FORMAT FILE APPEARANCE
-
-
- So this indenting code is not designed to please everybody...
- as a matter of fact it does not please me all
- the time. But it does provide me with a FIXED FORMAT that handles
- about 95% of the indenting required to quickly examine IF,WHILES,FOR
- and other constructs that get tricky when nested. Yes I know there
- are rules to follow....even the experts say follow the rules and every
- one of them has different rules.... so here are my rules.
-
- 1. Ignore anything inside text strings or comments.
- Many of the crossref systems don't to that.
-
- 1a. Forget about trying to check semi-colon usage. If
- the indenting is correct then the compiler or you will
- easily spot all missing semi-colons.
-
- 2. A procedure or function rewinds indenting back to
- the left margin. Which means if we haven't backed up
- to the left margin before hitting the next procedure
- or function then we have a mismatch or un-ended
- something.
-
- 3. Record, Begin, Repeat, Case increment the indent
- tab. These are the only words that trigger increases,
- and the indent increase will occur on the next line
- NOT THE LINE CONTAINING THE KEYWORD. This is
- important as you can see from the samples at the end.
-
- 4. END and UNTIL are the only backup or decrease
- indent tab keywords. Since most everything in Pascal
- is ended this should work.
-
- 5. Begin should be on a line all to its' self.
-
- 6. End/Until should not appear on the same line as
- it's mate. See the formated code line 105 for example
- of what happens if you care to write short statements
- on a single line.
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- EXAMPLE:
-
-
- Lets get real sloppy with the indenting for a short piece of Turbo code then run
- it through the indenter code to see what we get.
-
-
- SOURCE AS WRITTEN
-
- Program Weight_Distribution;
-
-
- FOR ILLUSTRATION OF INDENTING BY CROSSREF ONLY!!!
-
-
-
- Const (* pulling vehicle *)
- Veh_wgt = 5860;
- Veh_front_axle = 32;
- Veh_rear_Axle = 119;
- veh_5th = 105;
-
- Trailer = 5420; (* hauling trailer *)
- T_hitch = 224;
- t_front_axle = 63;
- t_rear_axle = 1;
-
- Var
-
- i,j : integer; (* loop controls *)
- Total_lbs,
- Total_moments,
- bag_count,bags_row: real; (* misc globals *)
- t_front, t_rear : real; (* wgt at hitch,axle*)
- Front_Empty : boolean; (* loading front *)
- rows : array[0..16] of real; (* bags in each row *)
-
- procedure keyarr;
-
- const
- endflag = 'END';
-
- var
- Entry : string[20];
- code : integer;
-
- begin
- j:= 0;
- Entry := '';
- clrscr;
- writeln('*** Enter bag count per row counting from back of trailer **');
- writeln('*** Enter ',Endflag,' to end data entry. **');
- while (entry <> endflag) and (j <= 16) do
- begin
- if j = 11 then writeln('*** Front Section ***');
- write('Enter bag count for row ',j+1,': ');
- readln(Entry);
- if length(entry) = 0 then entry := 'bad';
- if (entry <> endflag) and (j <= 16) then
- begin
- val(entry,rows[j],code);
- if code <> 0 then
- begin
- writeln('** Illegal. Please reenter. **');
- j := j-1;
- end;
- j := j+1;
- end;
- end;
- (* array is full now scan for total bag_count *)
- clrscr;
- bag_count := 0;
- for j := 0 to 16 do
- begin
- bag_count := bag_count + rows[j];
- (* if first 6 rows empty then front_empty is set true *)
- if (j=5) and (bag_count=0.0) then front_empty := true
- else front_empty := false;
- end;
- end;
-
- there are several procs and functions missing that go here
-
-
- begin (* main loop repeat forever. The -1 is caught in get_bag_count *)
- repeat
- i := 0;
- j := 0;
- bags_row := 0;
- bag_count := 0;
- Total_lbs := 0.0;
- Total_moments := 100 * trailer; empty trailer wgt applied at cg.
- get_bag_count;
-
- The real work starts here we have bags per row in rows[x].
- There are four rows to the rear of fulcrum point hence the
- strange looking FOR loop indexes, need moments behind
- fulcrum negated.
-
- For i := -3 to 7 do
- begin
- Total_lbs := Total_lbs+(rows[i+3]*45);
- Total_moments := Total_Moments+((rows[i+3]*45)*(16 * i));
- end;
-
- If Not Front_Empty then
- For i := 11 to 16 do
- begin
- Total_lbs :=
- Total_lbs+(rows[i]*40);
- Total_moments := Total_moments+((rows[i]*40 )*(16*i));
- end;
-
- report;
- writeln('Press any key'); repeat until keypressed;
-
- until bag_count = -1;
-
- end.
-
-
-
-
- Now this is the indented version of the same file....
-
- Program weight_distribution;
-
-
- FOR ILLUSTRATION OF INDENTING BY CROSSREF ONLY!!!
-
-
-
- Const (* pulling vehicle *)
- veh_wgt = 5860;
- veh_front_axle = 32;
- veh_rear_axle = 119;
- veh_5th = 105;
-
- trailer = 5420; (* hauling trailer *)
- t_hitch = 224;
- t_front_axle = 63;
- t_rear_axle = 1;
-
- Var
-
- i,j : Integer; (* loop controls *)
- total_lbs,
- total_moments,
- bag_count,bags_row: Real; (* misc globals *)
- t_front, t_rear : Real; (* wgt at hitch,axle*)
- front_empty : Boolean; (* loading front *)
- rows : Array[0..16] Of Real; (* bags in each row *)
-
- Procedure keyarr;
-
- Const
- endflag = 'END';
-
- Var
- entry : String[20];
- code : Integer;
-
- Begin
- | j:= 0;
- | entry := '';
- | Clrscr;
- | Writeln('*** Enter bag count per row counting from back of trailer **');
- | Writeln('*** Enter ',endflag,' to end data entry. **');
- | While (entry <> endflag) And (j <= 16) Do
- | Begin
- | | If j = 11 Then Writeln('*** Front Section ***');
- | | Write('Enter bag count for row ',j+1,': ');
- | | Readln(entry);
- | | If Length(entry) = 0 Then entry := 'bad';
- | | If (entry <> endflag) And (j <= 16) Then
- | | Begin
- | | | Val(entry,rows[j],code);
- | | | If code <> 0 Then
- | | | Begin
- | | | | Writeln('** Illegal. Please reenter. **');
- | | | | j := j-1;
- | | | End;
- | | | j := j+1;
- | | End;
- | End;
- | (* array is full now scan for total bag_count *)
- | Clrscr;
- | bag_count := 0;
- | For j := 0 To 16 Do
- | Begin
- | | bag_count := bag_count + rows[j];
- | | (* if first 6 rows empty then front_empty is set true *)
- | | If (j=5) And (bag_count=0.0) Then front_empty := True
- | | Else front_empty := False;
- | End;
- End;
-
- {there are several procs and functions missing that go here}
-
-
- Begin (* main loop repeat forever. The -1 is caught in get_bag_count *)
- | Repeat
- | | i := 0;
- | | j := 0;
- | | bags_row := 0;
- | | bag_count := 0;
- | | total_lbs := 0.0;
- | | total_moments := 100 * trailer; empty trailer wgt applied at cg.
- | | get_bag_count;
- | |
- | | {The real work starts here we have bags per row in rows[x].
- | | There are four rows to the rear of fulcrum point hence the
- | | strange looking FOR loop indexes, need moments behind
- | | fulcrum negated.}
- | |
- | | For i := -3 To 7 Do
- | | Begin
- | | | total_lbs := total_lbs+(rows[i+3]*45);
- | | | total_moments := total_moments+((rows[i+3]*45)*(16 * i));
- | | End;
- | |
- | | If Not front_empty Then
- | | For i := 11 To 16 Do
- | | Begin
- | | | total_lbs := total_lbs+(rows[i]*40);
- | | | total_moments := total_moments+((rows[i]*40 )*(16*i));
- | | End;
- | |
- | | report;
- | Writeln('Press any key'); Repeat Until Keypressed;
- | |
- | Until bag_count = -1;
- |
- End.
-
-
- First notice how the header including the const, type, vars are pulled to the
- left margin.....
-
- Next in the procedure this same left margin is adopted, plus within the
- begin:end you see indenting which allows drawing vertical lines which properly
- nest logical blocks for quick visual inspection. This indentation is also don
- to a format file but without the verticle lines which of course would not
- compile..
-
- Now on the printed copy only you may see the message;
-
- ( Record, Case, Begin/End ) or ( Repeat/Until ) pairing mismatch )
-
- Which means that within the Function/Procedure directly above the message you
- have not ended a Record, Case, Begin or You didn't use Repeat or Until as a
- pair....
-
-
-
- The Corssref list for the above code is pretty standard...expect we do not list
- reserved words nor do we list any words within
- literal strings or comments...
-
-
- bag_count 24 63 66 68 81 107
- bags_row 24 80
- code 36 52 53
- endflag 32 43 44 50
- entry 35 40 44 48 49 50 52
- front_empty 26 68 69 97
- get_bag_count 84
- i 21 78 91 93 94 94 98 100
- 101 101
- j 21 39 44 46 47 50 52 56
- 56 58 58 64 66 68 79
- keyarr 29
- report 104
- rows 27 52 66 93 94 100 101
- t_front 25
- t_from_axle 16
- t_hitch 15
- t_rear 25
- t_rear_axle 17
- total_lbs 22 82 93 100 100
- total_moments 23 83 94 94 101 101
- trailer 14 83
- veh_5th 12
- veh_front_axle 10
- veh_rear_axle 11
- veh_wgt 9
- weight_distribu 1
-
-
- Notice that you can use this list to locate any unused functions or procedures.
- You see when using libraries there are many times when the entire library is
- included but only access one or two items within that library. By using this
- crossreference list you can find any varables/Functions/Procedures which are
- used on only one line. This is either the line the procedure/function is
- declared on or the line where you will get the complier error message
- **Undefined label** or equivlant. So use this list when you are ready to
- compile your final 'tightest' version of the code....
-
-