Jump to content

MY own version of CMD

- - - - -

  • Please log in to reply
1 reply to this topic

#1
foster82

foster82

    Newbie

  • Members
  • Pip
  • 3 posts
Hi i am a noob to VB.NET

But i am looking to create my own version of CMD ,embedded into my program. Being a noob I dont know where to start. Any advise or tutorials would be greatfull. JUst really looking to be pointed in the right direction.

Thanks

Jonathan

#2
Alexander

Alexander

    It's Science!

  • Moderators
  • 4,124 posts
  • Location:Vancouver, Eh! Cleverness: 200
Hello foster82,

Essentially the console is a line buffered input, that means you can feed it a series of commands separated by newlines (the enter key) so you can easily create a command interpreter like a console.

You would have to do only a few steps:

  • Read the console input in to a string (readString = console.ReadLine())
  • Tokenize, or split, the string in to a readable format
i.e.
arrayOfParts = readString.Split(" ")
  • Parse each token under a predefined format, samples of commands:
myrename file1.txt file2.txt
mycd somedir
You will have to have a routine that will read the first array entry (for example myrename) and then decide how many parameters it should take, if the array arrayOfParts is less than three for example, you would warn the user that this specific function requires three parameters total (<function>, <file1>, <file2>)

Feel free to mess around with the console to better understand what you can do, you should be able to make your own fake command prompt as well, i.e.

console.Write("myprompt >")  'not writeline, as that would put in a new line and look silly
readLine = console.ReadLine()
...
You might need to read up on how to use arrays and loops, so you can continuously provide input as well, I've no experience in VB.NET although I hope to have provided a good insight in to the application.

Alexander.
Be sure to read the updated FAQ! || Health is achieved through the same 10,000 steps.
If a suggested code/method fails, informing us is less important than telling us why or what errors occurred.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users