10-06-2023, 06:17 PM
(This post was last modified: 10-06-2023, 06:27 PM by SpriggsySpriggs.)
Here is some code to run and try it yourself.
Code: (Select All)
Option Explicit
$NoPrefix
Declare CustomType Library
Function popen%& (cmd As String, type As String)
Sub fwrite (ptr As String, Byval size As _Offset, Byval nmemb As _Offset, Byval stream As _Offset)
Sub fflush (ByVal stream As _Offset)
Sub pclose (ByVal stream As _Offset)
End Declare
Dim As Offset p: p = zProgressBar("RUNNING!", 1)
Dim As Long x
For x = 1 To 100
Delay 0.25
zStepProgressBar p, x, Str$(x) + "%"
Next
zCloseProgressBar p
Function zProgressBar%& (__title As String, __autoClose As Long)
Dim As String cmd: cmd = "zenity --progress --no-cancel --time-remaining"
If __title <> "" Then cmd = cmd + " --title='" + __title + "'"
If __autoClose <> 0 Then cmd = cmd + " --auto-close"
Dim As _Offset stream: stream = popen(cmd + Chr$(0), "w" + Chr$(0))
If stream Then zProgressBar = stream Else zProgressBar = 0
End Function
Sub zStepProgressBar (__pHandle As _Offset, __newValue As Long, __message As String)
Dim As String buf
buf = _Trim$(Str$(__newValue)) + Chr$(0)
fwrite buf, 1, Len(buf), __pHandle
fflush __pHandle
If __message <> "" Then
buf = "# " + __message + Chr$(0)
fwrite buf, 1, Len(buf), __pHandle
End If
End Sub
Sub zCloseProgressBar (__pHandle As _Offset)
pclose __pHandle
End Sub
Tread on those who tread on you