RexxButton
BGNDCOL=CCCCCC;TEXTCOL=000084;SCRIPT=/* Z! mini controller */%0D%0A%0D%0Asignal on error name TrapErr%0D%0Asignal on syntax name TrapErr%0D%0Asignal on failure name TrapErr%0D%0Asignal on halt name TrapErr%0D%0A%0D%0A/* -- User configuration Section -------------- */%0D%0AZPath %3D @@ZPath@@ %0D%0A/* -- End User Configuration ---------------- */%0D%0A%0D%0Arc %3D RxFuncAdd('SysLoadFuncs', 'RexxUtil', 'SysLoadFuncs')%0D%0Aif rc %3D 0 then call SysLoadFuncs%0D%0A%0D%0APosX %3D Arg(1)%0D%0APosY %3D Arg(2)%0D%0APipeName %3D '\pipe\zmp3'%0D%0A%0D%0Aif DragItem.0 %3D 0 then%0D%0A    if PosY >%3D 50 then do%0D%0A        select%0D%0A            when PosX <%3D 33 then do%0D%0A                rc %3D lineout(PipeName, '*pause')%0D%0A                rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A                call SetVol%0D%0A            end%0D%0A            when (PosX > 33) & (PosX <%3D 66) then do%0D%0A                rc %3D lineout(PipeName, '*stop')%0D%0A                rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A%09call KillGT%0D%0A            end%0D%0A            when PosX > 66 then do%0D%0A                rc %3D lineout(PipeName, '*vol+')%0D%0A                rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A                call SetVol%0D%0A            end%0D%0A            otherwise%0D%0A                nop%0D%0A        end%0D%0A    end%3B else do%0D%0A        select%0D%0A            when PosX <%3D 33 then do%0D%0A                rc %3D lineout(PipeName, '*previous')%0D%0A                rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A                call SetVol%0D%0A            end%0D%0A            when (PosX > 33) & (PosX <%3D 66) then do%0D%0A                rc %3D lineout(PipeName, '*next')%0D%0A                rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A                call SetVol%0D%0A            end%0D%0A            when PosX > 66 then do%0D%0A                rc %3D lineout(PipeName, '*vol-')%0D%0A                rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A                call SetVol%0D%0A            end%0D%0A            otherwise%0D%0A                nop%0D%0A        end%0D%0A    end%0D%0Aelse do%0D%0A    call LaunchZ%0D%0A    SongsList %3D ''%0D%0A    do F %3D 1 to DragItem.0%0D%0A        rc %3D SysfileTree(DragItem.F, DropDir, 'DO')%0D%0A        ItemExt %3D Translate(Right(FileSpec('name', DragItem.F), 3))%0D%0A        select%0D%0A            when DropDir.0 %3D 1 then do%0D%0A                rc %3D SysfileTree(DropDir.1 || '\*.mp3', DirItem, 'FOS')%0D%0A                do D %3D 1 to DirItem.0%0D%0A                    rc %3D Enqueue(DirItem.D)%0D%0A                end D%0D%0A            end%0D%0A            when ItemExt %3D 'MP3' then do%0D%0A                rc %3D Enqueue(strip(DragItem.F))%0D%0A            end%0D%0A            otherwise%0D%0A                do while lines(DragItem.F)%0D%0A                    listline %3D linein(DragItem.F)%0D%0A                    rc %3D Enqueue(listline)%0D%0A                end /* do..while */%0D%0A        end /* select */%0D%0A    end F%0D%0A%0D%0A    message %3D '*addliststr ' || SongsList%0D%0A    rc %3D lineout(PipeName, message)%0D%0A    rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A    call SysSleep 1%0D%0A%0D%0A    message %3D '*play'%0D%0A    rc %3D lineout(PipeName, message)%0D%0A    rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A%0D%0A    call SetVol%0D%0Aend%0D%0A%0D%0Aexit%0D%0A%0D%0ALaunchZ: procedure expose PipeName ZPath%0D%0A    status %3D stream(PipeName, 'C', 'OPEN')%0D%0A    if status \%3D 'READY:' then call SysOpenObject ZPath||'z.exe', DEFAULT, TRUE%0D%0A    rc %3D SysSleep(1)%0D%0A    return ''%0D%0A%0D%0AKillGT: procedure expose ZPath%0D%0A%09call Value 'ZCRT', '', 'OS2ENVIRONMENT'%0D%0A%09if linein(ZPath || 'gt_alive') \%3D '' then do%0D%0A%09%09call lineout ZPath || 'gt_alive'%0D%0A%09%09call lineout ZPath || 'gt_kill', 'kill'%0D%0A%09%09call lineout ZPath || 'gt_kill'%0D%0A%09end%0D%0A%09return ''%0D%0A%0D%0ASetVol: procedure expose PipeName ZPath button.%0D%0A    rc %3D SysSleep(1)%0D%0A    rc %3D lineout(PipeName, '*status volume')%0D%0A    zvol %3D linein(PipeName)%0D%0A    rc %3D stream(PipeName, 'C', 'CLOSE')%0D%0A    if zvol \%3D '' then do%0D%0A        button.icon %3D ZPath || 'zctrl' || (zvol %25 5) || '.ico'%0D%0A        button.tooltip %3D 'Volume: ' || zvol || '%25'%0D%0A    end%3B else do%0D%0A        button.icon %3D ZPath || 'zctrl0.ico'%0D%0A        button.tooltip %3D ''%0D%0A    end%0D%0A    return ''%0D%0A%0D%0AEnqueue: procedure expose SongsList%0D%0A    if SongsList %3D '' then%0D%0A        SongsList %3D arg(1)%0D%0A    else%0D%0A        SongsList %3D SongsList || '%3B' || arg(1)%0D%0A%0D%0A    return ''%0D%0A%0D%0ATrapErr:%0D%0A    nl %3D '0D0A'x%0D%0A    ErrMsg %3D 'An error occurred in the script. See below for details:'%0D%0A    ErrMsg %3D ErrMsg || nl || nl%0D%0A    ErrMsg %3D ErrMsg || 'Error: ' || rc || nl%0D%0A    ErrMsg %3D ErrMsg || 'Description: ' ErrorText(rc) || nl%0D%0A    ErrMsg %3D ErrMsg || 'Condition: ' Condition('C') || nl%0D%0A    ErrMsg %3D ErrMsg || 'Line: ' SIGL || nl%0D%0A    ErrMsg %3D ErrMsg || 'Code: ' SourceLine(SIGL)%0D%0A    ErrMsg %3D ErrMsg || nl || nl%0D%0A    ErrMsg %3D ErrMsg || 'Please send this info to <criguada@libero.it>' || nl%0D%0A    ErrMsg %3D ErrMsg || nl || nl%0D%0A    ErrMsg %3D ErrMsg || 'The program will now simulate another error, '%0D%0A    ErrMsg %3D ErrMsg || 'so that your script will stop running.'%0D%0A    rc %3D RxMessageBox(ErrMsg, 'Script error', 'OK', 'ERROR')%0D%0A    rc %3D 1/0%0D%0A    exit%0D%0A;TITLE=Z! Controller;ICONFILE= @@IconPath@@ ;CANDROP=2;