-
Notifications
You must be signed in to change notification settings - Fork 5
/
AMIGADOS.PAS
1309 lines (1219 loc) · 31.9 KB
/
AMIGADOS.PAS
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{ @author: Sylvain Maltais ([email protected])
@created: 2021
@website(https://www.gladir.com/corail)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program AMIGADOS;
Uses {$IFDEF FPC}
Crt,DOS,PtcGraph,PtcCrt,PtcMouse
{$ELSE}
Crt,DOS,Graph
{$ENDIF};
Const
CommandList:Array[0..51]of String[20]=(
'ADDBUFFERS','ALINK','ASSEM','ASSIGN','BINDDRIVERS','BREAK',
'CD','CHANGETASKPRI','COPY','DATE','DELETE','DIR',
'DISKCHANGE','DISKCOPY','DISKDOCTOR','DOWNLOAD','ECHO',
'ED','EDIT','ENDCLI','EXECUTE','FAILAT','FAULT','FILENOTE',
'FORMAT','IF','INFO','INSTALL','JOIN','LAB','LIST','MAKEDIR',
'MOUNT','NEWCLI','PATH','PROMPT','PROTECT','QUIT','READ',
'RELABEL','RENAME','RUN','SEARCH','SETDATE','SETMAP','SKIP',
'SORT','STACK','STATUS','TYPE','WAIT','WHY'
);
Var
Language:(_French,_English,_Germany,_Italian,_Spain);
TmpLanguage:String;
InGraph:Boolean;
MaxX:Word;
Echo:Boolean;
CommandFound,Terminated:Boolean;
CmdStr:String;
CurrCommand,ParamList:String;
I,J:Byte;
XPos,YPos,MinLine,MaxLine,MinColumn,MaxColumn:Byte;
Function PadRight(S:String;Space:Byte):String;
Var
I:Byte;
Begin
If Length(S)<Space Then For I:=Length(S)+1 to Space do S:=S+' ';
PadRight:=S;
End;
Function PadZeroLeft(Value:Integer;Space:Byte):String;
Var
S:String;
Begin
Str(Value,S);
While Length(S)<Space do S:='0'+S;
PadZeroLeft:=S;
End;
Function TrimL(S:String):String;
Var
I:Byte;
Begin
For I:=1to Length(S)do Begin
If S[I]<>' 'Then Begin
TrimL:=Copy(S,I,255);
Exit;
End;
End;
TrimL:=S;
End;
Function StrToUpper(S:String):String;
Var
I:Byte;
Begin
For I:=1 to Length(S)do Begin
If S[I] in['a'..'z']Then S[I]:=Chr(Ord(S[I])-32);
End;
StrToUpper:=S;
End;
Function IntToStr(I:Integer):String;
Var
S:String;
Begin
Str(I,S);
IntToStr:=S;
End;
Function IntToStrPad(I,Pad:Integer):String;
Var
S:String;
Begin
Str(I:Pad,S);
IntToStrPad:=S;
End;
Procedure ChangeChar(Var Str:String;OldChar,NewChar:Char);
Var
I:Byte;
Begin
For I:=1 to Length(Str)do Begin
If Str[I]=OldChar Then Str[I]:=NewChar;
End;
End;
Procedure ShowCursor;Begin
SetFillStyle(SolidFill,Brown);
Bar(XPos*8,YPos*8,XPos*8+TextWidth(' '),YPos*8+TextHeight(' '));
End;
Procedure HideCursor;Begin
SetFillStyle(SolidFill,1);
Bar(XPos*8,YPos*8,XPos*8+TextWidth(' '),YPos*8+TextHeight(' '));
End;
Procedure ScrollWindow;
Var
Size:Word;
P:Pointer;
J:Integer;
Begin
Size:=ImageSize(MinColumn*8,MinLine*8,(MaxColumn+1)*8-1,(MinLine+1)*8-1);
GetMem(P,Size);
For J:=MinLine+1 to MaxLine do Begin
GetImage(MinColumn*8,J*8,(MaxColumn+1)*8-1,(J+1)*8-1,P^);
PutImage(MinColumn*8,(J-1)*8,P^,NormalPut);
End;
FreeMem(P,Size);
SetFillStyle(SolidFill,1);
Bar(MinColumn*8,MaxLine*8,(MaxColumn+1)*8+1,(MaxLine+1)*8+1);
End;
Procedure WriteChar(C:Char);Begin
If(InGraph)Then Begin
OutTextXY(XPos*8,YPos*8,C);
Inc(XPos);
End
Else
Write(C);
End;
Procedure ClearEOL;Begin
If(InGraph)Then Begin
SetFillStyle(SolidFill,1);
Bar(XPos*8,YPos*8,(MaxColumn+1)*8+1,YPos*8+TextHeight('COMMAND'));
End
Else
ClrEOL;
End;
Procedure WriteXY(X,Y:Byte;S:String);Begin
If(InGraph)Then Begin
XPos:=X;YPos:=Y;
SetFillStyle(SolidFill,1);
Bar(XPos*8,YPos*8,XPos*8+TextWidth(S),YPos*8+TextHeight(S));
OutTextXY(XPos*8,YPos*8,S);
Inc(XPos,Length(S));
If XPos>MaxColumn Then Begin
XPos:=MinColumn;
If(YPos<MaxLine)Then Inc(YPos)
Else ScrollWindow;
End;
End
Else
Begin
GotoXY(X,Y);
Write(S);
End;
End;
Procedure WriteLineXY(X,Y:Byte;S:String);Begin
If(InGraph)Then Begin
XPos:=X;YPos:=Y;
SetFillStyle(SolidFill,1);
Bar(XPos*8,YPos*8,XPos*8+TextWidth(S),YPos*8+TextHeight(S));
OutTextXY(XPos*8,YPos*8,S);
XPos:=MinColumn;
If(YPos<MaxLine)Then Inc(YPos)
Else ScrollWindow;
End
Else
Begin
GotoXY(X,Y);
WriteLn(S);
End;
End;
Procedure WriteStr(S:String);Begin
If(InGraph)Then Begin
SetFillStyle(SolidFill,1);
If(XPos+Length(S)>MaxColumn)Then Begin
Bar(XPos*8,YPos*8,XPos*8+TextWidth(Copy(S,1,MaxColumn-XPos+1)),YPos*8+TextHeight(S));
OutTextXY(XPos*8,YPos*8,Copy(S,1,MaxColumn-XPos+1));
S:=Copy(S,MaxColumn-XPos+1,255);
End
Else
Begin
Bar(XPos*8,YPos*8,XPos*8+TextWidth(S),YPos*8+TextHeight(S));
OutTextXY(XPos*8,YPos*8,S);
End;
Inc(XPos,Length(S));
If XPos>MaxColumn Then Begin
XPos:=MinColumn;
If(YPos<MaxLine)Then Inc(YPos)
Else ScrollWindow;
End;
End
Else
Begin
Write(S);
End;
End;
Procedure WriteLine(S:String);Begin
If(InGraph)Then Begin
If(XPos+Length(S)>MaxColumn)Then Begin
WriteLineXY(XPos,YPos,Copy(S,1,MaxColumn-XPos+1));
S:=Copy(S,MaxColumn-XPos+1,255);
XPos:=MinColumn;
If(YPos<MaxLine)Then Inc(YPos)
Else ScrollWindow;
WriteLineXY(XPos,YPos,S);
End
Else
WriteLineXY(XPos,YPos,S);
XPos:=MinColumn;
If(YPos<MaxLine)Then Inc(YPos)
Else ScrollWindow;
End
Else
WriteLn(S);
End;
Procedure InitScr;
Var
Driver,Mode:Integer;
ErrCode:Integer;
Begin
{$IFDEF FPC}
Driver:=VGA;
Mode:=VGAHi;
{$ELSE}
Driver:=Detect;
Mode:=VGAHi;
{$ENDIF}
InitGraph(Driver,Mode,'');
ErrCode:=GraphResult;
If ErrCode=grOk Then Begin
SetColor(White);
SetLineStyle(0, 0, 1);
End
Else
Begin
WriteLn('Erreur graphique : ',GraphErrorMsg(ErrCode));
Halt;
End;
SetBkColor(1);
ClearDevice;
SetRGBPalette(1,$46,$82,$B4);
End;
Procedure ShowAmigaWindow(X1,Y1,X2,Y2:Byte;Title:String);Begin
Dec(X1);
Dec(Y1);
Inc(X2);
Inc(Y2);
SetFillStyle(SolidFill,White);
Bar(X1*8,Y1*8,(X2+1)*8-1,(Y1+1)*8-1);
Rectangle(X1*8,Y1*8,(X2+1)*8-1,(Y2+1)*8-1);
SetFillStyle(SolidFill,1);
Bar((X1+Length(Title)+1)*8,Y1*8+1,(X2+1)*8-2,Y1*8+2);
Bar((X1+Length(Title)+1)*8,Y1*8+5,(X2+1)*8-2,Y1*8+6);
SetColor(1);
OutTextXY((X1+1)*8,Y1*8,Title);
SetColor(White);
End;
Function GetCurrentDisk:Char;
Var
CurrentDir:String;
Begin
GetDir(0,CurrentDir);
GetCurrentDisk:=CurrentDir[1];
End;
Function GetCurrentDiskAmiga:String;
Var
Tmp:String;
Begin
Case GetCurrentDisk of
'A':GetCurrentDiskAmiga:='DF0:';
'B':GetCurrentDiskAmiga:='DF1:';
Else Begin
Str((Ord(GetCurrentDisk)-Ord('A')-2),Tmp);
GetCurrentDiskAmiga:='HD'+Tmp+':';
End;
End;
End;
Function Path2Drive(Path:String):Char;Begin
Path:=FExpand(Path);
Path2Drive:=Path[1];
End;
Function Path2Ext(Const Path:String):String;
Var
D:DirStr;
N:NameStr;
E:ExtStr;
Begin
FSplit(Path,D,N,E);
Path2Ext:=E;
End;
Function GetDiskLabel(Dsk:Byte):String;
Var
Info:SearchRec;
CurrentDir:String;
Begin
If Dsk=0Then GetDir(0,CurrentDir)
Else CurrentDir:=Char(Dsk+64);
FindFirst(CurrentDir[1]+':\*.*',VolumeID,Info);
While DosError=0do Begin
If(Info.Attr = VolumeID)Then Begin
GetDiskLabel:=Info.Name;
Exit;
End;
FindNext(Info);
End;
GetDiskLabel:=''
End;
Function CopyFile(Source,Target:String;ShowProgression:Boolean):Boolean;
Var
SourceFile,TargetFile:File;
RecordsRead:Integer;
Buffer:Array[1..1000]of Byte;
Begin
CopyFile:=False;
Assign(SourceFile,Source);
{$I-}Reset(SourceFile,1);{$I+}
If IOResult<>0Then Begin
WriteLn('Fichier source introuvable ',Source);
Exit;
End;
Assign(TargetFile,Target);
{$I-}Rewrite(TargetFile,1);
If(ShowProgression)Then WriteLn('. = 1000 octets de copies');
BlockRead(SourceFile,Buffer,SizeOf(Buffer),RecordsRead);
While RecordsRead>0 do Begin
If(ShowProgression)Then Write('.');
BlockWrite(TargetFile,Buffer,RecordsRead);
BlockRead(SourceFile,Buffer,SizeOf(Buffer),RecordsRead);
End;
If(ShowProgression)Then WriteLn;
Close(SourceFile);
Close(TargetFile);
{$I+}
CopyFile:=True;
End;
Function GetErrorMessage(Code:Word):String;Begin
Case Code of
0:GetErrorMessage:='';
2:GetErrorMessage:='Fichier introuvable';
3:GetErrorMessage:='Chemin introuvable';
4:GetErrorMessage:='Trop de fichiers ouvert';
5:GetErrorMessage:='Acces refuse';
6:GetErrorMessage:='Handle de fichier invalide';
12:GetErrorMessage:='Mode d''acces sur disque invalide';
15:GetErrorMessage:='Num‚ro de disque invalide';
16:GetErrorMessage:='Impossible de supprimer le r‚pertoire';
17:GetErrorMessage:='Impossible de renommer sur plusieurs volumes';
100:GetErrorMessage:='Erreur de lecture … partir du disque';
101:GetErrorMessage:='Erreur d''ecriture sur le disque';
102:GetErrorMessage:='Fichier non attribue';
103:GetErrorMessage:='Le fichier n''est pas ouvert';
104:GetErrorMessage:='Le fichier n''est pas ouvert … l''entree';
105:GetErrorMessage:='Le fichier n''est pas ouvert … la sortie';
106:GetErrorMessage:='Numero invalide';
150:GetErrorMessage:='Disque protege en ecriture';
151:GetErrorMessage:='Peripherique est inconnu';
152:GetErrorMessage:='Disque pas pret';
153:GetErrorMessage:='Commande inconnue';
154:GetErrorMessage:='Echec de verification CRC';
155:GetErrorMessage:='Disque invalide';
156:GetErrorMessage:='Erreur de recherche sur disque';
157:GetErrorMessage:='Type de media invalide';
158:GetErrorMessage:='Secteur introuvable';
159:GetErrorMessage:='L''imprimante n''a plus de papier';
160:GetErrorMessage:='Erreur d''ecriture sur le peripherique';
161:GetErrorMessage:='Erreur de lecture sur le peripherique';
162:GetErrorMessage:='Defaillance materielle';
Else GetErrorMessage:='Erreur inconnue';
End;
End;
Procedure ExtractCommand;
Var
I:Byte;
Begin
For I:=1 to Length(CmdStr)do Begin
If Not(CmdStr[I]in['A'..'Z','a'..'z','_','-','0'..'9'])Then Begin
CurrCommand:=StrToUpper(Copy(CmdStr,1,I-1));
ParamList:=TrimL(Copy(CmdStr,I,255));
Exit;
End;
End;
CurrCommand:=StrToUpper(CmdStr);
ParamList:='';
End;
Function ExtractParam(Index:Byte):String;
Var
Count:Word;
LocalIndex:Word;
l:Byte;
Temp:String;
Begin
Temp:='';Count:=1;LocalIndex:=1;l:=0;
While Count<=Length(ParamList)do Begin
If Not(ParamList[Count] in [' ',#9])then Begin
If LocalIndex=Index Then Begin
While (Count<=Length(ParamList)) and (Not(ParamList[count] in[' ',#9])) and (l < 256) do Begin
Temp:=Temp+ParamList[count];
Inc(l);
Inc(Count);
end;
Temp[0]:=Char(l);
ExtractParam:=Temp;
Exit;
End;
While (Count<=Length(ParamList)) and (Not(ParamList[count] in [' ',#9])) do Inc(Count);
Inc(LocalIndex);
End;
If Count>=Length(ParamList)Then Break;
Inc(Count);
End;
ExtractParam:=Temp;
End;
Procedure HomeMessage;Begin
TextColor(Blue);
TextBackground(7);
WriteLine('');
WriteLine('AmigaShell/AmigaDOS');
WriteLine('');
End;
Procedure ShowPrompt;
Const Week:Array[0..6]of String[3]=('Dim','Lun','Mar','Mer','Jeu','Ven','Sam');
Mon:Array[1..12]of String[3]=('Jan','Fev','Mar','Avr','Mai','Jui',
'Jul','Aou','Sep','Oct','Nov','Dec');
Var
SP,CurrentDir:String;
I:Byte;
Year,Month,Day,DayOfWeek,Hour,Min,Sec,Sec100:Word;
Begin
If Not(Echo)Then Exit;
GetDir(0,CurrentDir);
SP:=GetEnv('PROMPT');
If SP=''Then SP:='$P$G';
I:=1;
While I<=Length(SP)do Begin
If SP[I]='$'Then Begin
Inc(I);
Case SP[I] of
'D': Begin
GetDate(Year,Month,Day,DayOfWeek);
WriteStr(Week[DayOfWeek]+' '+Mon[Month]+
IntToStr(Day)+','+IntToStr(Year));
End;
'T': Begin
GetTime(Hour,Min,Sec,Sec100);
WriteStr(IntToStr(Hour)+':'+IntToStr(Min)+':'+IntToStr(Sec));
End;
'B' : WriteStr('|');
'e','E' : WriteStr(#27);
'g','G' : WriteStr('>');
'N' : WriteStr(GetCurrentDiskAmiga);
'p','P' : Begin
GetDir(0,CurrentDir);
If CurrentDir[2]=':'Then Begin
CurrentDir:=Copy(CurrentDir,3,255);
End;
CurrentDir:=GetCurrentDiskAmiga+CurrentDir;
ChangeChar(CurrentDir,'\','/');
WriteStr(CurrentDir);
End;
'-','S' : WriteStr(' ');
'V' : WriteStr(IntToStr(Lo(DosVersion))+'.'+IntToStr(Hi(DosVersion)));
'_','Z' : WriteStr(#13#10);
'z' : WriteStr('?');
End;
End
Else
Write(SP[I]);
Inc(I);
End;
End;
Procedure InvalidParam(P:Byte);Begin
WriteLine('Le parametre suivant est invalide : '+ExtractParam(P));
End;
Procedure ADDBUFFERSCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure ALINKCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure ASSEMCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure ASSIGNCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure BINDDRIVERSCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure BREAKCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure CDCommand;
Var
Error:Word;
FirstParam,Dir:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
WriteLine('CD Cette commande permet de fixer ou de demander le repertoire courant.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('CD [/?] chemin');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLine(' chemin Ce parametre permet d''indiquer le chemin du repertoire.');
End
Else
If Length(FirstParam)>0Then Begin
{$I-} ChDir(FirstParam);{$I+}
Error:=IoResult;
If Error<>0Then WriteLine(GetErrorMessage(Error));
End
Else
Begin
GetDir(0,Dir);
WriteLine(Dir);
End;
End;
Procedure CHANGETASKPRICommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure COPYCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure DATECommand;
Const
DOW:Array[0..6]of String[10]=(
'Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'
);
Mon:Array[1..12]of String[3]=('Jan','Fev','Mar','Avr','Mai','Jui',
'Jul','Aou','Sep','Oct','Nov','Dec');
Var
FirstParam:String;
Year,Month,Day,DayOfWeek:Word;
Hour,Minute,Second,CentSec:Word;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
WriteLine('DATE Cette commande permet de fixer ou de demander la date du systeme d''exploitation');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('DATE [/?]');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
End
Else
Begin
GetDate(Year,Month,Day,DayOfWeek);
WriteStr(DOW[DayOfWeek]+' ');
WriteStr(IntToStrPad(Day,2)+'-'+Mon[Month]+'-'+Copy(PadZeroLeft(Year,4),3,2)+' ');
GetTime(Hour,Minute,Second,CentSec);
WriteLine(IntToStrPad(Hour,2)+':'+PadZeroLeft(Minute,2)+':'+PadZeroLeft(Second,2));
End;
End;
Procedure DELETECommand;
Var
P:Byte;
Err:Word;
F:File;
CurrParam:String;
Begin
P:=0;
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If CurrParam=''Then Begin
If P=1Then Begin
WriteLine('ParamŠtre requis');
End;
Break;
End
Else
If CurrParam='/?'Then Begin
WriteLine('DELETE Cette commande permet d''effectuer la suppression de fichier sur un unite de disque.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('DELETE [/?] fichier');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLine(' fichier Ce parametre permet d''indiquer le nom du fichier a supprimer.');
Exit;
End;
{$I-}Assign(F,CurrParam);
Erase(F);
{$I+}
Err:=IoResult;
If Err=0Then WriteLine('1 fichier de supprime')
Else WriteLine(GetErrorMessage(Err));
If P>9Then Break;
Until CurrParam='';
End;
Procedure DirCommand;
Var
P:Byte;
Info:SearchRec;
T:DateTime;
CurrParam,ShowDir:String;
Begin
P:=0;
ShowDir:='*.*';
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If Length(CurrParam)=0Then Break;
If CurrParam='/?'Then Begin
WriteLine('DIR Cette commande permet d''afficher le contenu d''un repertoire dans l''unite de disque.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('DIR [/?] [nom]');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
Exit;
End
Else
ShowDir:=CurrParam;
If P>99Then Break;
Until CurrParam='';
P:=0;
FindFirst(ShowDir,AnyFile,Info);
While DOSError=0 do Begin
If(Info.Attr and Directory=Directory)Then Begin
If(Info.Name<>'..')and(Info.Name<>'.')Then Begin
WriteStr(' '+' '+' '+' '+' '+PadRight(Info.Name+' (dir)',35));
End;
End
Else
WriteStr(' '+PadRight(Info.Name,38));
FindNext(Info);
End;
WriteLine('');
End;
Procedure DISKCHANGECommand;
Var
Letter:Char;
CurrParam:String;
Begin
CurrParam:=ExtractParam(1);
If CurrParam='/?'Then Begin
WriteLine('DISKCHANGE Cette commande permet de changer l''unit‚ de disque courant.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('DISKCHANGE [/?] [dr]');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLine('dr Ce paramŠtre permet d''indiquerle nouvel unit‚ de disque');
End
Else
If(Length(CurrParam)=4)and(CurrParam[4]=':')Then Begin
Letter:='@';
If StrToUpper(CurrParam)='DF0:'Then Letter:='A' Else
If StrToUpper(CurrParam)='DF1:'Then Letter:='B' Else
If StrToUpper(Copy(CurrParam,1,2))='HD'Then Begin
Letter:=Chr(Ord('C')+(Ord(UpCase(CurrParam[3]))-Ord('0')));
End
Else
Begin
WriteLine('Disque invalide !');
Exit;
End;
If Letter='@'Then Begin
WriteLine('Disque non reconnu !');
Exit;
End;
{$I-}ChDir(Letter+':\');{$I+}
If IoResult<>0 Then Begin
WriteLine('Impossible de changer d''unit‚ de disque.');
Exit;
End;
End;
End;
Procedure DISKCOPYCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure DISKDOCTORCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure DOWNLOADCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure EchoCommand;
Var
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
WriteLine('ECHO Cette commande permet d''activer ou desactiver le prompt de commande '+
'ou d''afficher un message sur le console du systeme d''exploitation.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('ECHO [/?] message');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLine(' message Ce parametre permet d''afficher un message');
End
Else
If ParamList='.'Then WriteLine('')
Else WriteLine(ParamList);
End;
Procedure EDCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure EDITCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure ENDCLICommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure EXECUTECommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure FAILATCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure FAULTCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure FILENOTECommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure FORMATCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure IFCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure INFOCommand;
Var
I:Char;
Dsk:Byte;
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
WriteLine('INFO Cette commande permet de demander des informations sur '+
'l''etat du systeme d''exploitation.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('INFO [/?]');
WriteLine('');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
End
Else
Begin
WriteLine('');
WriteLine('Unite Taille Utilise Libre Plein Erreurs Etat Nom');
For I:='A' to 'Z' do Begin
Dsk:=Ord(I)-Ord('A');
If DiskSize(Dsk+1)<>-1Then Begin
Case I of
'A':WriteStr('DF0:');
'B':WriteStr('DF1:');
Else Begin
WriteStr('DH'+IntToStr(Dsk-2)+':');
If Dsk<12Then WriteStr(' ');
End;
End;
If DiskSize(Dsk+1)>1073741824Then Write(DiskSize(Dsk+1) shr 30:9,'G')Else
If DiskSize(Dsk+1)>1048576Then Write(DiskSize(Dsk+1) shr 20:9,'M') Else
If DiskSize(Dsk+1)>1024Then Write(DiskSize(Dsk+1) shr 10:9,'K')
Else Write(DiskSize(Dsk+1):10);
If(DiskSize(Dsk+1)-DiskFree(Dsk+1)>1073741824)Then Write((DiskSize(Dsk+1)-DiskFree(Dsk+1)) shr 30:10) Else
If(DiskSize(Dsk+1)-DiskFree(Dsk+1)>1048576)Then Write((DiskSize(Dsk+1)-DiskFree(Dsk+1))shr 20:10)
Else Write((DiskSize(Dsk+1)-DiskFree(Dsk+1)) shr 10:10);
If DiskFree(Dsk+1)>1073741824Then Write(DiskFree(Dsk+1) shr 30:10)Else
If DiskFree(Dsk+1)>1048576Then Write(DiskFree(Dsk+1) shr 20:10) Else
If DiskFree(Dsk+1)>1024Then Write(DiskFree(Dsk+1) shr 10:10)
Else Write(DiskFree(Dsk+1):10);
WriteStr(IntToStrPad(Trunc(((DiskSize(Dsk+1)-DiskFree(Dsk+1))/DiskSize(Dsk+1))*100),6)+'%');
WriteStr(' '+IntToStr(0)+' ');
WriteStr('Lecture/Ecriture ');
WriteStr(GetDiskLabel(Dsk+1));
WriteLine('');
End;
End;
End;
End;
Procedure INSTALLCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure JOINCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure LABCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure LISTCommand;
Const
Mon:Array[1..12]of String[3]=('Jan','Fev','Mar','Avr','Mai','Jui',
'Jul','Aou','Sep','Oct','Nov','Dec');
Var
Option:Set of (QUICK);
I:Integer;
Info:SearchRec;
Path:String;
T:DateTime;
NumFiles,NumDirectories:LongInt;
Begin
If(ExtractParam(1)='--help')or(ExtractParam(1)='-h')Then Begin
WriteLine('LIST : Cette commande permet d''afficher les fichiers d''un r‚pertoire.');
WriteLine('');
WriteLine('Syntaxe : LIST [-l] [-s] [-t] [<repertoire>]');
End
Else
Begin
NumFiles:=0;
NumDirectories:=0;
Option:=[];
Path:='*.*';
I:=1;
While I<10 do Begin
If ExtractParam(I)=''Then Break Else
If StrToUpper(ExtractParam(I))='QUICK'Then Include(Option,Quick)
Else Path:=ExtractParam(I);
Inc(I);
End;
FindFirst(Path,AnyFile,Info);
While DosError=0 do Begin
If Not((Info.Name='.')or(Info.Name='..'))Then Begin
If(Info.Attr and Directory=Directory)Then Inc(NumDirectories)
Else Inc(NumFiles);
WriteStr(PadRight(Info.Name,40));
If Not((Quick)in(Option))Then Begin
If(Info.Attr and Directory=Directory)Then Begin
WriteStr('Dir'+' '+' ');
End
Else
WriteStr(IntToStrPad((Info.Size shr 9)+Byte((Info.Size and$1FF)>0),10)+' ');
WriteStr('----r');
If(Info.Attr and ReadOnly=ReadOnly)Then Write('-')
Else Write('w');
If Path2Ext(Info.Name)='.EXE'Then Write('e')
Else Write('-');
If(Info.Attr and Directory=Directory)Then Write('d')
Else Write('-');
Write(' ');
UnpackTime(Info.Time,T);
WriteStr(' '+IntToStrPad(T.Day,2)+'-'+Mon[T.Month]+'-'+
Copy(PadZeroLeft(T.Year,2),3,2));
WriteStr(' '+IntToStrPad(T.Hour,2)+':'+PadZeroLeft(T.Min,2)+' ');
End;
WriteLine('');
End;
FindNext(Info);
End;
WriteLine(IntToStr(NumFiles)+' fichiers - '+
IntToStr(NumDirectories)+' r‚pertoires');
End;
End;
Procedure MAKEDIRCommand;
Var
P:Byte;
Err:Word;
CurrParam:String;
Begin
P:=0;
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If CurrParam=''Then Begin
If P=1Then Begin
WriteLine('ParamŠtre requis');
End;
Break;
End
Else
If CurrParam='/?'Then Begin
WriteLine('MAKEDIR Cette commande permet de creer un repertoire.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('MAKEDIR [/?] nomrepertoire');
WriteLine('');
WriteLine(' nomrepertoire Ce parametre permet d''indiquer le nom du repertoire');
WriteLine(' /? Ce parametre permet d''afficher l''aide sur cette commande');
Exit;
End;
{$I-}MkDir(CurrParam);{$I+}
Err:=IoResult;
If Err<>0Then WriteLine(GetErrorMessage(Err));
If P>9Then Break;
Until CurrParam='';
End;
Procedure MOUNTCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure NEWCLICommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');
End;
Procedure PATHCommand;
Var
I:Integer;
P:Byte;
PATH,TPath,CurrParam:String;
Begin
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If Length(CurrParam)=0Then Break;
If CurrParam='/?'Then Begin
WriteLine('PATH Cette commande permet de ger les chemins d''acces par defaut.');
WriteLine('');
WriteLine('Syntaxe:');
WriteLine('');
WriteLine('PATH [/?] [SHOW]');
WriteLine('');
WriteLine('Parametres');
WriteLine('');
WriteLine(' SHOW Affiche la liste des repertoires a rechercher');
End
Else
If StrToUpper(CurrParam)='SHOW'Then Begin
PATH:=GetEnv('PATH');
TPath:='';
For I:=1 to Length(PATH)do Begin
If PATH[I]=';'Then Begin
WriteLine(TPath);
TPath:='';
End
Else
TPath:=TPath+Path[I];
End;
WriteLine(TPath);
End;
If P>99Then Break;
Until CurrParam='';
End;
Procedure PROMPTCommand;Begin
WriteLine('Cette commande n''est pas mise en oeuvre');