Using yoshi in yab
#2
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

restore 1000
open "cmds.yoshi" for output as #1
    while(line$ <> "end_of_data")
        read line$
        print #1 line$
    wend
close #1
shell "yoshi cmds.yoshi > yoshi.out"
open "yoshi.out" for input as #1
    while not EOF(1)
        line input #1, a$
        result$ = result$ + a$
    wend
close #1

if instr(result$, "chk=OFF") <> 0 then
    shell "alert --empty 'You turned off the checkbox. Thank you for following instructions', OK"
else
    shell "alert --empty 'You did not turn off the checkbox. Try again', OK"
endif
shell "rm -f cmds.yoshi"
shell "rm -f yoshi.out"
end

1000 data "*.title = Example window title"
data "*.bgcolor = 255-,232,181"
data "txt.type = text"
data "txt.default = yoshi in yab demo"
data "txt.lines = 2"
data "txt.align = centered"
data "txt.scrollbar = 1"
data "txt.bg = white"
data "chk.type = checkbox"
data "chk.default = 1"
data "chk.label = Turn off this checkbox, click OK and see what happens"
data "end_of_data"
Reply


Messages In This Thread
Using yoshi in yab - by clasqm - 05-02-2016, 04:43 AM
RE: Using yoshi in yab - by clasqm - 05-02-2016, 07:05 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)
Free Web Hosting