system$ command and return values & button disable
#4
at prOSy:

Code:
Programname$="Example top command output in yab"
Developer$="Lelldorin"

screenWidth = peek("desktopwidth")
screenHeight = peek("desktopheight")

ProgramFolder$="/boot/home/Desktop/for_prOSy"

WINDOW OPEN screenWidth/2-400,screenHeight/2-300 TO screenWidth/2+400,screenHeight/2+300, "TopCommandOutput", "Example top command output in yab"
    TEXTEDIT 5,5 TO 795,565, "TE:Output", 1, "TopCommandOutput"
    
    DRAW TEXT 5,585, "counter to reload (40):0", "TopCommandOutput"
looprun=30

//Main Loop    
dim part$(1)

inloop = true

while(inloop)
    looprun=looprun+1
    DRAW FLUSH "TopCommandOutput"
    DRAW TEXT 5,585, "counter to reload (40):"+str$(looprun), "TopCommandOutput"
    //print looprun
    msg$ = message$
    //print looprun
    
    
    if (split(msg$, part$(), ":|") > 2) then
        PartOne$=part$(1)
        PartTwo$=part$(2)
        PartThree$=part$(3)
    fi

    if (split(msg$, part$(), ":|") > 3) then
        PartFour$ = part$(4)
    fi

    if (msg$ <> "") print msg$
    

    switch msg$
    
    case PartOne$+":_QuitRequested|"
        WINDOW CLOSE PartOne$
        break
        
        

        
    
    default:

    end switch
    
    if(looprun=40)then
        //print "here"
        //i=0
        if(IfExists("/boot/home/config/settings/top_output")) then
            output$=system$("rm -r /boot/home/config/settings/top_output_temp")
        else
        endif
        output$=system$("top > /boot/home/config/settings/top_output_temp&kill top")
        wait 2
        output$=system$("cp /boot/home/config/settings/top_output_temp /boot/home/config/settings/top_output")
    elseif(looprun>40)then
        TEXTEDIT CLEAR "TE:Output"
        //print "loop ab:" +str$(looprun)
        //wait 2
        readout=open("/boot/home/config/settings/top_output", "r")
        while (not EOF(readout))
            x=x+1
            print "x:"+str$(x)
            dim ReadTopCommandOutput$(x)
                line input #readout b$
                ReadTopCommandOutput$(x)=b$    
                for i = 1 to readout
                    //print "i:"+str$(i)
                    TEXTEDIT ADD "TE:Output", ReadTopCommandOutput$(i)+"\n"                    
                next i
        wend
        i=0
        x=0
        looprun=0
    else
        
    endif

    if(window count<1) inloop = false

    sleep 0.1
    

wend

sub IfExists(filename$)
     return not system("test -e "+filename$)
end sub
Reply


Messages In This Thread
RE: system$ command and return values & button disable - by lelldorin - 09-11-2015, 12:30 PM

Forum Jump:


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