This source code file is available for download here: cmd_v12_2004_09_27.zip(~1 MB)
1: | program cmd; |
2: | |
3: | {$APPTYPE CONSOLE} |
4: | uses SysUtils,basShell,Chip; |
5: | |
6: | function CommandLine:string; |
7: | |
8: | function GetParamStr(P: PChar{; var Param: string}): PChar; |
9: | var |
10: | Len: Integer; |
11: | Buffer: array[0..4095] of Char; |
12: | begin |
13: | while True do |
14: | begin |
15: | while (P[0] <> #0) and (P[0] <= ' ') do Inc(P); |
16: | if (P[0] = '"') and (P[1] = '"') then Inc(P, 2) else Break; |
17: | end; |
18: | Len := 0; |
19: | while (P[0] > ' ') and (Len < SizeOf(Buffer)) do |
20: | if P[0] = '"' then |
21: | begin |
22: | Inc(P); |
23: | while (P[0] <> #0) and (P[0] <> '"') do |
24: | begin |
25: | Buffer[Len] := P[0]; |
26: | Inc(Len); |
27: | Inc(P); |
28: | end; |
29: | if P[0] <> #0 then Inc(P); |
30: | end else |
31: | begin |
32: | Buffer[Len] := P[0]; |
33: | Inc(Len); |
34: | Inc(P); |
35: | end; |
36: | // SetString(Param, Buffer, Len); |
37: | Result := P; |
38: | end; |
39: | |
40: | begin |
41: | Result:=Trim(StrPas(GetParamStr(CmdLine))) |
42: | end; |
43: | |
44: | var Script:Chip.TBasic; |
45: | begin |
46: | Script:=basShell.TBasic.Create; |
47: | try |
48: | Script.input:=@input; |
49: | Script.output:=@output; |
50: | Script.Run(CommandLine) |
51: | finally |
52: | Script.Free; |
53: | end |
54: | end. |