-
Notifications
You must be signed in to change notification settings - Fork 5
/
4DOS.PAS
3258 lines (3131 loc) · 77.5 KB
/
4DOS.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: 2022
@website(https://www.gladir.com/corail)
@abstract(Target: Turbo Pascal, Free Pascal)
}
Program _4DOS;
{$M 8192,0,16384}
Uses Crt,DOS;
Const
CommandList:Array[0..81]of String[8]=(
'ALIAS','ATTRIB','BEEP','BREAK','CALL','CD','CDD','CHCP','CHDIR',
'CLS','COLOR','COPY','CTTY','DATE','DEL','DELAY','DELETE',
'DESCRIBE','DIR','DIRS','DRAWBOX','DRAWHLINE','DRAWVLINE','ECHO',
'ENDLOCAL','ENDTEXT','ERA','ERASE','ESET','EXCEPT','EXIT','FOR','FREE',
'GLOBAL','GOSUB','GOTO','HELP','HISTORY','IF','IFF','INKEY',
'INPUT','KEYSTACK','LH','LOADBTM','LOADHIGH','LOG','MD','MEMORY',
'MKDIR','MOVE','PATH','PAUSE','PROMPT','PUSHD','QUIT','RD','REM',
'REN','RENAME','RETURN','RMDIR','SCREEN','SCRPUT','SET','SETDOS',
'SETLOCAL','SHIFT','SWAPPING','TEE','TEXT','TIME','TIMER','TRUENAME',
'TYPE','UNALIAS','UNSET','VER','VERIFY','VOL','Y','POPD'
);
MaxHistory=100;
MaxStackDirectory=50;
Type
StrPointer=^String;
Var
Language:(_French,_English,_Germany,_Italian,_Spain);
TmpLanguage:String;
ShowASCII128,Pipe,PipeToCommand:Boolean;
PipeFile:Text;
AttrAdd,AttrRemove:Word;
SubDirectory:Boolean;
InCmd:Byte;
Option:(optNone,optCommand);
History:Array[1..MaxHistory] of StrPointer;
StackDirectory:Array[1..MaxStackDirectory] of StrPointer;
NumberHistory,NumberDirectory:Integer;
Echo:Boolean;
CommandFound,Terminated:Boolean;
CmdStr:String;
CurrCommand,ParamList,PipeCommand:String;
I,J:Byte;
Procedure RunCommand;Forward;
Procedure PCopy(Source,Target:Byte);Begin
{$IFNDEF FPC}
Move(Mem[SegB800:Source*(MemW[$0040:$4A]*25*2)],Mem[SegB800:Target*(MemW[$0040:$4A]*25*2)],MemW[$0040:$4A]*25*2)
{$ENDIF}
End;
Function GetConvMemory:Word;
Var
Regs:Registers;
Begin
Regs.AX:=0;
Intr($12,Regs);
GetConvMemory:=Regs.AX;
End;
Function GetFreeMemory:LongInt;
Var
Regs:Registers;
Begin
Regs.AH:=$48;
Regs.BX:=$FFFF;
Intr($21,Regs);
GetFreeMemory:=LongInt(Regs.AX)*16;
End;
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 TrimR(s:String):String;
Var
i:Integer;
Begin
i:=Length(s);
While (i>0)and(s[i]in[#9,' '])do Dec(i);
s[0]:=Chr(i);
TrimR:=S;
End;
Function Trim(s:String):String;Begin
Trim:=TrimL(TrimR(s));
End;
Function StrToLower(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;
StrToLower:=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 DuplicateString(C:Char;Num:Integer):String;
Var
I:Byte;
S:String;
Begin
S:='';
For I:=1 to Num do S:=S+C;
DuplicateString:=S;
End;
Function GetCurrentDisk:Char;
Var
CurrentDir:String;
Begin
GetDir(0,CurrentDir);
GetCurrentDisk:=CurrentDir[1];
End;
Function FileExist(Name:String):Boolean;
Var
Rec:SearchRec;
Begin
FindFirst(Name,AnyFile,Rec);
FileExist:=DosError=0;
End;
Function Path2Drive(Path:String):Char;Begin
Path:=FExpand(Path);
Path2Drive:=Path[1];
End;
Function Path2Dir(S:String):String;
Var
D:DirStr;
N:NameStr;
E:ExtStr;
Begin
FSplit(S,D,N,E);
Path2Dir:=D;
End;
Function SplitFileName(s:String):String;
Var
D:DirStr;
N:NameStr;
E:ExtStr;
Begin
FSplit(S,D,N,E);
Splitfilename:=N+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;
Procedure Box(X1,Y1,X2,Y2,Couleur:Byte);Begin
Window(X1,Y1,X2,Y2);
TextBackground((Couleur shr 4)and 15);
{$IFDEF FPC}
If Couleur and $80=$80 Then Begin
TextColor((Couleur and 15)+BLINK);
End
Else
TextColor(Couleur and 15);
{$ELSE}
TextColor(Couleur and 15);
{$ENDIF}
ClrScr;
Window(1,1,80,25);
End;
Procedure FrameEmpty(X1,Y1,X2,Y2,Couleur:Byte);
Var
I:Byte;
ChrHori,ChrVert:Char;
Chr218,Chr192,Chr191,Chr217:Char;
Begin
TextBackground((Couleur shr 4)and 15);
TextColor(Couleur and 15);
If(ShowASCII128)Then Begin
ChrHori:='-';
ChrVert:='|';
Chr218:='+';
Chr192:='+';
Chr191:='+';
Chr217:='+';
End
Else
Begin
ChrHori:=#$C4;
ChrVert:=#$B3;
Chr218:=#218;
Chr192:=#192;
Chr191:=#191;
Chr217:=#217;
End;
For I:=Y1+1 to Y2-1 do Begin
GotoXY(X1,I);
Write(ChrVert);
GotoXY(X2,I);
Write(ChrVert);
End;
GotoXY(X1+1,Y1);
Write(DuplicateString(ChrHori,X2-X1-1));
GotoXY(X1+1,Y2);
Write(DuplicateString(ChrHori,X2-X1-1));
GotoXY(X1,Y1);
Write(Chr218);
GotoXY(X1,Y2);
Write(Chr192);
GotoXY(X2,Y1);
Write(Chr191);
GotoxY(X2,Y2);
Write(Chr217);
End;
Function AddHistory(S:String):Boolean;
Var
I:Word;
P:StrPointer;
Begin
If NumberHistory>=MaxHistory Then Begin
FreeMem(History[1],Length(History[1]^)+1);
For I:=1 to MaxHistory-1 do History[I]:=History[I+1];
GetMem(P,Length(S)+1);
P^:=S;
History[MaxHistory]:=P;
AddHistory:=True;
Exit;
End
Else
Begin
Inc(NumberHistory);
GetMem(P,Length(S)+1);
P^:=S;
History[NumberHistory]:=P;
AddHistory:=True;
End;
End;
Procedure FreeHistory;
Var
I:Word;
Begin
For I:=1 to NumberHistory do FreeMem(History[I],Length(History[I]^)+1);
FillChar(History,SizeOf(History),0);
NumberHistory:=0;
End;
Function PushDirectory(Directory:String):Boolean;
Var
P:StrPointer;
Begin
If NumberDirectory>=MaxStackDirectory Then Begin
WriteLn('Pile de r‚pertoire pleine');
PushDirectory:=False;
Exit;
End;
Inc(NumberDirectory);
GetMem(P,Length(Directory)+1);
P^:=Directory;
StackDirectory[NumberDirectory]:=P;
PushDirectory:=True;
End;
Function PopDirectory:String;Begin
PopDirectory:='';
If NumberDirectory>0Then Begin
PopDirectory:=StackDirectory[NumberDirectory]^;
FreeMem(History[NumberDirectory],Length(History[NumberDirectory]^)+1);
Dec(NumberDirectory);
End;
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 MoveFile(Source,Target:String):Boolean;
Var
F:File;
Begin
If(Source='')or(Target='')Then Begin
MoveFile:=False;
Exit;
End;
Source:=FExpand(Source);
Target:=FExpand(Target);
If(Source[1]<>Target[1])and(Source[2]=':')Then Begin { Unite de disque different ?}
{ Copie le fichier }
MoveFile:=CopyFile(Source,Target,False);
{ Supprime le fichier }
{$I-}Assign(F,Source);
Erase(F);
{$I+}
End
Else
Begin
{$I-}
Assign(F,Source);
Rename(F,Target+'\'+SplitFileName(Source));
MoveFile:=IOResult=0;
{$I+}
End;
End;
Procedure SetAttribut(Var F:File);
Var
CurrAttr:Word;
Begin
GetFAttr(F,CurrAttr);
If AttrRemove and ReadOnly=ReadOnly Then CurrAttr:=CurrAttr and Not ReadOnly;
If AttrRemove and Archive=Archive Then CurrAttr:=CurrAttr and Not Archive;
If AttrRemove and Hidden=Hidden Then CurrAttr:=CurrAttr and Not Hidden;
If AttrRemove and SysFile=SysFile Then CurrAttr:=CurrAttr and Not SysFile;
If AttrAdd and ReadOnly=ReadOnly Then CurrAttr:=CurrAttr or ReadOnly;
If AttrAdd and Archive=Archive Then CurrAttr:=CurrAttr or Archive;
If AttrAdd and Hidden=Hidden Then CurrAttr:=CurrAttr or Hidden;
If AttrAdd and SysFile=SysFile THen CurrAttr:=CurrAttr or SysFile;
SetFAttr(F,CurrAttr);
End;
Procedure SetAttributFiles(FileSpec:String);
Var
Info:SearchRec;
CurrFile:File;
Found:Boolean;
Begin
FindFirst(FileSpec,AnyFile,Info);
Found:=False;
While DOSError=0 do Begin
Found:=True;
If Info.Attr and Directory=Directory Then Begin
{If(SubDirectory)Then SetAttributFiles(Info.Name+'\*.*');}
End
Else
Begin
Assign(CurrFile,Info.Name);
SetAttribut(CurrFile);
End;
FindNext(Info);
End;
If Not Found Then WriteLn('Aucun resultat trouve');
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:='AccŠs 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''‚criture 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''entr‚e';
105:GetErrorMessage:='Le fichier n''est pas ouvert … la sortie';
106:GetErrorMessage:='Num‚ro invalide';
150:GetErrorMessage:='Disque protege en ‚criture';
151:GetErrorMessage:='P‚riph‚rique est inconnu';
152:GetErrorMessage:='Disque pas prˆt';
153:GetErrorMessage:='Commande inconnue';
154:GetErrorMessage:='Echec de v‚rification CRC';
155:GetErrorMessage:='Disque invalide';
156:GetErrorMessage:='Erreur de recherche sur disque';
157:GetErrorMessage:='Type de m‚dia invalide';
158:GetErrorMessage:='Secteur introuvable';
159:GetErrorMessage:='L''imprimante n''a plus de papier';
160:GetErrorMessage:='Erreur d''‚criture sur le p‚ripherique';
161:GetErrorMessage:='Erreur de lecture sur le p‚ripherique';
162:GetErrorMessage:='D‚faillance mat‚rielle';
Else GetErrorMessage:='Erreur inconnue';
End;
End;
Procedure ExtractCommand;
Var
I,J: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));
For J:=1 to Length(ParamList)do Begin
Case ParamList[J]of
'|':Begin
If Not(Pipe)Then Begin
{$I-}Assign(PipeFile,'4DOSPIPE.TMP');
Rewrite(PipeFile);{$I-}
If IoResult<>0 Then Begin
WriteLn('Tuyau invalide !');
End;
Pipe:=True;
End;
PipeToCommand:=True;
PipeCommand:=TrimL(Copy(ParamList,J+1,255));
If J=1 Then ParamList:=''
Else ParamList:=Copy(ParamList,1,J-1);
End;
'>':Begin
If Not(Pipe)Then Begin
{$I-}Assign(PipeFile,TrimL(Copy(ParamList,J+1,255)));
Rewrite(PipeFile);{$I-}
If IoResult<>0 Then Begin
WriteLn('Tuyau invalide !');
End
Else
Pipe:=True;
End;
If J=1 Then ParamList:=''
Else ParamList:=Copy(ParamList,1,J-1);
End;
End;
End;
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
WriteLn;
Case Language of
_English:WriteLn('4DOS - Command interpreter');
_Germany:WriteLn('4DOS - Befehlsinterpreter');
_Italian:WriteLn('4DOS - Interprete di comando');
_Spain:WriteLn('4DOS - Int‚rprete de comando');
Else WriteLn('4DOS - Interpr‚teur de commande');
End;
WriteLn;
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);
Write(Week[DayOfWeek],' ',Mon[Month],Day,',',Year);
End;
'T': Begin
GetTime(Hour,Min,Sec,Sec100);
Write(Hour,':',Min,':',Sec);
End;
'B' : Write('|');
'e','E' : Write(#27);
'g','G' : Write('>');
'N' : Write(GetCurrentDisk);
'p','P' : Begin
GetDir(0,CurrentDir);
Write(StrToLower(CurrentDir));
End;
'-','S' : Write(' ');
'V' : Write(Lo(DosVersion),'.',Hi(DosVersion));
'_','Z' : Write(#13#10);
'z' : Write('?');
End;
End
Else
Write(SP[I]);
Inc(I);
End;
End;
Procedure InvalidParam(P:Byte);Begin
WriteLn('Le paramŠtre suivant est invalide : ',ExtractParam(P));
End;
Procedure AliasCommand;Begin
WriteLn('Cette commande n''est pas mise en oeuvre');
End;
Procedure AttribCommand;
Var
P:Integer;
Info:SearchRec;
IsAttrSetting:Array[Byte]of Boolean;
CurrParam:String;
Begin
CurrParam:=ExtractParam(1);
If ExtractParam(1)='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Change or view file and subdirectoryh attributes');
WriteLn;
WriteLn('Format: ATTRIB file [+R|-R] [+A|-A] [+S|-S] [+H|-H]');
End;
Else Begin
WriteLn('ATTRIB - Cette commande permet de demander ou changer l''attribut d''un fichier');
WriteLn;
WriteLn('Syntaxe : ATTRIB nomdufichier [+R|-R] [+A|-A] [+S|-S] [+H|-H]');
End;
End;
End
Else
If CurrParam=''Then Begin
FindFirst('*.*',AnyFile and Not Directory,Info);
While DOSError=0 do Begin
If Info.Attr and ReadOnly=ReadOnly Then Write('r') Else Write('-');
If Info.Attr and SysFile=SysFile Then Write('s') Else Write('-');
If Info.Attr and Archive=Archive Then Write('a') Else Write('-');
If Info.Attr and Hidden=Hidden Then Write('h') Else Write('-');
If Info.Attr and VolumeID=VolumeID Then Write('v') Else Write('-');
If Info.Attr and Directory=Directory Then Write('d') Else Write('-');
Write(' ');
WriteLn(Info.Name);
FindNext(Info);
End;
End
Else
Begin
FillChar(IsAttrSetting,SizeOf(IsAttrSetting),0);
AttrAdd:=0;
AttrRemove:=0;
SubDirectory:=False;
P:=1;
Repeat
If StrToUpper(CurrParam)='+R'Then Begin
AttrAdd:=ReadOnly;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='-R'Then Begin
AttrRemove:=ReadOnly;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='+H'Then Begin
AttrAdd:=Hidden;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='-H'Then Begin
AttrRemove:=Hidden;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='+A'Then Begin
AttrAdd:=Archive;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='-A'Then Begin
AttrRemove:=Archive;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='+S'Then Begin
AttrAdd:=SysFile;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='-S'Then Begin
AttrRemove:=SysFile;
IsAttrSetting[P]:=True;
End
Else
If StrToUpper(CurrParam)='/S'Then Begin
SubDirectory:=True;
IsAttrSetting[P]:=True;
End;
Inc(P);
CurrParam:=ExtractParam(P);
Until CurrParam='';
P:=1;
CurrParam:=ExtractParam(1);
Repeat
If Not IsAttrSetting[P]Then Begin
SetAttributFiles(ExtractParam(P));
End;
If P=255Then Exit;
Inc(P);
CurrParam:=ExtractParam(P);
Until CurrParam='';
End;
End;
Procedure BeepCommand;
Var
FirstParam:String;
X:Boolean;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Beep the speaker or play simple music');
WriteLn;
WriteLn('Format: BEEP [/?]');
End;
Else Begin
WriteLn('BEEP Cette commande permet d''‚mettre un bip sonore.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('BEEP [/?]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
End;
End;
End
Else
Begin
Sound(1550);
Delay(182);
NoSound;
End;
End;
Procedure BreakCommand;
Var
FirstParam:String;
X:Boolean;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Display, enable, or disable Ctrl-C and Ctrl-Break checking.');
WriteLn;
WriteLn('Format: BREAK [/?]');
End;
Else Begin
WriteLn('BREAK Cette commande permet de fixer ou de demander l''‚tat du Ctrl+Break.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('BREAK [/?]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
End;
End;
End
Else
Begin
GetCBreak(X);
If(Pipe)Then Begin
Write(PipeFile,'BREAK = ');
If(X)Then WriteLn(PipeFile,'on')
Else WriteLn(PipeFile,'off');
End
Else
Begin
Write('BREAK = ');
If(X)Then WriteLn('on')
Else WriteLn('off');
End;
End;
End;
Procedure CallCommand;Begin
WriteLn('Cette commande n''est pas mise en oeuvre');
End;
Procedure ChDirCommand;
Var
Drive:Char;
Error:Word;
FirstParam,Dir,CurrPath:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Display or change the current directory.');
WriteLn;
WriteLn('Format: CD [path | -]');
WriteLn(' ':14,'or');
WriteLn(' ':10,'CHDIR [path | -]');
End;
Else Begin
WriteLn('CHDIR Cette commande permet de fixer ou de demander le r‚pertoire courant.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CD [/?] chemin');
WriteLn('CHDIR [/?] chemin');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
WriteLn(' chemin Ce paramŠtre permet d''indiquer le chemin du rep‚rtoire.');
End;
End;
End
Else
If Length(FirstParam)>0Then Begin
GetDir(0,CurrPath);
Drive:=GetCurrentDisk;
{$I-} ChDir(FirstParam);{$I+}
Error:=IoResult;
If Error<>0Then WriteLn(GetErrorMessage(Error));
If Drive<>GetCurrentDisk Then ChDir(CurrPath);
End
Else
Begin
GetDir(0,Dir);
WriteLn(Dir);
End;
End;
Procedure CHCPCommand;
Var
Err:Word;
Regs:Registers;
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Display of change the current system code page.');
WriteLn;
WriteLn('Format: CHCP [n]');
End;
Else Begin
WriteLn('CHCP Cette commande permet de fixer ou de demander la page de codes.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CHCP [/?] [code]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
WriteLn(' code Ce paramŠtre permet d''indiquer la page de code');
End;
End;
End
Else
If FirstParam<>''Then Begin
Regs.AX:=$6602;
Val(FirstParam,Regs.BX,Err);
If Err=0Then Begin
Intr($21,Regs);
If(Regs.Flags and FCarry=FCarry)Then Begin
WriteLn('Impossible de changer le code de page actif');
End;
End
Else
WriteLn('Code de page invalide.');
End
Else
Begin
Regs.AX:=$6601;
Intr($21,Regs);
If(Regs.Flags and FCarry=FCarry)Then Begin
WriteLn('Page de code active inconnnu');
End
Else
WriteLn('Page de code active : ',Regs.BX);
End;
End;
Procedure CDDCommand;
Var
Error:Word;
FirstParam,Dir:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Change the current disk drive and directory.');
WriteLn;
WriteLn('Format: CDD [path | -]');
End;
Else Begin
WriteLn('CCD Cette commande permet de fixer ou de demander le disque et le r‚pertoire courant.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CDD [/?] chemin');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
WriteLn(' chemin Ce paramŠtre permet d''indiquer le chemin du rep‚rtoire.');
End;
End;
End
Else
If Length(FirstParam)>0Then Begin
{$I-} ChDir(FirstParam);{$I+}
Error:=IoResult;
If Error<>0Then WriteLn(GetErrorMessage(Error));
End
Else
Begin
GetDir(0,Dir);
WriteLn(Dir);
End;
End;
Procedure CLSCommand;
Var
FirstParam:String;
Begin
FirstParam:=ExtractParam(1);
If FirstParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Clear the video display and move the cursor to the upper left');
WriteLn;
WriteLn('Format: CLS [/?]');
End;
Else Begin
WriteLn('CLS Cette commande permet d''effacer l''‚cran.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('CLS [/?]');
WriteLn;
WriteLn(' /? Ce paramŠtre permet d''afficher l''aide sur cette commande');
End;
End;
End
Else
Begin
ClrScr;
End;
End;
Procedure CopyCommand;
Var
P:Byte;
ShowProgression:Boolean;
F:File;
CurrParam,Source,Target:String;
Begin
P:=0;
ShowProgression:=False;
Source:='';
Target:='';
Repeat
Inc(P);
CurrParam:=ExtractParam(P);
If CurrParam=''Then Begin
If P=1Then Begin
WriteLn('ParamŠtre requis');
End;
Break;
End
Else
If CurrParam='/?'Then Begin
Case Language of
_English:Begin
WriteLn('Purpose: Copy data between disks, directories or files.');
WriteLn;
WriteLn('Format: COPY [/?] [/P] source destination');
End;
Else Begin
WriteLn('COPY Cette commande permet d''effacer la copie de fichier vers un autre emplacement.');
WriteLn;
WriteLn('Syntaxe:');
WriteLn;
WriteLn('COPY [/?] [/P] source destination');
WriteLn;
WriteLn(' /? Ce parametre permet d''afficher l''aide sur cette commande');
WriteLn(' /P Ce parametre permet d''afficher la progression de la copie');
WriteLn('source Ce parametre permet d''indiquer le fichier source');
WriteLn('destination Ce parametre permet d''indiquer le fichier destination');
Exit;
End;
End;
End
Else
If(CurrParam='/P')or(CurrParam='/p')Then ShowProgression:=True
Else
If CurrParam<>''Then
Begin
If Source=''Then Source:=CurrParam
Else Target:=CurrParam;
End;
If P>9Then Break;