Page 1 of 1

What is the problem? Console arguments.

Posted: Sun Oct 04, 2015 9:04 am
by zer0c0de

Code: Select all

If Left(cmd$, 3) = "cd "
    arg$ = Mid(cmd$, 3)
    arg$ = Trim(cmd$)
    arg$ = Trim(cmd$,Chr(9))
SetCurrentDirectory(arg$)
;The arg$ is empty, why?

Re: What is the problem? Console arguments.

Posted: Sun Oct 04, 2015 10:34 am
by Bisonte
Really ?

In this code...that what I see..... arg$ is empty because cmd$ is empty.....

Re: What is the problem? Console arguments.

Posted: Sun Oct 04, 2015 10:52 am
by Vera

Code: Select all

cmd$ = "cd " +Chr(9)+  "/some/where/Else" +Chr(9) + " "

If Left(cmd$, 3) = "cd "
  arg$ = Mid(cmd$, 3)        : Debug Mid(cmd$, 3)
  arg$ = Trim(cmd$)          : Debug Trim(cmd$)
  arg$ = Trim(cmd$, Chr(9))  : Debug Trim(cmd$, Chr(9))
  ;   SetCurrentDirectory(arg$)
  Debug "arg$ = " + arg$
EndIf

Debug "*********"

If Left(cmd$, 3) = "cd "
  arg$ = Mid(cmd$, 3)        : Debug Mid(cmd$, 3)
  arg$ = Trim(arg$)          : Debug Trim(arg$)
  arg$ = Trim(arg$, Chr(9))  : Debug Trim(arg$, Chr(9))
  ;   SetCurrentDirectory(arg$)
  Debug "arg$ = " + arg$
EndIf

Re: What is the problem? Console arguments.

Posted: Sun Oct 04, 2015 10:57 am
by zer0c0de
It's a part of my code.
For example.

command> cd directory

When i type cd and after the cd the directory's name, the program can't change the working directory, cause the arg$ variable is empty. Why stay empty the argument?
Sorry for my bad english.

Re: What is the problem? Console arguments.

Posted: Sun Oct 04, 2015 11:05 am
by zer0c0de
Thank you, Vera. :)

Re: What is the problem? Console arguments.

Posted: Sun Oct 04, 2015 11:07 am
by Vera
Aah ~ you got it ;-)

btw: Welcome to PureBasic zer0c0de :-)