home *** CD-ROM | disk | FTP | other *** search
- UNIT TP_Misc;
-
- INTERFACE
-
- uses TP_decl,
- Printer,DOS;
-
-
- Function I2S(Num : Integer): String;
- Function SI2S(Num : ShortInt): String;
- Function B2S(Num : Byte): String;
- Function LI2S(Num : LongInt): String;
- Function W2S(Num : Word): String;
- Function TimeDiff(time2,time1:MeasureTime):LongInt;
- Function EqualTime(time2,time1:MeasureTime):Boolean;
- Procedure SetTime(VAR time:MeasureTime; M,P : WORD);
- Procedure AddTime(time2,time1:MeasureTime;VAR time3 : MeasureTime);
- Procedure DisplayLicense;
- Function FileExists (Filename : STRING) : BOOLEAN;
- Function Power(TheNumber,TheExp:Byte):word;
-
- IMPLEMENTATION
-
- (**********************************************)
- Function Power(TheNumber,TheExp:Byte):word;
- (**********************************************)
- VAR tmp : word;
- BEGIN
- Tmp:=1;
- While TheExp>0 DO
- Begin
- Tmp:=Tmp*TheNumber;
- DEC(TheExp);
- End;
- Power:=Tmp;
- End; (* power *)
-
-
- (********************************************************)
- Procedure WriteDebugInfo(Instring : String);
- (********************************************************)
- Begin
- If debug then
- case debugout of
- SCREEN : WriteLn(InString);
- DEBFILE : WriteLn(DebugFile,Instring);
- PRINT : WriteLn(Lst,Instring);
- End;
- End;
-
- (********************************************************)
- Function I2S(Num : Integer): String;
- (********************************************************)
- VAR Res : String[25];
- Begin
- Str(Num,Res);
- I2S:=REs;
- End;
-
- (********************************************************)
- Function SI2S(Num : ShortInt): String;
- (********************************************************)
- VAR Res : String[25];
- Begin
- Str(Num,Res);
- SI2S:=Res;
- End;
-
- (********************************************************)
- Function B2S(Num : Byte): String;
- (********************************************************)
- VAR Res : String[25];
- Begin
- Str(Num,Res);
- B2S:=REs;
- End;
-
- (********************************************************)
- Function LI2S(Num : LongInt): String;
- (********************************************************)
- VAR Res : String[25];
- Begin
- Str(Num,Res);
- LI2S:=REs;
- End;
-
-
- (********************************************************)
- Function W2S(Num : Word): String;
- (********************************************************)
- VAR Res : String[25];
- Begin
- Str(Num,Res);
- W2S:=REs;
- End;
-
- (********************************************************)
- Function TimeDiff(time2,time1:MeasureTime):LongInt;
- (********************************************************)
- VAR dt : Longint;
- Begin
- dt:=(time2.Measure-time1.Measure)*PieceContr.TicksPerMeasure;
- dt:=dt+time2.MPart-time1.MPart;
- TimeDiff:=dt;
- End;
-
- (********************************************************)
- Function EqualTime(time2,time1:MeasureTime):Boolean;
- (********************************************************)
- Begin
- EqualTime:=TRUE;
- If time2.Measure<>time1.Measure Then EqualTime:=FALSE;
- If time2.Mpart<>time1.Mpart Then EqualTime:=FALSE;
- End;
-
-
- (*********************************************************************)
- Procedure AddTime(time2,time1:MeasureTime;VAR time3 : MeasureTime);
- (*********************************************************************)
- VAR M : Longint;
- Begin
- M:=PieceContr.TicksPerMeasure*(time1.Measure+time2.Measure)+time1.MPart+time2.MPart;
- time3.Measure:=M div PieceContr.TicksPerMeasure;
- time3.MPart:=M mod PieceContr.TicksPerMeasure;
- End;
-
- (*********************************************************************)
- Procedure SetTime(VAR time:MeasureTime; M,P : WORD);
- (*********************************************************************)
- Begin
- time.Measure:=M ;
- time.MPart:=P;
- End;
-
- (********************************************************)
- Procedure DisplayLicense;
- (********************************************************)
- VAR
- f : File;
- T : Longint;
- DT : DateTime; (* defined in DOS unit *)
- Begin
- WriteLn('********************************************************');
- Write('* Midi2TeX translator ',version);
- {$IFDEF PC}
- Write(' of ');
- Assign(f,ParamStr(0));
- GetFTime(f,T);
- UnPackTime(T,DT);
- With DT Do WriteLn(Day,'-',Month,'-',Year,',',Hour,':',Min);
- {$ENDIF}
- {$IFDEF ST} WriteLn(' *'); {$ENDIF}
- WriteLn('* author: H.J.P. Kuykens *');
- WriteLn('********************************************************');
- End;
-
- (**************************************************)
- FUNCTION FileExists (Filename : STRING) : BOOLEAN;
- (**************************************************)
- VAR
- f : FILE;
- BEGIN
- {$I-}
- {$IFDEF PC}
- ASSIGN (f, FileName);
- RESET (f);
- {$ENDIF}
- {$IFDEF ST}
- RESET (f,FileName);
- {$ENDIF}
- CLOSE (f);
- {$I+}
- FileExists := (IORESULT = 0) AND (FileName <> '');
- END; { FileExists}
-
- Begin
- End.