Author |
Topic: command line (Read 425 times) |
|
Alincon
Full Member
member is offline
Posts: 147
|
|
command line
« Thread started on: Feb 5th, 2017, 4:38pm » |
|
LB4 can pass parameters to a tokenized program, that are read in the called program using the command "ComandLine$"
If LBB does not have this capability, can I pass a small amount of information to an LBB compiled program (.exe) in a similar manner?
I am not talking about command line switches here. I want to avoid writing a file in the calling program and reading it in the called program.
r.m.
|
|
Logged
|
|
|
|
Jack Kelly
Full Member
member is offline
Gender:
Posts: 106
|
|
Re: command line
« Reply #1 on: Feb 5th, 2017, 6:10pm » |
|
Hi r.m. alincon,
The special system variable 'CommandLine$' will contain all characters passed to the .exe file at run time. Let me know if you need an example.
Jack
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
Re: command line
« Reply #2 on: Feb 5th, 2017, 9:16pm » |
|
Okay, show me your example. I just tried my program again in LB4.5, once with .tkn which received the parameter and worked, and once with ".exe" which apparently did not receive the parameter and did not work. I tried the program with LBB with "exe" and it failed. LBB does not work with 'tkn' as far as I know.
Maybe there are some differences between LB45 .exe and LBB .exe.
r.m.
|
|
Logged
|
|
|
|
Jack Kelly
Full Member
member is offline
Gender:
Posts: 106
|
|
Re: command line
« Reply #3 on: Feb 5th, 2017, 10:57pm » |
|
Compile the following two line program to 'test.exe'.
Code:
Next, compile the following one line program to 'test2.exe'.
Code:run "test.exe <Put your command line data here.>"
Finally, run 'test2.exe' from Windows. It works.
The 'run' statement in 'test2.bas' will not work from the LBB IDE, only from Windows.
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: command line
« Reply #4 on: Feb 6th, 2017, 08:33am » |
|
on Feb 5th, 2017, 10:57pm, Jack Kelly wrote:The 'run' statement in 'test2.bas' will not work from the LBB IDE, only from Windows. |
|
Can you explain what you mean by that? Of course you can run the code listed as test2.bas from the LBB IDE, and if you do it works perfectly (tested here, not that there was ever any doubt about it).
Unlike LB 4, running code from the IDE is not significantly different from compiling it and running the EXE - in the case of LBB they both run as separate processes.
What you are possibly getting confused with is that if you try to use the LBB run-time engine (LBBRUN.exe) in conjunction with a tokenized program (say test.lbb in this case) then it is true that you cannot use CommandLine$.
That has been on my list of things to fix for (literally) years, but since virtually nobody ever uses tokenized LBB programs (they offer no real benefit over compiled EXEs and the security is very poor) it's a low priority for me.
Richard.
|
|
Logged
|
|
|
|
Jack Kelly
Full Member
member is offline
Gender:
Posts: 106
|
|
Re: command line
« Reply #5 on: Feb 6th, 2017, 12:55pm » |
|
I wasn't using tokenized files. My confusion arose because I was running 'test2' from the IDE without having saved it to a .bas file first. When I did that it did work correctly. I'm running under XP.
|
|
Logged
|
|
|
|
Alincon
Full Member
member is offline
Posts: 147
|
|
Re: command line
« Reply #6 on: Feb 6th, 2017, 3:20pm » |
|
Well, I'm still confused, and I can not get my .exe program to work by calling it from my .bas program in the LBB or LB4.5 IDE.
I am depending on the "special variable" CommandLine$ to receive a few characters of information, and apparently, it does not.
Does LBB recognize "CommandLine$" as a 'spercial variable' or not? I was unable to find it in among the statements, functions, etc.
Should I just communicate by a small file, rather than try to pass parameters along with the call?
r.m.
|
|
Logged
|
|
|
|
Jack Kelly
Full Member
member is offline
Gender:
Posts: 106
|
|
Re: command line
« Reply #7 on: Feb 6th, 2017, 9:28pm » |
|
Alincon, did my example work for you or not? It works for both Richard and I, and demonstrates exactly how CommmandLine$ works in LBB.
Your programs might not work for any number of reasons. Start with one small step at a time and you should be able to figure it out.
Jack
|
|
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: command line
« Reply #8 on: Feb 6th, 2017, 9:54pm » |
|
on Feb 6th, 2017, 12:55pm, Jack Kelly wrote:My confusion arose because I was running 'test2' from the IDE without having saved it to a .bas file first. When I did that it did work correctly. |
|
The only significance of that is the setting of your 'default directory' (DefaultDir$). Saving the program sets DefaultDir$ to where you saved it. If you had specified an absolute path to test.exe in the RUN command it would have worked whether the program was saved or not.
Richard.
|
|
|
|
|