Leaderboard
Popular Content
Showing content with the highest reputation on 11/20/2016 in Posts
-
Hello all ! Here are some functions that I have created to manipulate multidimensionnal arrays. I think some of them can be useful. Some functions are limited to 32 dimensions. List of the functions : _ArrayAssign : Assigns an array variable by name with the data. _ArrayCompare : Checks if two array are identical (size or data) _ArrayDeclare : Creates an empty array with the specified size. _ArrayDeclareFromString : Creates an array from an array declaration type string. _ArrayEnumValues : Returns all values and indexes of an array in a 2D array. _ArrayEval : Returns the array from an array variable name, or the value of an array element by its name _ArrayShuffleMultiDim : Shuffle the whole data of an array. _ArrayToDeclarationString : Returns an array declaration string. The returned string can be used with _ArrayDeclareFromString. Some examples : _Example1() _Example2() _Example3() _Example4() _Example5() _Example6() _Example7() Func _Example1() Local $aArray1 = _ArrayDeclareFromString("[ [ 1, 2, 3], ['a', 'b', 'c'], [True, False, Null], [], [0x10, 1.3, -10.2E-3] ]") _ArrayDisplay($aArray1, "_ArrayDeclareFromString") EndFunc Func _Example2() Global $aArray2 = [[1,2,""], [4,5,6]] ; Must be a global variable _ArrayDisplay($aArray2, "Before _ArrayAssign") _ArrayAssign("aArray2[0][2]", 3) _ArrayDisplay($aArray2, "After _ArrayAssign") EndFunc Func _Example3() Local $aValues = [ [1,2,3], ['a', True, False] ] _ArrayAssign("aArray3", $aValues) Local $aRet = _ArrayEval("aArray3") _ArrayDisplay($aRet, "_ArrayEval") MsgBox(0, "", "Value for aArray3[1][0] : " & _ArrayEval("aArray3[1][0]") ) EndFunc Func _Example4() Local $aArray3 = [ [[ "000", "001", "002"], ["010", "011", "012"]] , [[ "100", "101", "102"], ["110", "111", "112"]] ] Local $aArray = _ArrayEnumValues($aArray3) _ArrayDisplay($aArray) EndFunc Func _Example5() Local $aArray4 = [ [1, 2, 3], [], ['A string', "That's so ""cool"" !"], [0x10, 1.3, -10.2E-3] ] Local $sDeclaration = _ArrayToDeclarationString($aArray4) MsgBox(0, "", $sDeclaration) EndFunc Func _Example6() Local $aArray5 = [ [[ "000", "001", "002"], ["010", "011", "012"]] , [[ "100", "101", "102"], ["110", "111", "112"]] ] Local $aBefore = _ArrayEnumValues($aArray5) _ArrayDisplay($aBefore, "Before shuffle") _ArrayShuffleMultiDim($aArray5) Local $aAfter = _ArrayEnumValues($aArray5) _ArrayDisplay($aAfter, "After shuffle") EndFunc Func _Example7() Local $aArray6 = [[1, 2], [3, 4]] Local $aArray7 = [["", 2], [3, 4]] Local $iRet = _ArrayCompare($aArray6, $aArray7) If $iRet Then MsgBox(0, "", "Arrays have exactly the same size") Else MsgBox(0, "", "Arrays do not have the same size and dimension.") EndIf $iRet = _ArrayCompare($aArray6, $aArray7, 1) If $iRet Then MsgBox(0, "", "Arrays have exactly the same size and values") Else MsgBox(0, "", "Arrays do not have the same size and values.") EndIf EndFunc ArrayMultiDim.au31 point
-
Remember the StringSplit, the number of sites is in $aList[0] Case $Button4 If GUICtrlRead($Button4) = "Next site" Then $n += 1 If $n > $aList[0] Then MsgBox(0,"finish","links it is over") Continueloop EndIf GUICtrlSetData($Input1, $aList[$n] ) GUICtrlSetData($Button4, "Open Site") Else ShellExecute(GUICtrlRead($Input1)) GUICtrlSetData($Button4, "Next site") EndIf1 point
-
Shouldn't be too hard. Where do the other values for the combo box 2 come from? I ask because you can not just change a single entry (in this case the first one) of a combo. When you set a value that exists in this value is selcted as the default value. Else the new value overwrites the existing combo. So if we want to change the first entry then we need to set the whole combo to the new first line plus all "products" the user can select.1 point
-
What's wrong on the solution @UEZ posted in1 point
-
Not sure the way you chose is very convenient... but this works #include <GUIConstantsEx.au3> #include <StringConstants.au3> #Include <Array.au3> ; sample list $sList = "https://www.autoitscript.com" & @crlf & "https://www.google.com" $Form1 = GUICreate("Form1", 473, 327, 192, 124) $Edit1 = GUICtrlCreateEdit("", 64, 72, 329, 169) GUICtrlSetData($Edit1, $sList) $Input1 = GUICtrlCreateInput("", 64, 32, 329, 21) $Button4 = GUICtrlCreateButton("Next Site", 72, 256, 75, 25) GUISetState(@SW_SHOWNA) $aList = StringSplit(GUICtrlRead($Edit1), @crlf, $STR_ENTIRESPLIT) ;_ArrayDisplay($aList) $n = 0 While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button4 If GUICtrlRead($Button4) = "Next site" Then $n += 1 GUICtrlSetData($Input1, $aList[$n] ) GUICtrlSetData($Button4, "Open Site") Else ShellExecute(GUICtrlRead($Input1)) GUICtrlSetData($Button4, "Next site") EndIf EndSwitch WEnd1 point
-
I'm not sure I fully understand. You want to have one combo to select the language from You want to have a second combo to select a product from This product combo should list the products in the language the user has selected before?1 point
-
I see. But why not use a simple label? So you have a combo to select the language from and a label that simply says (in the currently selected language): "Please select a language".1 point
-
What's the purpose of the second combo?1 point
-
You need a helper function with ByRef parameter. Simple example: #include <Array.au3> Local $a[3] = [1, 2], $b[2] = [3, 4] $a[2] = $b ConsoleWrite(($a[2])[0] & " " & ($a[2])[1] & @CRLF) ModArray($a[2], 0, "Test") _ArrayDisplay($a[2]) Func ModArray(ByRef $aArray, $iElement, $value) $aArray[$iElement] = $value EndFunc Otherwise a copy of the array will be created.1 point
-
1 point
-
Yes but only when using the Full SciTE4AutoIt3 version, which runs AutoIt3Wrapper when doing a Run or Compile from within SciTE ! Jos1 point
-
1 point
-
I would suggest here (simplest way) to use any painting tool to resize the image and additional apply a sharpen filter. Afterwards add it to your script.1 point
-
This app has been designed to help search for text within files, and has the following features: The phrase searched for can be case sensitive or not The file search can be recursive through subdirectories or not File masks for included or excluded file types are available I posted this in another thread as it was when I last worked on it last June, and got a very helpful tip from Melba23 regarding how to make .docx and .xlsx files searchable (though I did it in a very different way ). I now also use UEZ's File to Base64 String Code Generator to bundle the 7-Zip dll and exe in to the script for use on the new Office files, so the script is rather large. The other major change from the earlier version I posted is that if the file being searched is over 32MB then the file is searched in chunks to avoid the horrible memory allocation errors I got during testing when _WinAPI_ReadFile tried reading a 3GB video file in one piece. If there are any file types that need special attention to open properly or other feature requests please let me know. Ian Updated code 3/9/15, previous version downloaded 89 times Updated code 3/11/15, bug fix and added topmost option Find In File.7z1 point
-
Here are 2 examples using _IE* funcs #include <IE.au3> #include <Array.au3> $oIE = _IECreate("http://www.xe.com/", 0, 0) $oTable = _IETableGetCollection($oIE, 0) $aTableData = _IETableWriteToArray($oTable, 1) _IEQuit($oIE) For $i = 2 To 6 step 2 For $j = 10 to 1 step -1 $aTableData[$i][$j] = $aTableData[$i][$j-1] Next Next _ArrayDisplay($aTableData) #include <IE.au3> #include <Array.au3> $oIE = _IECreate("http://www.dailyfx.com/", 0, 0) $oTable = _IETableGetCollection($oIE, 18) $aTableData = _IETableWriteToArray($oTable, 1) _IEQuit($oIE) _ArrayDisplay($aTableData) The IE way is efficient but slow so you can also do like this : $html = BinaryToString(InetRead("http://www.dailyfx.com/")) $txt = StringRegExpReplace($html, '(?s).+?bank-rates-widget-table.+?<tr>(.+?)</tbody>.+', '$1') $titles = StringRegExp($txt, '<th.*?>([^<]+)', 3) $rates= StringRegExp($txt, '<td.*?>([^<]+)', 3) Dim $array[UBound($rates)/3+1][3] For $i = 0 to 2 $array[0][$i] = $titles[$i] Next For $i = 0 to UBound($array)-2 $array[$i+1][0] = $rates[$i*3] $array[$i+1][1] = $rates[$i*3+1] $array[$i+1][2] = $rates[$i*3+2] Next _ArrayDisplay($array)1 point
-
uhhhhhh... Limits???? In autoit? Yea, right... I for one also thought there were limits in autoit, nah man there's no limits, I believe someone smart once said :" you get out of autoit what put into autoit" and that's undeniably true, for one it might not use asp.net development environment but there's a huge library of pretty much everything you need to create about anything, it's solely up to you. I'm a newbie developer and I am developing software used by meduim to large sized companies, like a databasis for a university that needs to have all their students' information on record, Guesthouse managing software for our local Guesthouses and GuestLodges... and autoit has proven itself a more than worthy development programming language... JUST LOOK AT ALL PROGRAMMERS ON THIS FORUM NEWBIE OR NOT... it's all up to you, it was a lesson I had to learn myself and the bonus is, autoit is waaaaaaaaaaayyyyyy easy unlike other languages you dont need to go for courses to be able to develop in autoit thats a +100 to autoit...1 point
-
OK, here one short example how you can fill a form with Adobe Acrobat $$$ version from 5-X using JS: ;; user settings $FilePath = "C:\temp.pdf" ; fillable pdf with one form field $fieldname = "Test1" ;form field name $fileOut = "c:\temp_filled.pdf" ;; application $App = ObjCreate("AcroExch.App") ;; start Adobe Acrobat $App.Show ;; show Acrobat or comment out for hidden mode ;; actions $AVDoc = ObjCreate("AcroExch.AVDoc") ;; connect to Ac Viewer If $AVDoc.Open($FilePath,"") Then ;; open the file $PDDoc = $AVDoc.GetPDDoc ;; get PdDoc from AvDoc $AForm = ObjCreate("AFormAut.App") ;;connect to AForm API $EX = "" _ ;; write some JS-code to a variable & ' var f = this.getField("'&$fieldname&'")' & @LF _ & ' f.value = "hello"' ;msgbox(0,"",$ex) $AForm.Fields.ExecuteThisJavaScript($EX) ;;execute the Js-Code $PDDoc.save(1,$fileOut) $app.closeAlldocs() $app.exit() Else msgbox(0,"","Coudn't open report") endif ;; release objects $AForm = 0 $AvDoc = 0 $PdDoc = 0 $App = 0 If you want to fill a pdf only with free Reader you can write and execute an FDF-File: #include <GUIConstants.au3> ; Setting variables Global $sFilename = "C:\Temp.pdf" If FileExists($sFilename) Then $sX = StringReplace($sFilename,"\","/") $sX = StringReplace($sX,":","") $sPdfNM = "/" &$sX $FdfNM = FileOpen( "C:\Temp.FDF",2) $Ex = "%FDF-1.2 %% Fill Form Fields %%" &@CRLF _ &"1 0 obj << /FDF << /F (" &$sPdfNM &") /Fields " &@CRLF _ &"[" &@CRLF _ & '<</T(Test1)/V(MyTestValue)>>' &@CRLF _ &"]>>>>" &@CRLF _ & "endobj" &@CRLF _ & "trailer" &@CRLF _ & "<</Root 1 0 R >>" &@CRLF _ & "%%EOF" FileWrite($FdfNM,$Ex) FileClose($FdfNM) RunWait(@ComSpec & " /c " & 'start c:\Temp.fdf' , "", @SW_HIDE) ;FileDelete("C:\temp.fdf") endif But with Reader you can only save it if the rights are enabled. That normaly not or not ever. The free commandline tool pdftk.exe (well known and tested) can read pdf field-values, prefill or fill and save it. In the next example I added that: #include <GUIConstants.au3> ; Setting variables Global $sFilename = "C:\Temp.pdf" If FileExists($sFilename) Then $sX = StringReplace($sFilename,"\","/") $sX = StringReplace($sX,":","") $sPdfNM = "/" &$sX $FdfNM = FileOpen( "C:\Temp.FDF",2) $Ex = "%FDF-1.2 %% Fill Form Fields %%" &@CRLF _ &"1 0 obj << /FDF << /F (" &$sPdfNM &") /Fields " &@CRLF _ &"[" &@CRLF _ & '<</T(Test1)/V(MyTestValue)>>' &@CRLF _ &"]>>>>" &@CRLF _ & "endobj" &@CRLF _ & "trailer" &@CRLF _ & "<</Root 1 0 R >>" &@CRLF _ & "%%EOF" FileWrite($FdfNM,$Ex) FileClose($FdfNM) RunWait(@ComSpec & " /c " & 'start c:\Temp.fdf' , "", @SW_HIDE) ;FileDelete("C:\temp.fdf") endif if FileExists(@scriptdir&"/pdftk.exe") Then $OK=msgbox(51,"Pdf-Fill","Do you want "&@lf&" only to pre-fill (keep editable) or "&@lf&" pre-fill and flatten (fix content)?"&@lf&@lf&"Keep editable?") consolewrite($OK&@lf) select case $OK = 6 ;yes if FileExists("C:\temp_fe.pdf") then FileDelete("C:\temp_fe.pdf") Runwait(@ComSpec & " /c " &@scriptdir&"\pdftk.exe "&$sFilename&" fill_form c:\Temp.fdf output C:\temp_fe.pdf", "", @SW_HIDE) shellexecute("C:\temp_fe.pdf") case $OK = 7 ; no if FileExists("C:\temp_ff.pdf") then FileDelete("C:\temp_ff.pdf") RunWait(@ComSpec & " /c " &@scriptdir&"\pdftk.exe "&$sFilename&" fill_form c:\Temp.fdf output C:\temp_ff.pdf flatten", "", @SW_HIDE) shellexecute("C:\temp_ff.pdf") case $OK = 2 ; cancel msgbox(0,"Pdf-Fill","Job canceled") EndSelect endif If you don't have a fillable PDF-Form to test it, you just can set it up with Adobe Acrobat. If you don't want to spent money for that you can also use free Open-Office, which can also write fillable PDF-forms. HTH, Reinhard1 point
-
This is an example of a universal date converter from your PC local date format to any format you could need to use. I couldn't find any good solution on the forum, so I re-engineered an example of DaRam. This should work with any regional setting date format. The script reads the Local date format in your registry setting. RegRead("HKCU\Control Panel\International", "sShortDate") I hope you can use it. GreenCan #cs Description: Universal date format converter Converts the (default regional setting) PC Date format into any other specified date format: - convert date into another date format (for example ddd dd MMMM, yyyy) - convert date into day (d or dd) - convert date into month ( m, mm or mmm) - convert date into year (yy or yyyy) Parameter(s): $InputDate Input date $DateFmt - Format of input date (optional), if omitted, will return date in mm/dd/yyyy Requirement(s): <DateCalc.au3> The udf is included in this script Return Value(s):On Success - Date in in requested format On Error - @ERROR 1 (input date badly formatted) - Error Message Author(s): GreenCan Note(s): Part of source code was borrowed from the Date conversion example provided by DaRam http://www.autoitscript.com/forum/index.php?showtopic=76984&view=findpost&p=557834 DateCalc.au3 (_DateCalc udf) by Sean Hart http://www.autoitscript.com/forum/index.php?showtopic=14084&view=findpost&p=96173 Syntax: DateFormat( $Date , $DateFormat ) Example: DateFormat( _NowCalcDate() , "dd-MM-yyyy" ) #ce #include <Date.au3> #include <DateTimeConstants.au3> #include <GUIConstants.au3> ;#include <DateCalc.au3> Global $sDateFormat = RegRead("HKCU\Control Panel\International", "sShortDate") ; This is the date format of your PC ; example 1: Using GUICtrlCreateDate in a GUI $Form1 = GUICreate("PC DateFormat: " & $sDateFormat, 290, 112, 193, 115) $Label1 = GUICtrlCreateLabel("Date:", 8, 8, 90, 17) $Input1 = GUICtrlCreateDate(_Date_Time_GetLocalTime(), 100, 8, 180, 21,$DTS_SHORTDATEFORMAT ) ; $DTS_SHORTDATEFORMAT $DTS_LONGDATEFORMAT $Label2 = GUICtrlCreateLabel("Date Time Format:", 8, 36, 90, 17) $Input2 = GUICtrlCreateInput("ddd dd MMMM, yyyy", 100, 33, 180, 21) $Button1 = GUICtrlCreateButton("&Convert", 8, 64, 89, 25, 0) $Input3 = GUICtrlCreateInput("", 100, 64, 180, 24) GUISetState(@SW_SHOW) GUICtrlSetData( $Input3, DateFormat( GUICtrlRead($Input1), GUICtrlRead($Input2) ) ) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 GUICtrlSetData( $Input3, DateFormat( GUICtrlRead($Input1), GUICtrlRead($Input2) ) ) EndSwitch Wend ; Example 2: Direct conversion (make sure that the input date is in the PC sShortDate format, see your local settings) $Date = "05/12/2009" ConsoleWrite ( DateFormat( $Date , "dd-MM-yyyy" ) & @CR) ConsoleWrite ( DateFormat( $Date , "MMM" ) & @CR) ConsoleWrite ( DateFormat( $Date , "d" ) & @CR) ConsoleWrite ( DateFormat( $Date , "yy" ) & @CR) ; Example 3: Error simulation $NewDate = DateFormat( "35/12/2009" , "dd-MM-yyyy" ) If @error Then ConsoleWrite ( $NewDate & @CR) Else ConsoleWrite ( $NewDate & @CR) EndIf #FUNCTION# ============================================================== Func DateFormat($InputDate, $DateFmt = "mm/dd/yyyy") If StringLen($InputDate) < 6 Then SetError (1) Return "Invalid Date" ; ddmmyy = 6 EndIf If $DateFmt = "" Then $DateFmt = "dd/mm/yyyy" Local $DateValue = _DateCalc ($InputDate,$sDateFormat) ; convert the date to yyyy/mm/dd $DateValue = StringSplit($DateValue, "/") If @error Then SetError (1) Return "Invalid Date " & $InputDate EndIf If $DateValue[0] < 3 Then ; less than 3 parts in date not possible SetError (1) Return "Invalid Date " & $InputDate EndIf If Int(Number($DateValue[1])) < 0 Then SetError (1) Return "Invalid Year in Date" EndIf If Int(Number($DateValue[2])) < 1 Or Int(Number($DateValue[2])) > 12 Then SetError (1) Return "Invalid Month in Date" EndIf If Int(Number($DateValue[3])) < 1 Or Int(Number($DateValue[3])) > 31 Then SetError (1) Return "Invalid Day in Date" EndIf If Int(Number($DateValue[1])) < 100 Then $DateValue[1] = StringLeft(@YEAR,2) & $DateValue[1] $InputDate = $DateFmt $InputDate = StringReplace($InputDate, "d", "@") ; Convert All Day References to @ $InputDate = StringReplace($InputDate, "m", "#") ; Convert All Month References to # $InputDate = StringReplace($InputDate, "y", "&") ; Convert All Year References to & $InputDate = StringReplace($InputDate, "&&&&", $DateValue[1]) ; Century and Year $InputDate = StringReplace($InputDate, "&&", StringRight($DateValue[1],2)) ; Year Only $InputDate = StringReplace($InputDate, "&", "") ; Discard leftover Year Indicator $InputDate = StringReplace($InputDate, "####", _DateMonthOfYear($DateValue[2], 0)) ; Long Month Name $InputDate = StringReplace($InputDate, "###", _DateMonthOfYear($DateValue[2], 1)) ; Short Month Name If StringLen($DateValue[1]) < 2 Then $InputDate = StringReplace($InputDate, "##", "0" & $DateValue[2]) ; Month Number 2 Digit Else $InputDate = StringReplace($InputDate, "##", $DateValue[2]) ; Month Number 2 Digit EndIf $InputDate = StringReplace($InputDate, "#", int($DateValue[2])) ; Month Number $iPos = _DateToDayOfWeek($DateValue[1], $DateValue[2], $DateValue[3]) ; Day of Week Number $InputDate = StringReplace($InputDate, "@@@@", _DateDayOfWeek($iPos, 0)) ; Long Weekday Name $InputDate = StringReplace($InputDate, "@@@", _DateDayOfWeek($iPos, 1)) ; Short Weekday Name $InputDate = StringReplace($InputDate, "@@", $DateValue[3]) ; Day Number 2 Digit $InputDate = StringReplace($InputDate, "@", int($DateValue[3])) ; Day Number Return $InputDate EndFunc ;==>DateFormat #FUNCTION# ============================================================== ;=============================================================================== ; ; Description: Returns the Date [and time] in format YYYY/MM/DD [HH:MM:SS], ; give the date / time in the system or specified format. ; Parameter(s): $sSysDateTime - Input date [and time] ; $dFormat - Format of input date (optional) ; $tFormat - Format of input time (optional) ; Requirement(s): None ; Return Value(s): On Success - Date in in format YYYY/MM/DD [HH:MM:SS] ; On Error - @ERROR - 1 (input date badly formatted) ; - @ERROR - 2 (input time badly formatted) ; Author(s): Sean Hart <autoit@hartmail.ca> ; Note(s): Date format can be provided without any separators only in ; the format YYYYMMDD. ; If system format is used it is current user format, NOT ; default user format (which may be different). ; 2 digit years converted: 81 - 99 -> 1981-1999 ; 00 - 80 -> 2000-2080 ; ;=============================================================================== #include-once Func _DateCalc($sSysDateTime, $dFormat = "", $tFormat = "") Local $sDay Local $sMonth Local $sYear Local $sHour Local $sMin Local $sSec ;Local $dFormat Local $dSep ;Local $tFormat Local $tSep Local $am Local $pm Local $split1[9] Local $split2[9] Local $sSysDate Local $sSysTime Local $isAM Local $isPM Local $sTestDate ; Read default system time formats and separators from registry unless provided if $dFormat = "" then $dFormat = RegRead ("HKEY_CURRENT_USER\Control Panel\International", "sShortDate") $dSep = RegRead ("HKEY_CURRENT_USER\Control Panel\International", "sDate") else ; Extract separator from date format by finding first non recognised character for $x = 1 to StringLen ($dFormat) if (not (StringMid ($dFormat, $x, 1) = "y")) AND (not (StringMid ($dFormat, $x, 1) = "m")) AND (not (StringMid ($dFormat, $x, 1) = "d")) then $dSep = StringMid ($dFormat, $x, 1) ExitLoop endif next endif if $tFormat = "" then $tFormat = RegRead ("HKEY_CURRENT_USER\Control Panel\International", "sShortDate") $tSep = RegRead ("HKEY_CURRENT_USER\Control Panel\International", "sDate") $am = RegRead ("HKEY_CURRENT_USER\Control Panel\International", "s1159") $pm = RegRead ("HKEY_CURRENT_USER\Control Panel\International", "s2359") else ; Extract separator from time format by finding first non hour character for $x = 1 to StringLen ($tFormat) if (not (StringMid ($tFormat, $x, 1) = "h")) then $tSep = StringMid ($tFormat, $x, 1) ExitLoop endif next $am = "AM" $pm = "PM" endif ; Separate date and time if included (make break at first space) if StringInStr ($sSysDateTime, " ") then $sSysDate = StringLeft ($sSysDateTime, StringInStr ($sSysDateTime, " ") - 1) $sSysTime = StringStripWS (StringReplace ($sSysDateTime, $sSysDate, ""), 1) else $sSysDate = $sSysDateTime $sSysTime = "" endif ; Simple check of input date format (look for separators and unexpected non numeric characters) $sTestDate = StringReplace ($sSysDate, $dSep, "") $sTestDate = "1" & $sTestDate if (String (Number ($sTestDate)) <> $sTestDate) then SetError (1) Return endif if (StringInStr ($sSysDate, $dSep) = 0) AND ($dSep <> "") then SetError (1) Return endif if $sSysTime <> "" then $sTestDate = StringReplace ($sSysTime, $tSep, "") $sTestDate = StringReplace ($sTestDate, $am, "") $sTestDate = StringReplace ($sTestDate, $pm, "") $sTestDate = StringReplace ($sTestDate, " ", "") $sTestDate = "1" & $sTestDate if (StringInStr ($sSysTime, $tSep) = 0) or (String (Number ($sTestDate)) <> $sTestDate) then SetError (2) Return endif endif ; Break up date components (using format as a template), unless format is YYYYMMDD if $dFormat = "YYYYMMDD" then $sYear = StringMid ($sSysDate, 1, 4) $sMonth = StringMid ($sSysDate, 5, 2) $sDay = StringMid ($sSysDate, 7, 2) else $split1 = StringSplit ($dFormat, $dSep) $split2 = StringSplit ($sSysDate, $dSep) for $x = 1 to $split1[0] if StringInStr ($split1[$x], "M") then $sMonth = $split2[$x] if StringInStr ($split1[$x], "d") then $sDay = $split2[$x] if StringInStr ($split1[$x], "y") then $sYear = $split2[$x] next endif ; Pad values with 0 if required and fix 2 digit year if StringLen ($sMonth) = 1 then $sMonth = "0" & $sMonth if StringLen ($sDay) = 1 then $sDay = "0" & $sDay if StringLen ($sYear) = 2 then if $sYear > 80 then $sYear = "19" & $sYear else $sYear = "20" & $sYear endif endif ; Break up time components (if given) if $sSysTime <> "" then ; Look for AM/PM and note it, then remove from the string $isPM = 0 if StringInStr ($sSysTime, $am) then $sSysTime = StringReplace ($sSysTime, " " & $am, "") $isPM = 1 elseif StringInStr ($sSysTime, $pm) then $sSysTime = StringReplace ($sSysTime, " " & $pm, "") $isPM = 2 endif $split1 = StringSplit ($tFormat, $tSep) $split2 = StringSplit ($sSysTime, $tSep) $sSec = "00" for $x = 1 to $split2[0] if StringInStr ($split1[$x], "h") then $sHour = $split2[$x] if StringInStr ($split1[$x], "m") then $sMin = $split2[$x] if StringInStr ($split1[$x], "s") then $sSec = $split2[$x] next ; Clean up time values (change hour to 24h and 0 pad values) if ($isPM = 1) and ($sHour = 12) then $sHour = "00" if ($isPM = 2) and ($sHour < 12) then $sHour = $sHour + 12 if StringLen ($sHour) = 1 then $sHour = "0" & $sHour if StringLen ($sMin) = 1 then $sMin = "0" & $sMin if StringLen ($sSec) = 1 then $sSec = "0" & $sSec ; Return date with time Return $sYear & "/" & $sMonth & "/" & $sDay & " " & $sHour & ":" & $sMin & ":" & $sSec else ; Return date only Return $sYear & "/" & $sMonth & "/" & $sDay endif EndFunc ;==>_DateCalc #FUNCTION# ==============================================================1 point