Some of you may have seen my Kswitch (such an original name) program, and had you used it found that it had a really big flaw, namely command lines were split.
For those of you who didn't see it basicly its a DOS clone thingy, that pretty much sums it up. My problem is getting a command to be understood by the program, single commands like 'dir' or 'exit' work fine, but multiperamiter commands don't (in the first version I just turned each multiperamiter command into a slingle command, which was followed by a list of options).
I've started to recode the whole program, so I thought to nyself that the first thing I'd have to resolve is the above issue - but im having some trouble. In the code below im trying to get the command 'prompt' to work. What is supposed to happen is this:
The default propmt is '<get time$()>' but the prompt command allows the use to change this.
So they type 'prompt' followed by their desired prompt, I can get the program to recognise that the prompt command has been entered but actually getting the prompt isn't. For example to change the prompt to '<hello>' the user would need to type 'prompt hello' except all that happens is the prompt is changed to '<>'.
Here's the code, thanks for your help.
dim coms$(225,225)
dim version(1)
dim com$(3)
dim prompt$(1)
dim file$(3)
coms$(1)="dir"
coms$(1,1)="Displays the contents of the current directory."
coms$(2)="cdir"
coms$(2,2)="Displays the path for the current directory."
coms$(3)="exit"
coms$(3,3)="Exits Kswitch."
coms$(4)="prompt"
coms$(4,4)="Edits the prompt."
file$(1)="ver"
file$(2)="com"
file$(3)="prom"
prompt$(1)=get time$()
prompt()
end
function prompt()
com$(1)=""
com$(2)=""
com$(3)=""
if prompt$(1)="cdir" then prompt$(1)=get dir$()
if prompt$(1)="date" then prompt$(1)=get date$()
if prompt$(1)="time" then prompt$(1)=get time$()
input "<"+prompt$(1)+"> ",com$
if com$>""
com$(1)=com$
check()
else
prompt()
endif
endfunction
function check()
for t=1 to len(com$(1))
com$(2)=mid$(com$(1),t)
if com$(2)=" "
exit
else
com$(3)=com$(3)+com$(2)
endif
if com$(3)=coms$(1) then com1()
if com$(3)=coms$(2) then com2()
if com$(3)=coms$(3) then com3()
if com$(3)=coms$(4) then com4()
next t
prompt()
endfunction
function com1()
dir
prompt()
endfunction
function com2()
a$=get dir$()
print a$
prompt()
endfunction
function com3()
print "Goodbye"
wait 2000
end
endfunction
function com4()
com$(2)=""
com$(3)=""
for t=1 to len(com$(1))
com$(2)=mid$(com$(2),t)
com$(3)=com$(3)+com$(2)
if com$(3)=coms$(4) then com$(3)=""
next t
prompt$(1)=com$(3)
prompt()
endfunction
~I see one problem with your reasoning: The fact is that is a chicken~
