Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 04/10/2023 in all areas

  1. Could you post the related snippet of your code. Crystal ball is at repair shop
    1 point
  2. Gianni

    AutoIt Snippets

    _WorkDay() Returns the date that is the specified number of working days before or after the start date This is a variation of a function from this post that implements more features, namely, the function allows 3 parameters: $StartDate: Date representing the start date of the count. (no check is made on the correctness of the date provided) $iDays: Number of working days before or after the start_date. A positive value indicates a future date; a negative value indicates a past date; a zero value indicates the start_date itself. (Indicating 0 the departure date is returned even if this corresponds to a non-working day, but in this case the @error flag is set to 1) $sHolidays: Optional (default 1,7). Indicate the days of the week considered non-working (not to be considered in the count). $sHolidays represents a string with any combination of digits from 1 to 7 (the comma between the digits is optional) which indicates the days of the week to be considered holidays which correspond as follows: 1=Sunday, 2 =Monday , 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday. if you want to consider working all days of the week pass an empty string then. (if, by contradiction, all seven days of the week are indicated as holidays, the day pointed to by $Days is returned anyway, but the @error flag is also set to 1) I hope there are no bugs. Have fun. #include <date.au3> _Example() ; 1=Sunday, 2 =Monday , 3=Tuesday, 4=Wednesday, 5=Thursday, 6=Friday, 7=Saturday Func _Example() Local $Start = _NowCalcDate() Local $count = 25 MsgBox(0, 'example 1', "The " & $count & "th working days past " & $Start & " is " & _WorkDay($Start, $count)) $count = -9 MsgBox(0, 'example 2', $count & " workdays ago: " & _WorkDay($Start, $count)) $Start = "2022/12/31" $count = 33 $NoCountWeekDays = '234567' ; <-- all holidays except Sunday (count only the Sunday) MsgBox(0, 'example 3', "The " & $count & "th Sunday of the 2023 is on " & _WorkDay($Start, $count, $NoCountWeekDays)) $Start = _NowCalcDate() $count = -15 ; negative $NoCountWeekDays = '134567' ; <-- all holidays except Monday (count only the Monday) MsgBox(0, 'example 4', $count & " Mondays ago was " & _WorkDay($Start, $count, $NoCountWeekDays)) EndFunc ;==>_Example ; #FUNCTION# ==================================================================================================================== ; Name ..........: _WorkDay ; Description ...: ; Syntax ........: _WorkDay([$StartDate = _NowCalcDate([, $iDays = 0[, $sHolidays = "17"]]]) ; Parameters ....: $StartDate - Start day. ; $iDays - number of WorkDays to count (positive or negative) ; $sHolidays - a string of digits indicating not working days of week. Default is "17". ; Return values .: Target date ; Author ........: Gianni ; Modified ......: ; Remarks .......: ; Related .......: ; Link ..........: ; Example .......: No ; =============================================================================================================================== Func _WorkDay($StartDate = _NowCalcDate(), $iDays = 0, $sHolidays = "17") Local $iDirection = 1 * ($iDays < 0 ? -1 : $iDays > 0), $iWeekdays = 0 Local $iWorkDays = StringRegExpReplace("1234567", "[" & StringRegExpReplace($sHolidays, "[^1234567]", "") & "]", "") Local $aYMD = StringSplit($StartDate, "/", 2) Local $nJulianDate = _DateToDayValue($aYMD[0], $aYMD[1], $aYMD[2]) If Not $iDirection Then Return SetError(False = StringInStr($iWorkDays, _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2]), 2), 0, $StartDate) If $iWorkDays = '' Then Return SetError(1, 0, _DateAdd('D', $iDays, $StartDate)) $iDays = Abs($iDays) Do $nJulianDate += $iDirection _DayValueToDate($nJulianDate, $aYMD[0], $aYMD[1], $aYMD[2]) $iWeekdays += (StringInStr($iWorkDays, _DateToDayOfWeek($aYMD[0], $aYMD[1], $aYMD[2]), 2) ? 1 : 0) Until $iWeekdays = $iDays Return SetError(0, 0, $aYMD[0] & '/' & $aYMD[1] & '/' & $aYMD[2]) EndFunc ;==>_WorkDay
    1 point
  3. Seeing all of this I would like to suggest https://github.com/microsoft/cascadia-code new monospaced font that includes programming ligatures and is designed to enhance the modern look Hope to be relevant to the topic
    1 point
  4. abberration

    Software Installer

    Hi, all. I just posted a new version 2.0 on the very first post. Go there to see it. Thoughts on the new version? I'd love to hear them!
    1 point
  5. tkminh, Easy when you know how! #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <GuiRichEdit.au3> #include <WinAPI.au3> Opt('MustDeclareVars', 1) Global $lblMsg, $hRichEdit Global $sText = "ASDF fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasldsjf llskjlg fsdfsdffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF & _ "ABC" & @CRLF & _ "ASDF fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasldsjf llskjlg fsdfsdffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF & _ "ABC" & @CRLF & _ "ASDF fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasfj asldj fdsjf ldsjffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF & _ "ABC" & @CRLF & _ "ASDF fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasfj asldj fdsjf ldsjffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" & @CRLF & _ "ABC" & @CRLF & _ "ASDF fj aslfj skldjf lkdsjf jaskdjf lsjdfldsjflasfj asldj fdsjf ldsjffdsdsfghjf lskjdf lskdjf lskdjflkjlg ashd" Main() Func Main() Local $hGui = GUICreate("RichEdit Line Finder", 320, 300) Local $hRichEdit = _GUICtrlRichEdit_Create($hGui, $sText, 10, 10, 300, 220, BitOR($ES_MULTILINE, $WS_VSCROLL, $ES_AUTOVSCROLL)) Local $hButton = GUICtrlCreateButton("Get Line", 10, 250, 80, 30) Local $hLabel = GUICtrlCreateLabel("", 100, 250, 85, 20) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE GUIDelete() Exit Case $hButton Local $iLine = ControlCommand($hGUI, "", $hRichEdit, "GetCurrentLine", "") GUICtrlSetData($hLabel, $iLine) _WinAPI_SetFocus($hRichEdit) EndSwitch WEnd EndFunc M23
    1 point
×
×
  • Create New...