Make system(NULL) detect whether a command processor is available.

Previously, it just ran an Execute shell call with NULL as the command-line pointer.

The fix is to still call Execute, but with an empty string as the command line, and then check if the call gave an error. If running under plain GS/OS, this gives an error for an unknown system call, whereas both ORCA/APW and GNO shells will return with no error in this case. (Golden Gate doesn't implement the Execute shell call, so it also gives an error and will report no command processor available.)

This fixes issue #25.
This commit is contained in:
Stephen Heumann 2018-03-13 17:49:49 -05:00
parent 21d34a30ce
commit 7abdfc9beb
1 changed files with 16 additions and 2 deletions

View File

@ -973,14 +973,28 @@ system start
sta exComm
pla
sta exComm+2
phy execute the command
ora exComm
sta empty
bne lb1 if calling system(NULL)
lda #empty use empty command string
sta exComm
lda #^empty
sta exComm+2
lb1 phy execute the command
phx
plb
Execute ex
rtl
ldy empty
bne ret if doing system(NULL)
tya
bcs ret error => no command processor
inc a (& vice versa)
ret rtl
ex dc i'$8000'
exComm ds 4
empty ds 2
end
****************************************************************