Passing parameter from program A to B
#1
program A.exe wants to pass "hello" to program B.exe
 How do I pass the parameter in program A ?
How do I read the parameter in program B ?

currently I execute program B.exe via a shell command ... Shell "B.EXE" in program A
Reply
#2
http://www.qb64.net/wiki/index.php/RUN
B += x
Reply
#3
Thks for the help ... but
I should have mentioned

A runs B 
A needs to wait for B to complete before continuing on at the next step
 Thks ..
Reply
#4
There is also the obvious way for A to write a bunch of info to file, then when B is called it could open it and use the contents for whatever and even change the file for A to reread when control returns back to A.

Or use an environment variable of the OS?
B += x
Reply
#5
Why not just shell with "hello" as a parameter and read Command$ in program B?

Erik.
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#6
(02-04-2018, 12:32 PM)eoredson Wrote: Why not just shell with "hello" as a parameter and read Command$ in program B?

Erik.

Right! That was in the wiki link I first presented. I was offering stuff not found easily in Wiki.

I think shell would be my first choice but depends on usage, "hello" is frivolous hint.
B += x
Reply
#7
This describes passing a value from one program to another:

Code:
REM Proga
SHELL "progb.exe hello"
END

Target program:
Code:
REM Progb
PRINT COMMAND$
END

Otherwise you could use the CHAIN function..

Erik.
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#8
Using CHAIN function:

ProgX.bas
Code:
COMMON SHARED s AS STRING
s = "hello"
CHAIN "progy"
END

ProgY.bas
Code:
COMMON SHARED s AS STRING
PRINT s
END
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#9
Using a transfer file:

Prog1
Code:
Open "swapfile.txt" For Output as #1
Print #1,"hello"
Close #1
Shell "Prog2.exe"

Prog2
Code:
Open "swapfile.txt" For Input as #1
Input #1,s$
Close #1
Print s$
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#10
Well I guess you can't do this with QB64 but use to in DOS days, still can in SmallBASIC:
Code:
'test env SmallBASIC 0.12.11 2018-02-05

env("TEST=hello")
chain "a.bas"

'clear variable from environment
env("TEST=")
? "Checking TEST = ";env("TEST")
input "OK a.bas was run, we are done. ";ok

Code:
' A.bas SmallBASIC 0.12.11 (B+=MGA) 2018-02-05
? env("TEST")
input "Press enter to exit A.bas.";ex

Of course you can use QB64 to write and/or run a BAT file that will set an environment variable but that is ridiculously complicated.


Attached Files Thumbnail(s)

B += x
Reply
#11
How complicated?

Code:
REM Test1.bas
OPEN "TEST.BAT" FOR OUTPUT AS #1
PRINT #1, "@ECHO OFF"
PRINT #1, "SET TMP2=HELLO"
PRINT #1, "TEST2.EXE"
PRINT #1, "PAUSE"
PRINT #1, "EXIT"
CLOSE #1
SHELL "TEST.BAT"
PRINT "Returned from shell."
END

Code:
REM Test2.bas
PRINT "Variable="; ENVIRON$("TMP2")
END
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#12
I thought maybe data could be transferred from program A to program B using
DMA (direct memory access), but the operating system blocks memory access
between processes.

Otherwise, maybe data could be passed through the registry!?

Erik.
dndbbs project:

Links to my MUD: (strictly 16-bit); AKA XP:

Dndbbs executables
http://www.filegate.net/pdn/pdnbasic/dnd50a1e.zip

Dndbbs source
http://www.filegate.net/pdn/pdnbasic/dnd50a1s.zip

Dndbbs upgrade
http://www.filegate.net/pdn/pdnbasic/dnd50a1u.zip

DNDDOOR - https://bit.ly/EriksDNDDoor DUNGEON - https://bit.ly/EriksDungeon
Interpreter - https://bit.ly/EriksSICK Hex Editor - https://bit.ly/EriksHexEditor Utilities - https://bit.ly/EriksUtils
QB45 files: - https://bit.ly/EriksQB45 QB64shell - https://bit.ly/QB64shell Some old QB64 versions: - https://bit.ly/OldQB64
Reply
#13
Thank you all for your help ....

Mike
Reply
#14
Hi Mike, 

I like your problems, they get me thinking on things I might actually be able to solve! Wink

Like the file merge thing. I think I have the best solution that answers all your specs (the last one at QB64.net) but everyone else posts all this crazy stuff and I don't get how it's any better than what I posted. 

But there you go, I just have too much pride in my own work.

So much pride in fact, that I usually can't wait to show how brilliant I am IN THE SOURCE CODE!

Of course, what I think is the best, is usually always what is simplest and how a human might proceed intuitively but it's true there are plenty of occasions when our human intuition fails us, fools us, and completely misguides us. Con artists make their living from preying upon such foolishness.
B += x
Reply
#15
Completely tangential (sorry Mike):

Quote:Did you hear about the blonde that got excited? She finished a jigsaw puzzle in six months, when the box said, "two to four years."
Today's Joke

That is first one I actually like since I posted link in my signature.

But then I like math jokes, and blondes, and... well..., lot's of things...
B += x
Reply