![]() |
How to use SYSTEM$() to run C++ script - 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: How to use SYSTEM$() to run C++ script (/showthread.php?tid=191) |
How to use SYSTEM$() to run C++ script - PurpleStudio - 10-07-2025 I should start by saying, I know that SYSTEM$ isn't really meant to run C++ programs, but I figured, in theory, it should work. I have a very small C++ application that retrieves some information via web api to retrieve some live data on the internet. The C++ compiled with no issues and runs perfectly. My Yab: Code: #! /bin/yab The C++ program when ran in Terminal outputs a single line of text. I want to DRAW TEXT to a window. That wasn't working, so I figured I'd just use PRINT to get something in the console to see if that was working... it wasn't. All files are in the same working directory. Help? RE: How to use SYSTEM$() to run C++ script - clasqm - 10-07-2025 SYSTEM$ doesn't care what language your program was written in. What it does care about is whether your program's output gets written to STDOUT or STDERR. It will only report back with the contents of STDOUT. Try redirecting all of your app's output to a temporary file, Then OPENing it and reading the contents. system("command-name &>filename") open "filename" for reading as #1 line input #1, a$ close #1 system("rm filename") print a$ RE: How to use SYSTEM$() to run C++ script - PurpleStudio - 10-08-2025 (10-07-2025, 06:24 PM)clasqm Wrote: SYSTEM$ doesn't care what language your program was written in. Thank you for the response!! I took another look at the code and figured it out! I had accidentally included a newline "\n"; at the end of my STD::COUT so Yab WAS doing what it was supposed to do, it was (as per usual) user error. It was just storing the newline in my string variable. Such a simple mistake. Oh well, now I know. My code is working really well now! I might as well ask a follow-up question. When I "DRAW FLUSH" there's a quick flash in the VIEW that gets flushed. Is there any way to mitigate that flicker? Or no? Lastly clasqm, I know you'll be taking a little break from Youtube soon, but do you plan to make any more Yab videos? AND would you ever entertain doing a complete series (door-to-door) on Programming C++ on Haiku? Including the Interface Kit? As a novice programmer, I wish there were more resources out there. I know DarkWyrm published Programming C++ on Haiku (I have the book), but it left me wishing there was more. And I just jive really well with the way you explain and analyze things... you make these things easy to understand and absorb. |