arts Posted June 14, 2015 Posted June 14, 2015 (edited) I'm trying to make bold some days of a calendar. I get those days from a SQLite database. Using the _GUICtrlMonthCal_SetDayState function I almost got it working. Please look at the following ugly code and help me to understand why when the variable $finalX is calculated by the script it doesn't work (no bolding days) but, if I declare the value of the same variable manually, it works... I'm sure I'm doing something stupid but can't see it. [...] ;---- BUSY DAYS if _SQLite_GetTable2d(-1,'select A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, ID from mydatabase where DEADLINE like "%' & "-" & $tTeste & "-" & '%" ORDER BY 1 D, C;', $arows, $irows, $icols) = $SQLITE_OK Then _GUICtrlListView_DeleteAllItems(GUICtrlGetHandle($lvList)) Local $final[ubound($arows)] Local $finalX = "" Local $tempDay = "" Local $val_hex[ubound($arows)] Local $val_pre = "" for $1 = 1 to ubound($arows) - 1 _GUICtrlListView_AddItem($lvList, $arows[$1][0]) for $2 = 1 to ubound($arows,2) - 1 _GUICtrlListView_AddsubItem($lvList,$1-1, $arows[$1][$2], $2) next $tempDay = StringLeft(($arows[$1][3]), 2) $val_pre = Number($tempDay); + 0 ConsoleWrite("val_pre: " & $val_pre & @CRLF) $val_hex[$1] = "BitShift(0x0001,-" & "(" & $val_pre & "-1)" & ")" ConsoleWrite("val_hex[$1]: " & $val_hex[$1] & @CRLF) next ConsoleWrite("===========================" & @CRLF) $final = _ArrayUnique($val_hex) $finalX = _ArrayToString($final, " + ", 1) $finalX = StringTrimLeft($finalX, 3); <<------ COMPUTED $finalX doesn't work ConsoleWrite("FinalX:"&$finalX & @CRLF) ;------>> When I declare the same value as the computed above, it WORKS.. --->> $finalX = BitShift(0x0001,-(28-1)) + BitShift(0x0001,-(29-1)) + BitShift(0x0001,-(30-1)) + BitShift(0x0001,-(15-1)) + BitShift(0x0001,-(7-1)) + BitShift(0x0001,-(24-1)) + BitShift(0x0001,-(1-1)) + BitShift(0x0001,-(11-1)) + BitShift(0x0001,-(2-1)) EndIf ;--------------- Local $aMasks[_GUICtrlMonthCal_GetMonthRangeSpan($idMonthCal, True)] $aMasks[1] = $finalX; <<<-------- bold days _GUICtrlMonthCal_SetDayState($idMonthCal, $aMasks) GUICtrlSetState($tabCalendar, $GUI_SHOW) EndFunc ;==>BusyDays Edited June 14, 2015 by arts
Andreik Posted June 14, 2015 Posted June 14, 2015 (edited) Try this:expandcollapse popup#include <SQLite.au3> #include <SQLite.dll.au3> #include <GUIMonthCal.au3> #include <GUIConstantsEx.au3> #include <String.au3> _SQLite_Startup() $hDB = _SQLite_Open() _SQLite_Exec($hDB,'CREATE TABLE Days(dt datetime)') _SQLite_Exec($hDB,"INSERT INTO Days SELECT '2015-06-15'") _SQLite_Exec($hDB,"INSERT INTO Days SELECT '2015-06-18'") _SQLite_Exec($hDB,"INSERT INTO Days SELECT '2015-06-21'") _SQLite_Exec($hDB,"INSERT INTO Days SELECT '2015-06-23'") _SQLite_Exec($hDB,"INSERT INTO Days SELECT '2015-06-29'") $hMain = GUICreate('Test') $hCal = _GUICtrlMonthCal_Create($hMain, 100,100, $MCS_DAYSTATE) SetBoldDays($hDB,$hCal,"SELECT strftime('%d',dt) AS Day FROM Days") GUISetState(@SW_SHOW) Do Sleep(10) Until GUIGetMsg() = $GUI_EVENT_CLOSE _SQLite_Close($hDB) _SQLite_Shutdown() Func SetBoldDays($hDB,$hCal,$sQuery) Local $aResult, $iRows, $iColumns $iRval = _SQLite_GetTable2d($hDB, $sQuery , $aResult, $iRows, $iColumns) If $iRval = $SQLITE_OK Then Local $Mask = _StringRepeat('0',31) For $Index = 1 To UBound($aResult)-1 $Mask = StringLeft($Mask,$aResult[$Index][0]-1) & '1' & StringRight($Mask,31-$aResult[$Index][0]-1) Next Local $aMasks[_GUICtrlMonthCal_GetMonthRangeSpan($hCal, True)] $aMasks[1] = Bin2Dec(StringReverse($Mask)) _GUICtrlMonthCal_SetDayState($hCal, $aMasks) Else MsgBox(0x10,'Error','Oups!') EndIf EndFunc Func Bin2Dec($B) ; Thanks to kaesereibe ;https://www.autoitscript.com/forum/topic/163035-dec2bin-bin2dec/?do=findComment&comment=1186748 Return BitOr((StringLen($B) > 1 ? BitShift(Bin2Dec(StringTrimRight($B, 1)), -1) : 0), StringRight($B, 1)) EndFunc Edited June 14, 2015 by Andreik Additional info arts 1
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now