Information about dos.dll and asynchronous output handling
"saidsaracoglu" <[email protected]> Thu, 18 Oct 2012 10:47:52 -0000
| Newsgroups | gmane.comp.windows.gui4cli |
|---|---|
| Message-ID | <[email protected]> |
Hi,
I have met with gui4cli last week and it seemed perfect for writing a simple gui for pyroscope (http://code.google.com/p/pyroscope/) torrent tools. Especcialy mktor(creating torrent meta file).
My intention is showing a progress bar while mktor creates torrent and since it gives percentage output, I wanted to update a progress bar according to output. Before that I thought I should try it with some test cli program.
contest.exe is working but I needed a program that outputs some numbers by time, I needed something like a counter.
I wrote something with c and compiled with mingw, but output was not real time, gui4cli waits until program outputs all numbers(1 to 30) to add an edbox. A little search helped and it seems gui4cli needs not only printed output it also needs flushed output, otherwise it waits until all content printed and in the end flushed out completely.
I searched but couldn't find anything in posts so I decided to wrote here in case anyone needs in future.
Here are codes, gui4cli one taken from dos.dll help file and modified a little.
-------------------------------------------------
G4C contest
WINDOW 81 71 345 393 'ConTest'
xOnLoad
guiopen #this
xOnClose
guiquit #this
// send text to the program..
XTEXTIN 15 70 325 20 "" text
attr frame sunk
appvar text '\n'
dos.input TEST $text
// abort a running instance
XBUTTON 180 10 160 30 'Abort ConTest.exe'
dos.abort TEST
// launch the console program
XBUTTON 15 10 150 30 'Launch ConTest.exe'
dos.set OnExit #this endEvent
dos.set OnOutput #this handleText
dos.launch TEST "C:/MinGW/msys/1.0/home/Said/echotest.exe"
// this will be trigerred on exit
xRoutine endEvent
say 'Exit event was trigerred'
// This will be trigerred when text is available
xRoutine handleText
Use EDBOX #this myXed
edbox add 'Text = $$dll.dos.text'
// say 'Text = $$dll.dos.text'
XEDBOX 15 115 320 265 ""
attr ID myXed
-------------------------------------------------
echotest.exe:
-------------------------------------------------
#include <stdio.h>
#include <windows.h>
#define sleep(n) Sleep(1000 * n)
int main() {
int x,i;
for (i=1;i<=30;i++) {
printf("%d\n",i);
fflush(stdout); //The important part for us.
sleep(1);
}
return 0;
}
-------------------------------------------------
I am not native speaker for English, I won't be offended if you correct me :)
------------------------------------
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/gui4cli/
<*> Your email settings:
Individual Email | Traditional
<*> To change settings online go to:
http://groups.yahoo.com/group/gui4cli/join
(Yahoo! ID required)
<*> To change settings via email:
[email protected]
[email protected]
<*> To unsubscribe from this group, send an email to:
[email protected]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/