home *** CD-ROM | disk | FTP | other *** search
/ Meeting Pearls 3 / Meeting_Pearls_III.iso / Pearls / midi / misc / Midi2TeX / src / tp_debug.pas < prev    next >
Pascal/Delphi Source File  |  1992-07-28  |  5KB  |  123 lines

  1. UNIT TP_debug;
  2.  
  3. INTERFACE
  4. uses TP_decl,
  5.      PRINTER,
  6.      TP_misc;
  7.  
  8. Procedure WriteDebugInfo(Instring : String);
  9. Procedure ToBothEr(S : STring);
  10. Procedure ErrorExit(errorcode : integer);
  11. Procedure Warning(S:String);
  12.  
  13. IMPLEMENTATION
  14.  
  15.  
  16. (********************************************************)
  17.    Procedure WriteDebugInfo(Instring : String);
  18. (********************************************************)
  19. Begin
  20. If debug then
  21.     case debugout of 
  22.         SCREEN      : WriteLn(InString);
  23.         DEBFILE     : WriteLn(DebugFile,Instring);
  24.         PRINT       : WriteLn(Lst,Instring);
  25.     End;    
  26. End;    
  27.  
  28.  
  29. (********************************************)
  30.     Procedure Help;
  31. (********************************************)
  32. Begin
  33. (* WriteLn('A correct call to Midi2TeX looks like this :'); *)
  34. WriteLn('');
  35. WriteLn('    MIDI2TEX midifilename [TeXfilename] [-option1] [-option2] ...');
  36. WriteLn('');
  37. WriteLn('Switch -s suppresses note generation for tracks #');
  38. WriteLn('Switch -o determines order of tracks to display on staffs (up-down)');
  39. WriteLn('Switch -b assigns the bass clef to staff # (counted from top to bottom)');
  40. WriteLn('Switch -a1..-a5 assign the alto clefs to staff # (from top to bottom)');
  41. WriteLn('Switch -i assigns 2 or more staffs to one instrument');
  42. WriteLn('Switch -q determines the quantization note time, 1,2,4,8,16,32,64,128');
  43. WriteLn('Switch -p redefines the part time, (default a quarter note)');
  44. WriteLn('Switch -f forces the slopes of the beams to be zero');
  45. WriteLn('Switch -h changes the horizontal size of the score [1600  *0.1mm]');
  46. WriteLn('Switch -v changes the vertical size of the score [2400 *0.1mm]');
  47. WriteLn('Switch -m select music size [20,16]');
  48. WriteLn('Switch -e change \elemskip value (in pt)');
  49. {$IFDEF ST}
  50. WriteLn('Switch -x skips wait for key hit at end of program');
  51. {$ENDIF}
  52. WriteLn('Switch -d@ switches on debugging info, @ can be any of the following :');
  53. WriteLn(' NONE    : no debugging,             SCREEN  : debug info to the screen');
  54. WriteLn(' PRINTER : debug info to the printer,   FILE : debug info to a file');
  55. WriteLn('Switch -? displays this help message');
  56. End;
  57.  
  58. (********************************)
  59.  Procedure ToBothEr(S : STring);
  60. (********************************)
  61. Begin
  62. WriteDebugInfo('Fatal error:'+S);
  63. WriteLn('');WriteLn('Fatal error:'+S);
  64. End;
  65.  
  66. (********************************)
  67.  Procedure Warning(S : STring);
  68. (********************************)
  69. Begin
  70. WriteDebugInfo('Warning:'+S);
  71. WriteLn('Warning:'+S);
  72. End;
  73.  
  74.  
  75. (********************************************)
  76.     Procedure ErrorExit(errorcode : integer);
  77. (********************************************)
  78.  
  79. Begin
  80.   case errorcode of
  81.        0 : Help; 
  82.        1 : ToBothEr(' No input file specified, or file does not exist ');
  83.        3 : ToBothEr(' MidiFile track '+B2S(curtrack)+' is not ok');
  84.        4 : ToBothEr(' Found a NoteOff without a NoteOn');
  85.        5 : ToBothEr(' Can only translate MIDI files of type 1, sorry...');
  86.        6 : ToBothEr(' Nil pointer detected in NoteOff search');
  87.        7 : ToBothEr(' No. of order indices does not correspond with No. of tracks in file');
  88.        8 : ToBothEr(' Staffindex out of range, you tried to change a staff attribute which I cannot handle');
  89.        9 : ToBothEr(' Heap exhausted during initializing memory');
  90.        10: ToBothEr(' The noteheap appeared to be empty during a note request to the noteheap');
  91.        11: ToBothEr(' A note value exceeded 127, probably a program bug');
  92.        12: ToBothEr(' Invalid PartTime entered, only one of 1,2,4,8,16,32 allowed');
  93.        13: ToBothEr(' Invalid quantization time entered, use switch -? to get proper range');
  94.        14: ToBothEr(' Can only define one multi-staff instrument in this version');
  95.        15: ToBothEr(' Definition of an instrument of one track is useless');
  96.        16: ToBothEr(' The Slurr-array is exhausted, too many slurrs (9) for MusicTeX');
  97.        17: ToBothEr(' Process terminated by user ');
  98.        18: ToBothEr(' The Beam-array is exhausted, too many beams (9) for MusicTeX');
  99.        19: ToBothEr(' -h,-v,-m and -k option can only take one parameter');
  100.        20: ToBothEr(' -m option parameter must be either 20 or 16');
  101.        21: ToBothEr(' -k option parameter must be between -8 and 8');
  102.        22: ToBothEr(' -a1..-a5 option parameter is not correct');
  103.        23: ToBothEr(' -s option parameter is not correct');
  104.        24: ToBothEr(' Unexpected end of MIDI file reached, file corrupted ?');
  105.        Else
  106.          ToBothEr(' Unknown error , either a corrupted midi file or a bug..');
  107.   end;
  108.   WriteDebugInfo('Program Terminated');
  109.   Case ErrorCode of
  110.      1,7,8,12,13,14,15 :  WriteLn('Run program with switch -? to get additional help');
  111.   Else
  112.      If MIDIFileOpened Then
  113.         Begin
  114.         WriteLn(TeXFile,'%MIDI2TeX file processing aborted due to a non-run time error');
  115.         WriteLn(TexFile,'\finmorceau');
  116.         WriteLn(TexFile,'\bye');
  117.         End;
  118.   End;
  119.   Halt;
  120. End; (* ErrorExit *)
  121.  
  122. Begin
  123. End.