Hi. I want to make a loading console for my Editor.
What i mean is an external Window that reports the loading process while the editor is loaded..
The way i made it so far is by making an external GUI exe Window that get its info by reading a Text File whenever it changes by the editor sending reports.
so it needs to check the file size to decide if the file has changed..
Is their a better way to do this ? or my way is ok?
I think im gonna use Createprocess command to run the console
but in the case that my editor crashes, i need to find a way that the console will shut down too.
so i need a way to check if my editor is running or not. but thats less important
Hiya,
Hmm, I only know of a Windows only way to achieve exactly this. I'd guess that other OSs would have something similar.
This example is from MS to give an example of to use the Api
https://docs.microsoft.com/en-us/windows/win32/fileio/obtaining-directory-change-notifications
If you need any help getting it working with BMax let me know.
its not such a complex task..
i already made it in my way and ill share it later..
just wondering whats the best way..
i could also comunicate using UDP or something.
but ill communicate with text file
OK. it does not work for some reason..
the external windows is not updated.. like it waits for the editor to upload..
Is their a way to open CMD window and send text messages to this win?
If you want some kind of inter process communication? Then using TProcess will allow 2 'apps' to talk to each other via its pipe read and write methods.
Ok Ill Try The Read and Write Pipe Method
How do I read process from the target process?
writing to process is simple..
but i need to get the process address from the process . how do i do that?
You could pass it as a command line startup parameter?
Oh I misunderstood what you mean. I'm assuming both apps are written in BMax? In the 'main' app you start up the 'child' app using TProcess, and TProcess handles the connections. In your child app you can read/write to/from stdin/stdout, and the main app will use TProcess pipe to read/write.
I will glad to an example cause i have no idea how to use i.
meanwhile im searching.
anyway im trying to make a console and so far it does no transmit data while loading so..ill keep trying
Hi,
here is a basic example of communicating via process pipe using standardio (every application has their own).
Compile the tool.bmx in release mode or rename the file variable to tool.debug.exe . After that run the main app.
'Main app
'-------------------
'StandardIO example
'-------------------
Local proc:TProcess = CreateProcess("tool.exe")
If Not proc Then Print("Could not create tool app process"); End
Local feed:String, count:Int
Print "~nCount to 5:~n"
If ProcessStatus(proc)
Delay 100
proc.pipe.WriteString("Main_app: Sending ~qHello~q~n")
Repeat
If proc.pipe.ReadAvail() Then
feed:+ proc.pipe.ReadString(proc.pipe.ReadAvail())
EndIf
Delay 1000;
If count > 4 Then Exit
count:+ 1
Print "Counting " + count + ".."
Forever
proc.pipe.Close()
Else
Print("tool.exe not running. Exiting.."); End
EndIf
Delay 1000
Print "~n" + feed
Print "Ending process.."
TerminateProcess(proc)
End
'Tool app
'--------
'tool.bmx
'--------
Local s:String
While True
'Waiting for newline character
s = ReadStdin()
'Respond
WriteStdout(s + "~nTool_app: Responding with ~qHello back!~q")
Wend
-Henri
Of course you should do it a bit more "complicated" at the end.
Means having a type which handles all the communication for you (lurking around scanning for new input, handling queued up outgoing messages ...).
Also messages should have "IDs" so you know which came in what order (sequential messages).
@ Henri
I think it could be an interesting piece of code to attach to an running process (debuggers seem to be capable under circumstances). Am not sure if that is even doable "security wise" as it would mean to be able to "listen" to an else "separate" running program.
Aside of that a "process communication" module might be interesting too ... so something providing the basement of a crossplatform solution to send and receive stdio-based messaqes amongst parent ant child processes.
bye
Ron