Jump to content

Leaderboard

Popular Content

Showing content with the highest reputation on 07/09/2021 in all areas

  1. Yap, or maybe (overcautious?): If ((Not @error) And (IsArray($aData)=True) And (Ubound($aData,0)=2) Then
    1 point
  2. Most of the time it's because the font used to display file content doesn't have a representation for the Unicode codepoints found. But there may be other reasons. If you have an example I'll be happy to help. For instance I use the latest DejaVu Sans Mono font for all fixed-size uses, including my SciTE UTF8 console. This allows the following code ; Mixed language strings $s = "Μεγάλο πρόβλημα Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة" CW($s) ; A familly with different Fitzpatrick settings = only one glyph $s = ChrW(0xD83D) & ChrW(0xDC68) & ChrW(0xD83C) & ChrW(0xDFFB) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC69) & ChrW(0xD83C) & ChrW(0xDFFF) & ChrW(0x200D) & ChrW(0xD83D) & ChrW(0xDC66) & ChrW(0xD83C) & ChrW(0xDFFD) CW($s) to display this (CW() is a Unicode-aware ConsoleWrite): Μεγάλο πρόβλημα Большая проблема 大问题 बड़ी समस्या مشكلة كبيرة 👨🏻‍👩🏿‍👦🏽 You can also open cmd.exe then use chcp 65001 and try to paste the content of the result above. Several codepoints show as blank rectangular placeholders, others as unknown (a question mark in black hexagonal background). If you use a poorly complete Unicode font (no font cover all of Unicode) you're most likely going to see some garbage or rather many question marks, depending on how the font is coded to represent codepoints it has no representation for. EDIT: Forgot to mention that there are codepoints reserved for surrogates [0xD800, 0xDFFF] which if found as standalone cause an invalid codepoint detection by fonts rendering engines. There are also private use ranges where Unicode doesn't define a representation and currently unassigned codepoints which may get assigned in the future version of the character set.
    1 point
  3. Example code for IPv6 to uint128 code: #include "..\include\BigNum.au3" Local $sIPv6 = "2001: 4860: 4860 :: 8888" ; there shouldn't be spaces and add trailing column $sIPv6 = StringReplace($sIPv6, ' ', '') & ':' ; split string on columns Local $aIPv6 = StringRegExp($sIPv6, "([[:xdigit:]]{0,4}):", 3) ; expand double columns to strings of zeroes ; and store hex values in structure uword elements Local $tIPv6_16 = DllStructCreate("ushort[8]") Local $tIPv6_64 = DllStructCreate("uint64[2]", DllStructGetPtr($tIPv6_16)) For $i = 0 To 7 If $aIPv6[$i] == "" Then $aIPv6[$i] = "0" For $j = 0 To 7 - UBound($aIPv6) _ArrayInsert($aIPv6, $i + 1 + $j, "0") Next EndIf DllStructSetData($tIPv6_16, 1, Number("0x" & $aIPv6[$i]), 8 - $i) Next ; fetch hi and lo uint64 values Local $iHi64 = _UintToString(DllStructGetData($tIPv6_64, 1, 2), 10) Local $iLo64 = _UintToString(DllStructGetData($tIPv6_64, 1, 1), 10) ; shift left hi value by 64 bits ConsoleWrite(_bignum_parse($iHi64 & " * 18446744073709551616 + " & $iLo64) & @LF) Func _UintToString($i, $base) Return DllCall("msvcrt.dll", "wstr:cdecl", "_ui64tow", "uint64", $i, "wstr", "", "int", $base)[0] Return $aRes[0] EndFunc ;==>_UintToString The reverse conversion left as exercise to readers.
    1 point
  4. Try this : #include <Excel.au3> #include <File.au3> Local $aFile = _FileListToArrayRec(@ScriptDir, "*.xls;*.xlsx", $FLTA_FILES, Default, Default, $FLTAR_FULLPATH) If @error Then Exit ;_ArrayDisplay($aFile) Local $oExcel = _Excel_Open(False) Local $oWB, $sW57 For $i = 1 To $aFile[0] $oWB = _Excel_BookOpen($oExcel, $aFile[$i]) $sW57 = _Excel_RangeRead($oWB, Default, "W57") If StringStripWS($sW57, $STR_STRIPLEADING+$STR_STRIPTRAILING) <> "" Then ConsoleWrite($aFile[$i] & @CRLF) EndIf _Excel_BookClose($oWB) Next _Excel_Close($oExcel)
    1 point
  5. Heya, Thought i'd share an API snippet to see if there is interest in collaboration or just help out someone who's trying to make a trading bot. For the script to work you'd need to create an account on Phemex aswell as an API key, the script then connects to display your trading wallet balance. #include <Date.au3> #include <Array.au3> #include <File.au3> ;Enter your API Key and API secret Global $APIkey = "Enter your API key here" Global $ApiSecret = "Enter your API secret here" ;General variables Global $URI = "https://api.phemex.com" Global $Logfile = "log.txt" ;Object variables Global $oMyRet[2] Global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc") $WalletBalance = GetWalletBalance($APIkey, $ApiSecret) If not @error then MsgBox(0, "Balance", "Your wallet holds "&$WalletBalance/100000000&" BTC") Func GetWalletBalance($APIkey, $ApiSecret) $Method = "GET" $Action = "/accounts/accountPositions" $Parameters = "currency=BTC" $ConnectionRetry = 0 While 1 $Expires = _TimeGetStamp()+60 $Signature = _HashHMAC("SHA256", $Action&$Parameters&$Expires, $ApiSecret) $objHTTP = ObjCreate("MSXML2.ServerXMLHTTP") $objReturn = ObjCreate("Msxml2.DOMdocument.3.0") $objHTTP.open ($Method, $URI & $Action &"?"& $Parameters, False) $objHTTP.setRequestHeader ("Content-Type", "application/json") $objHTTP.setRequestHeader ("x-phemex-access-token", $APIkey) $objHTTP.setRequestHeader ("x-phemex-request-expiry", $Expires) $objHTTP.setRequestHeader ("x-phemex-request-signature", $Signature) $objHTTP.send () If @error then If $oMyRet[0] = 80020009 then $ConnectionRetry = $ConnectionRetry+1 If $ConnectionRetry = 60 then _FileWriteLog($Logfile, 'Error - GetWalletBalance - COM Error: '&$oMyRet[1]) Exit EndIf Sleep (1000) ContinueLoop EndIf EndIf If $ConnectionRetry > 1 then _FileWriteLog($Logfile, "Warning - Connection to API was lost for "&$ConnectionRetry&" seconds but ok now") $strStat = $objHTTP.status If $strStat = 200 then $strReturn = $objHTTP.responseText If NOT StringInStr($strReturn, '"code":0') then _FileWriteLog($Logfile, 'Error - GetWalletBalance - API Status '&$strStat&@CR&$strReturn) SetError (2) Return 0 EndIf $ReturnArray = StringSplit($strReturn, ":") $WalletbalanceSearch = _ArraySearch($ReturnArray, "accountBalanceEv", 0, 0, 0, 1) $WalletBalanceArray = StringSplit($ReturnArray[$WalletbalanceSearch+1],",") $WalletBalance = $WalletBalanceArray[1] Return $WalletBalance ElseIf $strStat = 500 OR $strStat = 502 OR $strStat = 503 OR $strStat = 401 Then _FileWriteLog($Logfile, "Warning - Call returned status "&$strStat&", retrying call", 1) sleep (1000) ContinueLoop Else $strReturn = $objHTTP.responseText $ReturnArray = StringSplit($strReturn, ":") _FileWriteLog($Logfile, 'Error - GetWalletBalance - API Status "'&$strStat&@CR&$strReturn) Exit EndIf WEnd EndFunc Func _TimeGetStamp() Local $av_Time $av_Time = DllCall('CrtDll.dll', 'long:cdecl', 'time', 'ptr', 0) If @error Then SetError(99) Return False EndIf Return $av_Time[0] EndFunc Func _HashHMAC($sAlgorithm, $bData, $bKey, $bRaw_Output = False) Local $oHashHMACErrorHandler = ObjEvent("AutoIt.Error", "_HashHMACErrorHandler") Local $oHMAC = ObjCreate("System.Security.Cryptography.HMAC" & $sAlgorithm) If @error Then SetError(1, 0, "") $oHMAC.key = Binary($bKey) Local $bHash = $oHMAC.ComputeHash_2(Binary($bData)) Return SetError(0, 0, $bRaw_Output ? $bHash : StringLower(StringMid($bHash, 3))) EndFunc Func _HashHMACErrorHandler($oError) ;Dummy Error Handler EndFunc Func MyErrFunc() $HexNumber = Hex($oMyError.number, 8) $oMyRet[0] = $HexNumber $oMyRet[1] = StringStripWS($oMyError.description, 3) _FileWriteLog($Logfile, "### COM Error ! Number: " & $HexNumber & " ScriptLine: " & $oMyError.scriptline & " Description: " & $oMyRet[1] & @LF ) SetError(1) Return EndFunc
    1 point
  6. Thanks... my simple question was how to pass the parameters... but anyways it seems it went in different direction, i have found my solution by performing some RND so thanks for going out of topic !! and filling up this topic without any related content.
    0 points
×
×
  • Create New...