shell$() with parameter(s)

new BookmarkLockedFalling
mikeukmid
Guest

Guest Avatar

Post by mikeukmid on Jan 2, 2009 16:17:40 GMT -5

Carl,
Trying to execute a LibertyBASIC program from RunBASIC and pass a commandline parameter results in RB error "is not recognized as an internal or external command, operable program or batch file."

Running the LB program without any commandline parameters does work ok. I had high hopes for shell$ but without cmdline parameters, I can not put it to use.

Am I not adding a parameter correctly eg:

exec$=chr$(34)+"C:\Documents and Settings\User1\Desktop\LPTout1.tkn param1"+chr$(34)
re$=shell$(exec$)

or is this not supported. If not is there a chance of it being included soon? Pretty Please! ;D

Mike.
Carl Gundel - admin
Administrator
*****

Carl Gundel - admin Avatar

Posts: 550

mikeukmid
Guest

Guest Avatar

Post by mikeukmid on Jan 3, 2009 5:30:05 GMT -5

Carl Gundel - admin Avatar
Should the parameters be located inside the CHR$(34) like you have in your example? Isn't Windows going to interpret param1 as being part of the application pathname?

-Carl


Without the quotes error ''C:\Documents' is not recognized as an internal or external command, operable program or batch file' is received, presumably a result of spaces in the path. With the quotes and no cmdline parameter, the LB program runs.

Changing exec$ to:
exec$=chr$(34)+"C:\Documents and Settings\User1\Desktop\RB remote\"+chr$(34)+"LPTout1.tkn 255"


the LB program runs but the cmdline parameter is not received. (I have run LPTout1.tkn from another LB prog to confirm that a cmdline parameter is being received)

Many thanks
Mike.
Last Edit: Jan 3, 2009 7:01:30 GMT -5 by mikeukmid
carlgundel
Administrator
*****
Creator of Run BASIC

carlgundel Avatar

Posts: 975

mikeukmid
Guest

Guest Avatar

Post by mikeukmid on Jan 3, 2009 10:36:03 GMT -5

carlgundel Avatar
How about this?

exec$=chr$(34)+"C:\Documents and Settings\User1\Desktop\LPTout1.tkn"+chr$(34)+" param1"

-Carl


Already tried that but nope, sorry :(
LPTout1.tkn runs but param1 is not received.

ex$="C:\LPTout1.tkn 255"
Moving the tkn to C:\ to eliminate the quotes, the tkn runs but no parameter is received.

Mike.

Edit: I've also tried running C:\LPTout1.exe (LB runtime engine) but that returns 'File not found: LPTout1.TKN'
Last Edit: Jan 3, 2009 10:48:58 GMT -5 by mikeukmid
zoomkat
New Member
*

zoomkat Avatar

Posts: 31Female

mikeukmid
Guest

Guest Avatar

Psycho
Full Member
***

Psycho Avatar

Posts: 196

Post by Psycho on Jan 18, 2009 14:11:49 GMT -5

Mike,

Are you able to run and pass the same parameters successfully from an actual command line?

I'm not very good at command line arguments but I'm pretty confident that if you can't launch this from an actual command line, it certainly won't work when done through RB either. In playing around, here are a couple generic examples that show some working configurations of exec$ that passes some sort of command line parameter. Some will only work for those with Liberty Basic installed because I wanted directories with spaces.

exec$=chr$(34)+"C:\Program Files\Liberty BASIC v4.03\liberty.exe"+chr$(34)+ " C:\Program Files\Liberty BASIC v4.03\SQRT.bas"

exec$="notepad " + chr$(34)+"C:\Program Files\Liberty BASIC v4.03\register.txt"+chr$(34)

exec$="notepad " + chr$(34)+"C:\rbp101\readme.txt"+chr$(34)


Maybe as a workaround you can have the RB program write the parameters to a file and have the LB program check that file for the current parameters :-/


John "Psycho" Siejkowski
mikeukmid
Guest

Guest Avatar

Post by mikeukmid on Jan 18, 2009 17:30:00 GMT -5

John, Thanks, yes some of the examples I have already tested and work. What I wanted to do was to run a LB prog and pass a value into LB as commandline$
exec$=chr$(34)+"C:\Documents and Settings\User1\Desktop\RB remote\LPTout1.tkn 255"+chr$(34)
where the parameter is a value to output to LPT port. The parameter is not received by the LB prog. Tried making a standalone app, LPTout.exe with no change and also tried all combinations of inserting quotes. I have tired of using files to pass data and hoped shell$ would be my salvation.

Mike.
StefanPendl
Global Moderator
*****

StefanPendl Avatar

Run for BASIC ...
Posts: 945

Post by StefanPendl on Jan 19, 2009 1:49:50 GMT -5

I would try the following, if TKN files are not associated with the LB runtime engine.

MyApp$ = "C:\MyPath\MyApp"

Exec$ = chr$(34);MyApp$;".exe";chr$(34);" ";chr$(34);MyApp$;".tkn";chr$(34);" ";255

Result$ = shell$(Exec$)

If TKN files are associated with the LB runtime engine you can use the following.

MyApp$ = "C:\MyPath\MyApp"

Exec$ = chr$(34);MyApp$;".tkn";chr$(34);" ";255

Result$ = shell$(Exec$)

I noticed that your last example included the parameter inside the quotes surrounding the TKN path, which is not correct.
In any case, surround the path with quotes and the arguments including spaces with quotes.
[b]Stefan[/b] - [a href=http://stefanpendl.runbasichosting.com/]Homepage[/a][br][br][b]Please give credit if you use code I post, no need to ask for permission.[/b][br][br]Run BASIC 1.01, Fire-/Waterfox (IE11, Edge), Windows 10 Professional x64, Intel Core i7-4710MQ 2.5GHz, 16GB RAM
mikeukmid
Guest

Guest Avatar

Post by mikeukmid on Jan 19, 2009 6:21:22 GMT -5

Thanks Stefan, but like I said in previous posts, I've tried all combinations of the position of the parameter and quotes. The LB prog DOES run, both in tkn and exe form (if the quotes are in the right places) but the parameter never gets through. CommandLine$ is always empty.
For example, exec$=chr$(34)+"C:\Documents and Settings\User1\Desktop\RB remote\"+chr$(34)+"LPTout1.tkn 255" runs the tkn but CommandLine$ is empty.

Mike.

EDIT: just noticed you put the parameter outside the quotes, will try that later when I get home. :)

EDIT 2: sorry Stefan, doesn't work. run "LPTout1.tkn 255" from LB sets CommandLine$ to "255"; from shell$ the tkn runs but the parameter is blank.
Last Edit: Jan 19, 2009 12:18:43 GMT -5 by mikeukmid