Jump to content

Progress History UDF


JRSmile
 Share

Recommended Posts

Happy NEW Year, finaly after a lot of faitures i finished my first UDF,

it holds two functions: _ProgHisInit() and _ProgHisSet()

Here is my sample code, please try and make comments to it.

UDF, save as GuiProgHis.au3:

#region Header
#cs
    Title:   Progress History UDF Library for AutoIt3
    Filename:  GuiProgHis.au3
    Description: A collection of functions for creating and updating a Progress History.
    Author:   JRSmile
    Version:  T1.0
    Last Update: 1/1/06
    Requirements: AutoIt3 Beta (3.1.1.63 or higher), Developed/Tested on Windows2000 Professional
    Notes:
    This is just a simple POC release, it is not very fast and hast a mad cpu performance as result.
    
    Update History:
    ===================================================
    T1.0 1/1/06
    Initial Release - error handling is not present right now, documentation has just begun, only initial UDF standards met.
    
    \\\ Core Functions
    
    _ProgHisInit()
    Creates a progress history out of progressbars
    
    _ProgHisSet()
    Updates the progress history created with _ProgHisInit()
 
#ce
#endregion
#region Core functions
;===============================================================================
;
; Function Name:    _ProgHisInit()
; Description:    Creates a progress history out of progressbars
; Parameter(s):  $x           - relative position in the GUI x-axis
;                  $y             - relative position in the GUI y-axis
;                  $width       - width of the history
;                  $hight       - hight of the history
;                  $bgcolor   - background color of the history (default: black)
;                  $color       - color of the history (default: green)
; Requirement(s):   $x,$y,$width,$hight
; Return Value(s):  On Success - Creates the Progress history at the desired coordinates.
;                  On Failure - NONE
; Author(s):        JRSmile
;
;===============================================================================
;
func _ProgHisInit($x,$y,$i_width,$i_hight,$b_bgcolor = 0x000000,$b_color = 0x00FF00)
    $s_list = ""
    for $i = 1 to $i_width step 2
        $s_list &= "|" & GuiCtrlCreateProgress($x + $i, $y, 3, $i_hight,$PBS_VERTICAL + $PBS_SMOOTH)
        GUICtrlSetBkColor(-1,$b_bgcolor)
        GUICtrlSetColor(-1,$b_color)
        GUICtrlSetTip(-1,"0%")
    next
    $ai_List = StringSplit($s_list,"|")
    return $ai_List
EndFunc  ;==>_ProgHisInit


;===============================================================================
;
; Function Name:    _ProgHisSet()
; Description:    Updates the progress history created with _ProgHisInit()
; Parameter(s):  $val         - the new value to be added to the history
;                  $ai_List     - the progress history handler to be updated
; Requirement(s):   $val,$ai_List
; Return Value(s):  On Success - Displays the updated history
;                  On Failure - NONE
; Author(s):        JRSmile
;
;===============================================================================
;
func _ProgHisSet($i_val,$ai_List)
    Local $s_List,$ai_UpdatedList
    for $i = 2 to $ai_List[0]
        $s_List &= "|" & GUICtrlRead($ai_List[$i])
    Next
    $ai_UpdatedList = StringSplit($s_List,"|")
    For $i = 0 To (UBound($ai_UpdatedList) - 2)
        $ai_UpdatedList[$i] = $ai_UpdatedList[$i + 1]
    Next
    Local $i = (UBound($ai_UpdatedList) - 1)
    $ai_UpdatedList[$i] = $i_val
    for $i = 2 to $ai_List[0]
        GUICtrlSetData($ai_List[$i],$ai_UpdatedList[$i])
        GUICtrlSetTip($ai_List[$i],$ai_UpdatedList[$i] & "%")
    Next
EndFunc  ;==>_ProgHisSet
#endregion

the example, save in the same folder:

#include <GuiConstants.au3>
#include <GuiProgHis.au3>
opt("GUIOnEventMode",1)
GuiCreate("Progress History Sample GUI", 400, 80)
; easy way to integrate it in a gui
$ai_List = _ProgHisInit(0,0,400,80,0x000000,0x00FF00) 
GuiSetState()
GUISetOnEvent($GUI_EVENT_CLOSE,"close")

While 1
; just give it a variable and everything is done for you.
    _ProgHisSet(Random(1,100,1),$ai_List)
    sleep(100)
WEnd

func close()
    Exit
EndFunc
$a=StringSplit("547275737420796F757220546563686E6F6C75737421","")
For $b=1 To UBound($a)+(-1*-1*-1)step(2^4/8);&$b+=1*2/40*µ&Asc(4)
Assign("c",Eval("c")&Chr(Dec($a[$b]&$a[$b+1])));''Chr("a")&"HI"
Next ;time_U&r34d,ths,U-may=get$the&c.l.u.e;b3st-regards,JRSmile;
MsgBox(0x000000,"",Eval("c"));PiEs:d0nt+*b3.s4d.4ft3r.1st-try:-)
Link to comment
Share on other sites

  • Moderators

Hey that's really neat for your first UDF JRSmile... no comments, I just ran the code, hadn't looked at it yet... but good job!

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...