home *** CD-ROM | disk | FTP | other *** search
- Procedure GetInteger(Prompt : PromptString; Var IntegerParameter : Integer);
- { This procedure reads an I/O checked integer from the user. The two
- parameters pass the prompt and the variable, respectively. }
- Begin { Procedure GetInteger }
- Repeat
- Write(Prompt);
- {$I-} Readln(IntegerParameter) {$I+};
- OK := (IoResult = 0);
- If Not OK Then
- Write(^G); { Ring bell to alert user to entry error }
- Writeln;
- Until OK;
- End; { Procedure GetInteger }
-
- Procedure ReportBadEntry(Message : PromptString);
- { Report entry error to user }
- Begin { Procedure ReportBadEntry }
- HighVideo;
- Writeln(^g,Message); { Ring bell & write error message }
- LowVideo;
- End; { Procedure ReportBadEntry }
-
- Procedure SelectH; { Select desired Herschel classes }
- Var
- SaveClass,SelectClass : HClassSet;
- Ch : Char;
- Begin { Procedure SelectH }
- ClrScr;
- Writeln('The Herschel classes are:');
- Writeln;
- HighVideo; Write(' 1'); LowVideo; Writeln(' : Bright Nebulae');
- HighVideo; Write(' 2'); LowVideo; Writeln(' : Faint Nebulae');
- HighVideo; Write(' 3'); LowVideo; Writeln(' : Very Faint Nebulae');
- HighVideo; Write(' 4'); LowVideo; Writeln(' : Planetary Nebulae');
- HighVideo; Write(' 5'); LowVideo; Writeln(' : Very Large Nebulae');
- HighVideo; Write(' 6'); LowVideo;
- Writeln(' : Very Compressed and Rich Clusters of Stars');
- HighVideo; Write(' 7'); LowVideo;
- Writeln(' : Compressed Clusters of Small and Large Stars');
- HighVideo; Write(' 8'); LowVideo;
- Writeln(' : Coarsely Scattered Clusters of Stars');
- Writeln;
- Writeln('Current selected values are:');
- If ClassSet >= [1..8] Then
- Writeln('All Herschel classes.')
- Else
- Begin { Else }
- Write('Herschel class(es) ');
- For Index := 1 To 8 Do
- If Index In ClassSet Then
- Write(ClassNames[Index],' ');
- Writeln;
- End; { Else }
- Writeln;
- SaveClass := ClassSet; { Save the current set in case we need to keep it }
- If Not Expanding Then
- ClassSet := [];
- Write('Type single digit classes one at a time. Type "');
- HighVideo; Write('Q'); LowVideo; Writeln('" to quit');
- Writeln;
- Write('Type your class(es) now: ');
- Repeat
- Repeat
- Read(Kbd,Ch);
- Until Upcase(Ch) In ['1'..'8','Q'];
- HighVideo; Write(Ch,' ');
- If Upcase(Ch) <> 'Q' Then
- Begin { Then }
- Case Ch Of
- '1' : SelectClass := [1];
- '2' : SelectClass := [2];
- '3' : SelectClass := [3];
- '4' : SelectClass := [4];
- '5' : SelectClass := [5];
- '6' : SelectClass := [6];
- '7' : SelectClass := [7];
- '8' : SelectClass := [8];
- End; { Case }
- ClassSet := ClassSet + SelectClass; { Build set of desired classes }
- End; { Then }
- Until Upcase(Ch) = 'Q';
- If ClassSet = [] Then { User entered procedure but didn't select anything }
- ClassSet := SaveClass { Restore saved class selection values }
- Else
- NewSelection := True; { Something was selected }
- End; { Procedure SelectH }
-
- Procedure SelectNGC;
- { This procedure allows the user to select a range of desired NGC #s. }
- Begin { Procedure SelectNGC }
- ClrScr;
- Writeln('Currently selected NGC #s are from ',LowNGC,' to ',HighNGC);
- Writeln;
- AllOK := False;
- NewSelection := True;
- Repeat
- Writeln;
- GetInteger('Enter low NGC number: ',LowNGC);
- GetInteger('Enter high NGC number: ',HighNGC);
- AllOK := LowNGC <= HighNGC;
- If Not AllOK Then
- ReportBadEntry('Enter the low NGC number first!');
- Until AllOK;
- End; { Procedure SelectNGC }
-
- Procedure SelectRA;
- { This procedure allows the user to select a desired range of r.a. }
- Begin { Procedure SelectRA }
- ClrScr;
- Write('Currently selected r.a. values are from ',LowRAHr,'h, ');
- Writeln(LowRAMin,'m to ',HighRAHr,'h, ',HighRAMin,'m');
- AllOK := False;
- NewSelection := True;
- Repeat
- Writeln;
- GetInteger('Enter low r.a. Hrs. : ',LowRAHr);
- GetInteger(' Enter Low r.a. Minutes: ',LowRAMin);
- GetInteger('Enter high r.a. Hrs. : ',HighRAHr);
- GetInteger(' Enter high r.a. minutes: ',HighRAMin);
- AllOK := LowRAHr <= HighRAHr;
- If Not AllOK Then
- Begin { Then }
- Write('Wrap around the 0 Hr. line? (Y/N): ');
- Repeat
- Read(Kbd,Ch);
- Until Upcase(Ch) In ['Y','N'];
- AllOK := Upcase(Ch) = 'Y';
- End; { Then }
- Until AllOK;
- End; { Procedure SelectRA }
-
- Procedure SelectDec;
- { Select desired range of Declination. }
- Begin { Procedure SelectDec }
- ClrScr;
- Write('Currently selected dec. values are from ',LowDecDeg,'d, ');
- Writeln(LowDecMin,'m to ',HighDecDeg,'d, ',HighDecMin,'m');
- AllOK := False;
- NewSelection := True;
- Repeat
- Writeln;
- GetInteger('Enter low Dec. degrees: ',LowDecDeg);
- GetInteger(' Enter low Dec. minutes: ',LowDecMin);
- GetInteger('Enter high Dec. degrees: ',HighDecDeg);
- GetInteger(' Enter high Dec. minutes: ',HighDecMin);
- AllOK := LowDecDeg <= HighDecDeg;
- If Not AllOK Then
- ReportBadEntry('Enter the low declination first!');
- Until AllOK;
- End; { Procedure SelectDec }
-
- Procedure SelectMag;
- { Select a desired range of magnitude. }
- Begin { Procedure SelectMag }
- ClrScr;
- Write('Currently selected mag. values are from ');
- Writeln(LowMag / 10:4:1,' to ',HighMag / 10:4:1);
- AllOK := False;
- NewSelection := True;
- Repeat
- Writeln;
- Repeat
- Write('Enter low (bright) magnitude: ');
- {$I-} Readln(LowMag) {$I+};
- OK := (IoResult = 0);
- If Not OK Then
- Write(^G); { Ring bell to alert user to entry error }
- Writeln;
- Until OK;
- LowMag := LowMag * 10;
- Repeat
- Write('Enter high (faint) magnitude: ');
- {$I-} Readln(HighMag) {$I+};
- OK := (IoResult = 0);
- If Not OK Then
- Write(^G); { Ring bell to alert user to entry error }
- Writeln;
- Until OK;
- HighMag := HighMag * 10;
- AllOK := LowMag <= HighMag;
- If Not AllOK Then
- ReportBadEntry('Enter the low magnitude first!');
- Until AllOK;
- End; { Procedure SelectMag }
-
- Procedure SelectType;
- { Select desired object types. }
- Var
- SaveTypes,SelectType : HTypeSet;
- Ch : Char;
- Begin { Procedure SelectType }
- ClrScr;
- Writeln('Object types are:');
- Writeln;
- HighVideo; Write(' O'); LowVideo; Writeln('pen Clusters');
- Write(' Globular '); HighVideo; Write('C'); LowVideo; Writeln('lusters');
- HighVideo; Write(' D'); LowVideo; Writeln('iffuse Nebulae');
- HighVideo; Write(' P'); LowVideo; Writeln('lanetary Nebulae');
- HighVideo; Write(' G'); LowVideo; Writeln('alaxies');
- Write(' Clusters'); HighVideo; Write('/'); LowVideo; Writeln('Nebulae');
- HighVideo; Write(' N'); LowVideo; Writeln('onexistant');
- Writeln;
- Writeln('Currently selected object types are:');
- If TypeSet >= [1..7] Then
- Writeln('All object types.')
- Else
- Begin { Else }
- Write('Object type(s) ');
- For Index := 1 To 7 Do
- If Index In TypeSet Then
- Write(ObjectTypes[Index],' ');
- Writeln;
- End; { Else }
- Writeln;
- Write('Type single characters for types one at a time. Type "');
- HighVideo; Write('Q'); LowVideo; Writeln('" to quit.');
- Writeln;
- SaveTypes := TypeSet; { Save current value for possible restoring }
- Writeln;
- If Not Expanding Then
- TypeSet := [];
- Write('Type your object class(es) now: ');
- Repeat
- Repeat
- Read(Kbd,Ch);
- Until Upcase(Ch) In ['O','G','P','D','C','U','N','/','Q'];
- HighVideo; Write(Ch,' ');
- If Upcase(Ch) <> 'Q' Then
- Begin { Then }
- Case Ch Of
- 'O','o' : SelectType := [1];
- 'C','c' : SelectType := [2];
- 'D','d' : SelectType := [3];
- 'P','p' : SelectType := [4];
- 'G','g' : SelectType := [5];
- '/' : SelectType := [6];
- 'N','n' : SelectType := [7];
- End; { Case }
- TypeSet := TypeSet + SelectType; { Build set of desired types }
- End; { Then }
- Until Upcase(Ch) = 'Q';
- If TypeSet = [] Then { User enterd procedure but didn't select anything }
- TypeSet := SaveTypes { Restore saved type selection values }
- Else
- NewSelection := True; { Something was selected }
- End; { Procedure SelectType }
-
- Procedure SelectCon;
- { Select desired constellations. }
- Const
- Arrow = '->';
-
- Var
- FunKey,AllSelected,SelfDeleted,ChangeInArray : Boolean;
- HoldCons : Array[Cons] Of Boolean;
- ConArrayIndex,X,Y,Row,Column : Byte;
- Index : Cons;
-
- Procedure Beep; { Make a sound when the arrow is moved }
- Begin { Procedure Beep }
- Sound(1000);
- Delay(3);
- NoSound;
- End; { Procedure Beep }
-
- Procedure AddCon;
- { The user typed a "+" - so add the constellation to the desired list.
- The Constel array flags the desired constellations for comparison in
- procedure Inp. }
- Begin { Procedure AddCon }
- Beep;
- Constel[Index] := True;
- Write(Names[Index]);
- End; { Procedure AddCon }
-
- Procedure RemoveCon;
- { The user typed a "-", so we remove the constellation from consideration. }
- Begin { Procedure RemoveCon }
- Beep;
- Constel[Index] := False;
- LowVideo;
- Write(Names[Index]);
- HighVideo;
- End; { Procedure RemoveCon }
-
- Procedure EraseArrow;
- { This procedure erases the "->" at each new move. }
- Begin { Procedure EraseArrow }
- Beep;
- GoToXY(X,Y);
- Write(' ');
- End; { Procedure EraseArrow }
-
- Procedure GetArrow;
- { The user typed an arrow (cursor control) key - find which one & respond }
- Begin { Procedure GetArrow }
- If KeyPressed Then
- Begin { Then }
- FunKey := True;
- Read(Kbd,Ch); { Get 2nd character of extended code }
- End; { Then }
- If FunKey Then
- Begin { Then }
- FunKey := False;
- Case Ch Of
- #81 : Ch := 'a'; { # 81 is 'Q' and we don't want to quit }
- #75 : Begin { Case Left }
- EraseArrow;
- X := X - 5;
- Index := Index - 1;
- If X < 10 Then
- Begin { Then }
- X := 60;
- Index := Index + 11;
- End; { Then }
- End; { Case Left }
- #77 : Begin { Case Right }
- EraseArrow;
- X := X + 5;
- Index := Index + 1;
- If X > 60 Then
- Begin { Then }
- X := 10;
- Index := Index - 11;
- End; { Then }
- End; { Case Right }
- #72 : Begin { Case Up }
- EraseArrow;
- Y := Y - 2;
- Index := Index - 11;
- If Y < 1 Then
- Begin { Then }
- Y := Y + 16;
- Index := Index + 88;
- End; { Then }
- End; { Case Up }
- #80 : Begin { Case Down }
- EraseArrow;
- Y := Y + 2;
- Index := Index + 11;
- If Y > 17 Then
- Begin { Then }
- Y := Y - 16;
- Index := Index - 88;
- End; { Then }
- End; { Case Down }
- End; { Case }
- End; { Then }
- End; { Procedure GetArrow }
-
- Procedure WriteConScreen; { Write the constellation selection screen }
- Begin { Procedure WriteConScreen }
- ClrScr;
- Writeln;
- For Row := 0 To 7 Do { Nested FOR loop to write Con. names in order }
- Begin { For Row }
- Tab(11);
- For Column := 1 To 11 Do
- Begin { For Column }
- LowVideo;
- If Constel[11 * Row + Column] Then
- HighVideo;
- Write(Names[11 * Row + Column],' ');
- End; { For Column }
- Writeln; Writeln;
- End; { For Row }
- LowVideo;
- Writeln;
- Tab(18); Writeln('Position arrow with cursor control keys.');
- Writeln;
- Tab(16); Write('Add with "'); HighVideo; Write('+');
- LowVideo; Write('", delete with "'); HighVideo; Write('-');
- LowVideo; Write('". Quit with "'); HighVideo; Write('Q');
- LowVideo; Writeln('".');
- Writeln;
- Tab(19); Write('Add all with "'); HighVideo; Write('A');
- LowVideo; Write('", delete all with "'); HighVideo; Write('D');
- LowVideo; Writeln('"');
- HighVideo;
- End; { Procedure WriteConScreen }
-
- Procedure AddAll; { Add all constellations into consideration. This makes
- it easier to add all but a few constellations. }
- Begin { Procedure AddAll }
- Beep;
- Constel := TrueConArray; { All constellations selected }
- WriteConScreen;
- End; { Procedure AddAll }
-
- Procedure DeleteAll; { Remove all constellations from consideration }
- Begin { Procedure DeleteAll }
- Beep;
- For ConArrayIndex := 0 To NumberOfConstellations Do
- Constel[ConArrayIndex] := False;
- WriteConScreen;
- End; { Procedure DeleteAll }
-
- Begin { Procedure SelectCon }
- { Here is the logic at the heart of the SelectCon routine. }
- SelfDeleted := True; { Program will delete all if all cons. are selected }
- For Index := 0 To NumberOfConstellations Do { Loop to check selections }
- If Not Constel[Index] Then { Not every con. was selected }
- SelfDeleted := False;
- If SelfDeleted Then { Delete all & prepare for fresh selection }
- For Index := 0 To NumberOfConstellations Do { Delete all }
- Constel[Index] := False;
- HoldCons := Constel; { Save Constel array for comparing at proc. end }
- FunKey := False; { No numeric keypad key has been pressed }
- Window(1,1,80,25); { Set window size to entire screen }
- WriteConScreen;
- X := 10; { Initial position for arrow }
- Y := 2;
- Index := 1; { Arrow is at Constel[1] }
- Repeat
- GoToXY(X,Y);
- Write(Arrow);
- Repeat
- Read(Kbd,Ch)
- Until Upcase(Ch) In ['+','-','Q','A','D',#27];
- Case Ch Of
- '+' : AddCon;
- '-' : RemoveCon;
- 'A','a' : AddAll;
- 'D','d' : DeleteAll;
- #27 : GetArrow;
- End; { Case }
- Until Upcase(Ch) = 'Q';
- LowVideo;
- ChangeInArray := False; { For checking for individual changes }
- AllSelected := True; { For checking for case of all selected }
- For Index := 0 To NumberOfConstellations Do { Loop to check selections }
- Begin { For Index }
- If Constel[Index] <> HoldCons[Index] Then
- ChangeInArray := True; { Something has changed since we saved }
- If Not Constel[Index] Then { Not all were selected }
- AllSelected := False;
- End; { For Index }
- If Not (SelfDeleted And AllSelected) Then { OK to set NewSelection }
- If ChangeInArray Then
- NewSelection := True;
- If SelfDeleted And ((Not ChangeInArray) Or AllSelected) Then
- Constel := TrueConArray; { User made no selection so we restore all }
- End; { Procedure SelectCon }
-
- Procedure DisplaySelectionSet; { Called from proc. ExamineStatus }
- Var
- Index,ConCount : Byte;
- ConSelected : Boolean;
- Begin { Procedure DisplaySelectionSet }
- With SelectionSetArray[SetChoice] Do
- Begin { With }
- Writeln;
- ConCount := 0;
- ConSelected := False;
- HighVideo; Writeln('Current selected values are:'); LowVideo;
- Writeln;
- Write('Sorted by ');
- Case SortField Of
- 'H','h',' ' : Writeln('Herschel class.');
- 'N','n' : Writeln('NGC number.');
- 'R','r' : Writeln('right ascension.');
- 'D','d' : Writeln('declination.');
- 'M','m' : Writeln('magnitude.');
- 'O','o' : Writeln('object type.');
- 'C','c' : Writeln('constellation.');
- End; { Case }
- Writeln;
- If ClassSet >= [1..8] Then
- Writeln('All Herschel classes.')
- Else
- Begin { Else }
- Write('Herschel class(es) ');
- For Index := 1 To 8 Do
- If Index In ClassSet Then
- Write(ClassNames[Index],' ');
- Writeln;
- End; { Else }
- Writeln;
- If (LowNGC <= 0) And (HighNGC >= 8000) Then
- Writeln('All NGC numbers.')
- Else
- Writeln('NGC numbers from ',LowNGC,' to ',HighNGC);
- Writeln;
- If (LowRAHr <= 0) And (LowRAMin <= 0) And (HighRAHr >= 24)
- And (HighRAMin >= 60) Then
- Writeln('All r.a. values.')
- Else
- Writeln('R.A. from ',LowRAHr,' Hrs, ',LowRAMin,' Min to ',
- HighRAHr,' Hrs, ',HighRAMin,' Min.');
- Writeln;
- If (LowDecDeg <= -90) And (LowDecMin <= -60) And (HighDecDeg >= 90) And
- (HighDecMin >= 60) Then
- Writeln('All Dec. values.')
- Else
- Writeln('Dec. from ',LowDecDeg,' Deg, ',LowDecMin,' Min to ',
- HighDecDeg,' Deg, ',HighDecMin,' Min.');
- Writeln;
- If (LowMag <= 0) And (HighMag >= 170.0) Then
- Writeln('All magnitudes.')
- Else
- Writeln('Magnitudes from ',(LowMag/10):4:1,' to ',(HighMag/10):4:1,'.');
- Writeln;
- If TypeSet >= [1..7] Then
- Writeln('All object types.')
- Else
- Begin { Else }
- Write('Object type(s) ');
- For Index := 1 To 7 Do
- If Index In TypeSet Then
- Write(ObjectTypes[Index],' ');
- Writeln;
- End; { Else }
- Writeln;
- For Index := 1 To NumberOfConstellations Do
- If Not Constel[Index] Then
- Begin { Then }
- ConSelected := True;
- ConCount := Succ(ConCount);
- End; { Then }
- If Not ConSelected Then
- Writeln('All Constellations.')
- Else
- If ConCount = NumberOfConstellations Then
- Writeln('No Constellations.')
- Else
- Begin { Else }
- Writeln('The following constellation(s):');
- ConCount := 0;
- For Index := 1 To NumberOfConstellations Do
- Begin { For }
- If Constel[Index] Then
- Begin { Then }
- Write(Names[Index],' ');
- ConCount := Succ(ConCount);
- If ConCount > 14 Then
- Begin { Then }
- Writeln;
- ConCount := 0;
- End; { Then }
- End; { Then }
- End; { For }
- End; { Else }
- Writeln; Writeln; HighVideo;
- If DisplayIndex >= 2 Then { We'll need this version of the message }
- Begin { Then }
- Write('Press "Q" to quit, or any ');
- Write('other key to proceed: ');
- End { Then }
- Else { Just hit something when you're done looking }
- Write('Press any key to proceed: ');
- LowVideo;
- Read(Kbd,Ch); { We take the first value entered }
- If DisplayIndex < 2 Then { Fool proc. ExamineStatus into stopping }
- Ch := 'Q'; { See final repeat loop in proc. ExamineStatus }
- End; { With }
- End; { Procedure DisplaySelectionSet }
-
- Procedure ExamineStatus; { Show selected values to user }
- Var
- ErrorCode : Integer;
- ChoiceOK : Boolean;
- Begin { Procedure ExamineStatus }
- ClrScr;
- Window(20,1,80,25); { Center status display screen }
- If DisplayIndex >= 2 Then
- Repeat
- ClrScr;
- Ch := 'X'; { Anything but "Q", for this Repeat loop }
- Write('There are currently ',DisplayIndex);
- Writeln(' selection sets in use.');
- Write('Display values for which one (1-',DisplayIndex,')? ');
- Repeat
- Read(Kbd,Ch); { 'Looking for a digit }
- Val(Upcase(Ch),SetChoice,ErrorCode); { Convert char to integer }
- If Not (ErrorCode = 0) Then { Value entered was not an integer }
- ChoiceOk := False
- Else { Number was good, but is it between 1 and 9? }
- ChoiceOk := (SetChoice > 0) And (SetChoice <= DisplayIndex);
- Until ChoiceOk;
- Write(SetChoice); { So user knows what he asked for }
- DisplaySelectionSet;
- Until Upcase(Ch) = 'Q' { From proc. DisplaySelectionSet }
- Else
- Begin { Else }
- AssignSelections(1); { For the "with" in proc. DisplaySelectionSet }
- SetChoice := 1; { We will display the one & only selection set }
- DisplaySelectionSet;
- End; { Else }
- End; { Procedure ExamineStatus }