Using yoshi in yab - Printable Version +- yab | yet another Basic for HAIKU (https://yab.orgfree.com/forum) +-- Forum: General discussion (https://yab.orgfree.com/forum/forumdisplay.php?fid=8) +--- Forum: yoshi (https://yab.orgfree.com/forum/forumdisplay.php?fid=12) +--- Thread: Using yoshi in yab (/showthread.php?tid=68) |
Using yoshi in yab - clasqm - 05-02-2016 WHAT!? why would you want to do that when you can make all your windows and gadgets in yab itself? 1. For the same reason you don't laboriously make your own ALERT and FILEPANEL widgets. You could, you know. But someone already did all the heavy lifting here in terms of layout, so why bother? 2. Because using yoshi lets you tweak the dialogue OUTSIDE yab. I can think of a number of ways to do this. The easiest is to construct the yoshi dialogue in a separate file and just call it. But I have a fondness for shipping apps with as few files as possible (It goes back to my BeOS days) and constructing secondary files on the fly, so that's what I will do here. Code: #!/bin/env yab The INSTR command in yab makes it a lot easier to retrieve yoshi's output than it is in bash. Here, all I wanted to know was whether a specific action had been taken. For more complex yoshi scripts, you will have to use all of yab's string-splitting tricks to parse the output (e.g TOKEN, SPLIT, LEFT$ and RIGHT$). RE: Using yoshi in yab - clasqm - 05-02-2016 bas is a BASIC interpreter available on my repo. So I just had to see how hard it would be to port the above program to this different dialect of the language. Not hard at all. bas uses SHELL rather than SYSTEM and it has no way of getting data back from a SHELL command. So I had to pipe the results into a separate file and read it back in. Also, RESTORE in bas uses a line number rather than a label, and we have to use Haiku's alerts rather than yab's. But while the yab example admittedly showed a different way of doing something we could have done in yab itself, we are now doing something that would be impossible in bas if we did not have yoshi. So, if for whatever reason I decided that I wanted my app to be in bas rather than yab, I can do it. Or the other way round. Code: #!/bin/env bas |