Re: Information about dos.dll and asynchronous output handling
Dimitris Keletsekis <[email protected]> Thu, 18 Oct 2012 20:32:14 +0300
| Newsgroups | gmane.comp.windows.gui4cli |
|---|---|
| Message-ID | <CAHiKg1W-HFzFQJdwucjCzTvsnDjee7_hbEe1-YGT4EW5PmEo_Q@mail.gmail.com> |
Hi,
Yes, that's a problem with dos.dll but there is no way around it I know of.
Unless the output is flushed, its not available and many programs don't
bother..
BTW - this is the code for the contest.exe if anyone needs it (I thought I
had included it but couldn't find it)
#include "stdafx.h" // or use "windows.h"
#include<stdio.h>
#include<string.h>
#define BUFF_SIZE 1024
main(int argc, char *argv[])
{
char buff[BUFF_SIZE+4];
// Print any arguments we received on the command line..
printf ("ConTest.exe has started.. argc = %d\n", argc);
if (argc > 1)
{
printf ("Received %d arguments:\n", argc-1);
int c;
for (c = 1; c < argc; ++c)
printf ("Arg %d : %s\n", c, argv[c]);
}
// make sure we flush the buffers otherwise the text may not be outputed..
fflush(NULL);
// read from stdin, echoing everything they send us, until we received
// the word "EXIT", whereupon we exit..
bool stop = 0;
while (!stop)
{
memset(buff, 0, BUFF_SIZE);
gets (buff);
printf ("Echoing [%s]\n", buff);
fflush(NULL);
if (stricmp(buff,"Exit")==0)
{
printf ("received EXIT command - exiting...\n");
stop = 1;
}
}
return 0;
}
Best regards
Dimitris
On Thu, Oct 18, 2012 at 1:47 PM, saidsaracoglu <[email protected]> wrote:
> **
>
>
> 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
> :)
>
>
>