A barberpole spinner
#9
(05-09-2016, 09:46 PM)bbjimmy Wrote: yes, launch a separate program and have it send a message when the process is done. Then the main loop can spin the spinner until it receives the done message.

OK, here's one approach:

Code:
#!/bin/env yab
DEBUG = 0
displaymessage$ = "Please Wait ..."

import spinner

OpenWindow()
//Main Message Loop
dim msg$(1)
while(not leavingLoop)
    nCommands = token(message$, msg$(), "|")
    for everyCommand = 1 to nCommands
        if(DEBUG and msg$(everyCommand)<>"") print msg$(everyCommand)
        switch(msg$(everyCommand))
            case "_QuitRequested":
                leavingLoop = true
                break
            default:
                break
        end switch
    next everyCommand
    spin("Barber")
wend
CloseWindow()
end

sub CloseWindow()
    window close "MainWindow"
end sub

sub OpenWindow()
    window open 100,100 to 600,150, "MainWindow", "barberpole"
    window set "MainWindow", "look", "bordered"
    view 1,3 to 500,28, "SpinView", "MainWindow"
    new_spinner(1,1,25,497, "Barber", "SpinView")
    display_spinner("Barber")
    view 3,31 to 497,50, "MsgView", "MainWindow"
    text 1,4 to 494, 19,"themessage", displaymessage$, "MsgView"
    text set "themessage", "align-center"
end sub

compile that as the executable "barberpole" (actually, I call dibs on that name - name yours something related to your app like "barberpole_MyGreatApp")

Now call it in yab with
system("barberpole")

When you no longer need it, there are two ways to get rid of it. The elegant way:

system("hey barberpole quit")

The brute force way:

system("kill barberpole")

Of course if there were two barberpoles active they would both be killed, which is why you should name your version appropriately.

This is just a quick mockup. A proper CLI app would put itself in the screen centre, have parameters to change colours and direction, a custom message and so on. I think I will develop that further.
Reply


Messages In This Thread
A barberpole spinner - by bbjimmy - 05-05-2016, 10:58 AM
RE: A barberpole spinner - by clasqm - 05-07-2016, 02:57 PM
RE: A barberpole spinner - by bbjimmy - 05-07-2016, 07:21 PM
RE: A barberpole spinner - by clasqm - 05-08-2016, 08:02 AM
RE: A barberpole spinner - by clasqm - 05-08-2016, 09:40 AM
RE: A barberpole spinner - by bbjimmy - 05-08-2016, 12:43 PM
RE: A barberpole spinner - by clasqm - 05-09-2016, 04:40 PM
RE: A barberpole spinner - by bbjimmy - 05-09-2016, 09:46 PM
RE: A barberpole spinner - by clasqm - 05-10-2016, 11:12 AM
RE: A barberpole spinner - by bbjimmy - 05-10-2016, 02:02 PM
RE: A barberpole spinner - by clasqm - 05-10-2016, 03:23 PM
RE: A barberpole spinner - by bbjimmy - 05-11-2016, 09:21 AM
RE: A barberpole spinner - by clasqm - 05-13-2016, 02:08 PM
RE: A barberpole spinner - by clasqm - 05-17-2016, 11:11 AM

Forum Jump:


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