Shell cmds?

BlitzPlus Forums/BlitzPlus Programming/Shell cmds?

arget brisingr(Posted 2007) [#1]
I am making a game it is a hacker game and I need a shell type thing were they can type in there commands. So I need it to be like this: cd dir and if that dir exists then it goes there. Also if they type 'ls' It will show the files in the dir...

So is there a way to do this? I mean I could do it with IF...ELSE but that would be alot of code...


b32(Posted 2007) [#2]
Well, basically, you should use if..then I suppose, or Select..Case. Use Lower$, Left$, Mid$, Trim$(?) to prepare the strings, and then a big Select..Case structure to handle the commands, sort of like this:
Select command$
Case "LS"
   ShowFiles(currendir$)
Case "CD"
   ChangeDir(parameter1$)
End Select

In the archives, you can find a few examples. I believe one was called 'Basic in basic' o.s., and Mark wrote a simple basic compiler.