Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Interpreting a command line

Author
Message
Killswitch
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 6th Dec 2003 21:18 Edited at: 6th Dec 2003 21:19
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.



~I see one problem with your reasoning: The fact is that is a chicken~
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 7th Dec 2003 07:58 Edited at: 7th Dec 2003 07:59
Hmm, your code is abit diffucult for me to understand.
But, the way you do it, is you get the user's input, com$, and then check that ( i believe you are already doing this ) for commands.

Ok, once you've done that ( and is working, ie, the program recognises the "prompt" command ), you next need to check what comes after the command.

From scratch, i would use the Mid$() command on the com$ variable, and check for a space.

Then, use the Right$() command to make prompt$(1) = whatever is after the space.

Then, i would exit from the loop.

like this:


Hope I Helped...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy
Killswitch
22
Years of Service
User Offline
Joined: 2nd Oct 2002
Location: School damnit!! Let me go!! PLEASE!!!
Posted: 7th Dec 2003 12:02 Edited at: 7th Dec 2003 14:31
Thanks alot! Sorry my code was hard to understand I'm a bit sloppy in that area. I managed to get it working using this code:



Your's had the same problem as mine! But it gave me a huge hint in the right direction.

~I see one problem with your reasoning: The fact is that is a chicken~
Jess T
Retired Moderator
21
Years of Service
User Offline
Joined: 20th Sep 2003
Location: Over There... Kablam!
Posted: 8th Dec 2003 02:44
Cool, glad you figured it out...


Team EOD :: Programmer/Logical Engineer/All-Round Nice Guy

Login to post a reply

Server time is: 2025-05-22 06:19:05
Your offset time is: 2025-05-22 06:19:05