What is the problem? Console arguments.

Linux specific forum
zer0c0de
New User
New User
Posts: 6
Joined: Sun Oct 04, 2015 8:51 am

What is the problem? Console arguments.

Post 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?
User avatar
Bisonte
Addict
Addict
Posts: 1313
Joined: Tue Oct 09, 2007 2:15 am

Re: What is the problem? Console arguments.

Post by Bisonte »

Really ?

In this code...that what I see..... arg$ is empty because cmd$ is empty.....
PureBasic 6.21 (Windows x64) | Windows 11 Pro | AsRock B850 Steel Legend Wifi | R7 9800x3D | 64GB RAM | RTX 5080 | ThermaltakeView 270 TG ARGB | build by vannicom​​
English is not my native language... (I often use DeepL.)
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: What is the problem? Console arguments.

Post 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
zer0c0de
New User
New User
Posts: 6
Joined: Sun Oct 04, 2015 8:51 am

Re: What is the problem? Console arguments.

Post 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.
zer0c0de
New User
New User
Posts: 6
Joined: Sun Oct 04, 2015 8:51 am

Re: What is the problem? Console arguments.

Post by zer0c0de »

Thank you, Vera. :)
User avatar
Vera
Addict
Addict
Posts: 858
Joined: Tue Aug 11, 2009 1:56 pm
Location: Essen (Germany)

Re: What is the problem? Console arguments.

Post by Vera »

Aah ~ you got it ;-)

btw: Welcome to PureBasic zer0c0de :-)
Post Reply