system$ command and return values & button disable - Printable Version +- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum) +-- Forum: Programming in yab (https://yab.orgfree.com/forum/forumdisplay.php?fid=1) +--- Forum: Help with programs (https://yab.orgfree.com/forum/forumdisplay.php?fid=4) +--- Thread: system$ command and return values & button disable (/showthread.php?tid=39) |
system$ command and return values & button disable - prOSy - 09-10-2015 Hello readers, [haiku hrev48444 gcc2hy] [yab 1.72] i revived an old unfinished project from 2009 at BeGeistert meeting where i tried to start programming with yab with a lot of help from lorglas and lelldorin of besly.de. [1] Now i want to play with system$ command (and what it gives back) in my little project. My application is a GUI for a command line application known as muscled, the base of all BeShare-driven networks. Main goal for me is to learn how to programm with yab in the right manner, and i'm now on a point where i could need help. Starting the muscle-daemon is comparable with the top command. Both written in C/C++. Top gives return values continuously to the user (refreshes all 5 seconds). The muscled also gives feedback as long as it runs. For now i open a terminal window where the user can follow the server messages [ see attached screenshot ] but i would like to have that messages placed best within my application in a VIEW, because when a user monkeys with that Terminal window and close it, the daemon is stopped and my application does not notice that. My question: is there a way to "pipe" the output from another cli program into a VIEW. Anyone here who can show me a little code snipped as exaple with the top command? [2] Is it possible to set a BUTTON visible but disabled in yab? I want to prevent the user to press the config button while server is running, so i want to disable (but keep visible) that button during server is running [ see attached screenshot ]. Thanks for your attention! prOSy RE: system$ command and return values & button disable - clasqm - 09-10-2015 On the button issue, that is easy Code: option set "copyButton", "enabled", 0 That is from the example program TinyTim I posted on this forum, in the Snippets section. When you want to enable it again: Code: option set "copyButton", "enabled", 1 Your other issue is trickier. The System$ command runs the parameter once and dumps its output to stdout, which yab can intercept and put into a string variable. The moment you grab that output and paste that onto a view, you'd get a snapshot, but then you lose access to that stream immediately.You want a continuous display, like a log, am I right? I would redirect the muscled output to a logfile. Code: system("muscled > ~/.muscled_log &") Code: a$ = system$("tail ~/.muscled_log") This is all off the top of my head, BTW. I am very far away from a yab installation right now. Debug, debug, debug! Anybody else? If there is a way to pipe a Unix stream directly into, say, a listbox, I'm all ears. Another approach would be to use the hey command to remove the tab from your Terminal window. That makes it a bit harder for the user to close it down. Also harder to move it around, so also use hey to position it somewhere in a corner and resize it. RE: system$ command and return values & button disable - prOSy - 09-11-2015 (09-10-2015, 02:56 AM)clasqm Wrote: On the button issue, that is easyThanks a lot. Already done, works perfect! Quote:Your other issue is trickier. ... You want a continuous display, like a log, am I right?Yes, indeed. that would be the N°1 solution, if possible. Quote:I would redirect the muscled output to a logfile.Good hint, which led me to another possibility. I could wirte log-messages always to a logfile and if user needs to look at that log, a button with system(tail -f ~/.logfile.log) or so opens a Terminal window and enables a look to the file. And if that window should be inadvertently closed it would not harm my application. Quote:Anybody else? If there is a way to pipe a Unix stream directly into, say, a listbox, I'm all ears.I'm all ears too! (-: Quote:Another approach would be to use the hey command to remove the tab from your Terminal window. That makes it a bit harder for the user to close it down. Also harder to move it around, so also use hey to position it somewhere in a corner and resize it.A nice possibility too. From what i've seen i have to dig into that hey stuff. It seems i have a little bit longer to think about it and to test various solutions. Anyway, thanks again, clasqm! prOSy RE: system$ command and return values & button disable - lelldorin - 09-11-2015 at prOSy: Code: Programname$="Example top command output in yab" |