Re: Need a bit of help with reading in characters.

From: Advocated (......_at_......com)
Date: 12/23/03


Date: Tue, 23 Dec 2003 02:25:30 -0000


"Leo Custodio" <lcustoc611@rogers.com> wrote in message
news:8bGFb.52187$2We1.22327@news04.bloor.is.net.cable.rogers.com...
> I still don't understand what you're trying to do, but let's see if with a
> few more examples we all get it.
> Are you trying to create a program that, when running, would accept
> arguments and would pass them to the shell?
> Because you've mentioned something earlier about your program being able
to
> accept external arguments as well (ie. myprogram -a -x -kill) but it does
> not do that so far.
>
> If your program will take external parameters, you might wanna have a look
> at the main function and change it to something like ~ int main(int argc,
> char * argv[]) ~ and analyze all the parameters from it and pass them back
> to the shell.
>
> If what you're trying to do is simply get parameters at runtime (ie. your
> software prompts for user imput and you will then analyze them), you have
to
> change that scanf input type ~ scanf("%s", string); ~ as i've said before
> and make it accept the whole line. Afterwards, you separate them and check
> any arguments, enabling flags for each parameter and then running your
> program according to the flags.
>
>
>
> Leo
> aliensprite@hotmail.com
>
>
>
> "Advocated" <......@......com> escreveu na mensagem
> news:7RyFb.8385$FN.6250@newsfep4-winn.server.ntli.net...
> > > > Hey all, thanks for taking the time to read this in the first place.
> > > >
> > > > Anyway, ill try and keep it simple. In my program, if i type $ man >
> > something
> > > > it should read in the 2 words, man and something
> > > > it should look up man - find that its a function, run the man >
> > function, and
> > > > then, with that second word "something" it should then execute that
as
> >
> > its
> > > > parameters, if that make sense.
> > >
> > > at first i thought you were confusing command-line parameters (argv[])
> > > with function parameters. after looking at the code, it looks more
> > > like a proto-shell of sorts. if that is the case, then look into
> > > strtok(3) to "tokenize" the contents of string.
> > >
> > > after that, you should declare main() as type int, lose the infinite
> > > loop, return from main(), and ditch the c++ style comments.
> > >
> > > --
> > > donLouis
> >
> > Well i think i get what you mean, this is the original code i was
looking
> > at:
> > http://tinyurl.com/39nfe
> >
> > I think this uses a kind of tokeniser, but the problem is, the input is
> > predifined if that makes any sense, i.e
> > strcpy(InputString," Test\t \t of the parser \t with its
problems....
> > a");
> > is already the user input, instead of getting the actual user input.
> >
> > The idea is, it will actually be a kind of shell, if i can get this
first
> > part to function. Any more ideas?
> >
> > Thanks
> >
> >
>
>

Thanks for all this help guys. Ive made the changes stated
http://tinyurl.com/2hkpx
and also added something to get the commands, this is working ok at the
moment, in the means that, if i type: dir *.exe it will print token 0 is
dir, token 1 is *.exe so i think im kind of getting the idea?

Im having a silly problem with it though, in the LeftTrim function it uses:
while ((*Input == ' ') || (*Input == '\t')) This is supposed to remove all
spaces and tabs from the input, but its only semi working and i cannot see
why. If i type hello<space>world it works fine, if i do
hello<space><space>world etc, it works fine, and both times prints token 0 =
hello token 1 = world.
The problem is with the tabs. If i type: <tab>hello world it prints token 0
= hello token 1 = world. but if i type: hello<tab>world it prints: token 0
= hello world.

Not sure why its not working, but in my previous examples where i wasnt
waiting for user input(using a predefined string: strcpy(InputString,"
Test\t \t of the parser \t with its problems.... a"); ) it worked
perfectly, Can anyone see where im going wrong? Ive tried running in Visual
Studio debugger, but for some reason its not working 100%, i.e i run the
debugger, it gets to say a printf statement and asks me where printf.c is
located :s

Cheers though all!



Relevant Pages

  • Re: Form that uses previous output as input.
    ... you would not need to be passing the user data to the shell at all. ... (The shell would still be involved, because the idiot PHP developers ... about passing user input to programs or functions that are not ...
    (uk.net.web.authoring)
  • [Test Needed] PHP [win32] & CLI required for testing.
    ... written, lets just say to create shell emulation for now, and have ... My previous attempts to create the source below, ended with the loop ... stopping due to undefined varible, that requested for user input, the ... finally resolve any issues due to this problem in PHP compatibility. ...
    (alt.php)
  • PHP [win32] & CLI Testers needed.
    ... written, lets just say to create shell emulation for now, and have ... My previous attempts to create the source below, ended with the loop ... stopping due to undefined varible, that requested for user input, the ... finally resolve any issues due to this problem in PHP compatibility. ...
    (php.general)
  • Re: custom shell starts before all services loaded
    ... Do you just want to launch your shell app and know when user input is available in it? ... You may end up launching a very small app as your shell. ...
    (microsoft.public.windowsxp.embedded)
  • Re: Exporting selected tabs multiple times to different file names
    ... Dim mySelection as Range ... set mySelection = selection ... I want to write a macro to export tabs to seperate files and save them ... I am also wondering how i can get a user input text box in excel so I can ...
    (microsoft.public.excel.programming)