|
Post by 1180michel on Mar 18, 2021 6:10:18 GMT -5
Hi ! It seems that the characters "\" and ":" are not welcome in CommandLine$... How to put a full filename in CommandLine$ ?
Of course, between self-made Lbasic programs, you can use replstr$ to code/decode CommandLine$ :
Calling program : CommandLine$=replstr$(CommandLine$,"\","+") CommandLine$=replstr$(CommandLine$,":","\")
Called program : CommandLine$=replstr$(CommandLine$,"+","\") CommandLine$=replstr$(CommandLine$,"=",":")
But Windows doesn't ! If you try to open (for example) a .txt file with "Open with... (with my Lbasic program with file name in CommandLine$)", you get an error ".tkn not found" !
Is ther a way to avoid this ?
Thanks a lot to all !
1180michel
|
|
|
Post by Rod on Mar 18, 2021 11:05:04 GMT -5
|
|
|
Post by 1180michel on Mar 18, 2021 17:05:03 GMT -5
Hi Rod ! Thanks for answer ! To be more clear, I explain :-)))
Here is the CALLED program (please, compile it to called.exe) : --------------------------------- nomainwin c$=after$(CommandLine$," ") notice "Parameter is : ";c$ end ---------------------------------
Here is the CALLING program (not to compile, better to start from LB to easy change it) :
--------------------------------- nomainwin run "e:\lbasic\called.exe somestuf" ' (somestuf doesn't exist anywhere) end ' My LB dir is "e:\lbasic", you should have to change to yours ---------------------------------
Start the calling program : IT WORKS
Change the calling program to :
run "e:\lbasic\called.exe c:\somestuf" : IT WORKS run "e:\lbasic\called.exe c:\\\\somestuf" : IT WORKS run "e:\lbasic\called.exe 123somestuf" : IT WORKS run "e:\lbasic\called.exe c:somestuf" : DOESN'T WORK ("File not found : c:") run "e:\lbasic\called.exe c:\some\stuf" : DOESN'T WORK ("File not found : called.tkn) run "e:\lbasic\called.exe some:stuf" : DOESN'T WORK ("File not found : called.tkn) run "e:\lbasic\called.exe e:\some>stuf" : DOESN'T WORK ("File not found : called.tkn) run "e:\lbasic\called.exe e:\lbasic\calling.bas" : IT WORKS !!!
You can experiment so and so...
I thought that the parameter after "e:\lbasic\called.exe" was only considered as a simple string, but it seems that this parameter is "interpreted" by LB or by Windows...
What's happen ? Can You explain ?
Thanks 1000 times for your answer !
1180michel
|
|
|
Post by Chris Iverson on Mar 18, 2021 18:45:44 GMT -5
I suspect there is some sort of path mangling going on when working with the CommandLine$ strings.
Try quoting the paths when you run the external programs.
parameter$ = chr$(34) + "C:\some\stuf" + chr$(34) run "e:\lbasic\called.exe " + parameter$
|
|
|
Post by 1180michel on Mar 19, 2021 4:22:22 GMT -5
Thanks Chris, but unhappily this does'nt work, I had already tested :
p$=chr$(34)+"some\stuf"+chr$(34) run "e:\lbasic\called.exe "+p$
Thanks anyway !
|
|
|
Post by tsh73 on Mar 19, 2021 8:23:12 GMT -5
|
|
|
Post by Rod on Mar 19, 2021 9:58:58 GMT -5
I think the spaces are also important. Windows or Liberty breaks the line when a space is found. See the difference between these two attempts. The space after .exe makes all the difference.
run "c:\atemp\test\test.exe"+chr$(34)+"C:\somestuff"+chr$(34)'works run "c:\atemp\test\test.exe "+chr$(34)+"C:\somestuff"+chr$(34)'fails
|
|
|
Post by 1180michel on Mar 23, 2021 15:53:41 GMT -5
Thanks, Rod ! I will more think about blanks !
|
|