tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
28
Task/Environment-variables/XPL0/environment-variables.xpl0
Normal file
28
Task/Environment-variables/XPL0/environment-variables.xpl0
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
include c:\cxpl\codes; \intrinsic 'code' declarations
|
||||
string 0; \use zero-terminated strings
|
||||
int CpuReg, PspSeg, EnvSeg, I, J, C;
|
||||
char EnvVar;
|
||||
[CpuReg:= GetReg; \access CPU registers
|
||||
PspSeg:= CpuReg(9); \get segment address of our PSP
|
||||
EnvSeg:= Peek(PspSeg,$2C) + Peek(PspSeg,$2D)<<8;
|
||||
EnvVar:= "PATH"; \environment variable
|
||||
I:= 0;
|
||||
loop [J:= 0;
|
||||
loop [C:= Peek(EnvSeg,I); I:= I+1;
|
||||
if C = 0 then quit;
|
||||
if C = EnvVar(J) then
|
||||
[J:= J+1;
|
||||
if J = 4 then
|
||||
[Text(0, EnvVar); \show env. var.
|
||||
loop [C:= Peek(EnvSeg,I); \ and rest of
|
||||
I:= I+1; \ its string
|
||||
if C = 0 then exit;
|
||||
ChOut(0, C);
|
||||
];
|
||||
];
|
||||
]
|
||||
else J:= 5; \line must start with environment variable
|
||||
];
|
||||
if Peek(EnvSeg,I) = 0 then quit; \double 0 = env. var. not found
|
||||
];
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue