Jump to content

Create mask for MonthCal


BugFix
 Share

Recommended Posts

Hi,

if you want to mark several days in an MonthCal (with _GUICtrlMonthCal_SetDayState), you must create an mask with this days in.

The following function creates the mask.

;===============================================================================
; Function Name:   _GetHexMask($sDays [, $Delim=Default])
; Description:     creates mask to mark days with _GUICtrlMonthCal_SetDayState in MonthCal
; Parameter(s):    $sDays    string with days to mark
;                  $Delim    delimiter in string, 'Default' (char from 'GUIDataSeparatorChar')
; Return Value(s): Hexstring for $aMasks
; Author(s):       BugFix (bugfix@autoit.de)
;===============================================================================
Func _GetHexMask($sDays, $Delim=Default)
    If $Delim = Default Then $Delim = Opt('GUIDataSeparatorChar')
    $aDays = StringSplit($sDays, $Delim, 2)
    Local $aHex[8] = [0,0,0,0,0,0,0,0], $pos, $out = ''
    For $i = 0 To UBound($aDays) -1
        Select
            Case $aDays[$i] < 5
                $pos = 0
            Case $aDays[$i] < 9
                $pos = 1
            Case $aDays[$i] < 13
                $pos = 2
            Case $aDays[$i] < 17
                $pos = 3
            Case $aDays[$i] < 21
                $pos = 4
            Case $aDays[$i] < 25
                $pos = 5
            Case $aDays[$i] < 29
                $pos = 6
            Case Else
                $pos = 7
        EndSelect
        $aDays[$i] -= $pos * 4
        $aHex[$pos] += 2 ^ ($aDays[$i]-1)
    Next
    For $i = 0 To UBound($aHex) -1
        $out = Hex($aHex[$i], 1) & $out
    Next
    Return '0x' & $out
EndFunc  ;==>_GetHexMask

_GetHexMask.au3

Best Regards BugFix  

Link to comment
Share on other sites

  • 7 years later...
On 12/21/2009 at 6:16 PM, BugFix said:

The following function creates the mask

It does not, for some reason, work for me. This did:

Func _GetHexMask($sDays, $Delim=Default)
    If $Delim = Default Then $Delim = Opt('GUIDataSeparatorChar')
    $aDays = StringSplit($sDays, $Delim, 2)
    Local $Mask = 0
    For $i = 0 To UBound($aDays) -1
        If $aDays[$i] < 1 Or $aDays[$i] > 31 Then ContinueLoop
        $Mask += BitShift(0x0001,-($aDays[$i] -1))
    Next
    Return $Mask
EndFunc  ;==>_GetHexMask

@BugFix, if you change your code, i'll remove this ( as it would be redundant ).
Thanks for the idea, it's handy :) 

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

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...