1
0
mirror of https://github.com/dschmenk/PLASMA.git synced 2026-03-14 00:16:32 +00:00
Files
PLASMA/src/libsrc/args.pla
2016-08-15 22:13:37 -07:00

34 lines
636 B
Plaintext

include "inc/cmdsys.plh"
const cmdline = $01FF
def argDelim(str)
byte n
// Strip leading spaces
while ^str and ^(str + 1) == ' '
memcpy(str + 1, str + 2, ^str - 1)
^str--
loop
// Scan to trailing spaces (if any)
for n = 1 to ^str
if ^(str + n) <= ' '
^(str + n) = ^str - n
^str = n - 1
break
fin
next
return str
end
export def argNext(str)
str = str + ^str + 1
return argDelim(str)
end
export def argFirst
// NULL terminate command line
^(cmdline + ^cmdline + 1) = 0
return argDelim(cmdline)
end
done