chachew Posted October 24, 2011 Share Posted October 24, 2011 (edited) I have a working application and for the most part it works perfect...but something is causing to to crash randomly and im not sure why. I get a Autoit Error that i have attached Since the script is compiled i have no idea how to look at the problem area(line 1175). Here is the script expandcollapse popup#RequireAdmin #include <Array.au3> #include <HTTP.au3> Opt("TrayIconDebug", 1) While ProcessExists("CallStatus.exe") Global $iRow = ControlListView("CallStatus","",66714, "GetItemCount") Global $iCol = ControlListView("CallStatus","",66714, "GetSubItemCount") Global $iRowCount = $iRow Global $array[$iRow][$iCol] Global $fileDir=@TempDir $fileName="callstatus.txt" If $iRow = 0 Then $iRow =1 For $r = 0 To $iRow - 1 For $c = 0 To UBound($array, 2) - 1 $array[$r][$c] = ControlListView("CallStatus","",66714,"GetText", $r, $c) Next Next _FileWriteFromArray2D($fileDir & "\" & $fileName,$array, $iRowCount) _FileUpload() Sleep(4000) WEnd Func _FileWriteFromArray2D($FILEPATH, $ARRAY, $count, $iROWstart=0, $iROWend=0, $iCOLstart=0, $iCOLend=0, $DELIM='","', $propertyname='callstatus') If Not IsArray($ARRAY) Then SetError(1) Return 0 EndIf Local $Ubound = UBound($ARRAY) If $iROWend = 0 Then $iROWend = $Ubound-1 Local $fh = FileOpen($FILEPATH, 2) If $fh = -1 Then SetError(2) Return 0 EndIf FileWrite($fh, '<%@ Page Language="C#" ContentType="text/javascript" %><%= Request.QueryString["callback"] %>({"' & $propertyname & '":[') If $count > 0 Then Select Case $iROWstart < 0 Or $iROWstart > $Ubound-1 $iROWstart = 0 ContinueCase Case $iROWend < 0 Or $iROWend > $Ubound-1 $iROWend = $Ubound-1 ContinueCase Case $iROWstart > $iROWend $tmp = $iROWstart $iROWstart = $iROWend $iROWend = $tmp EndSelect Local $Ubound2nd = UBound($ARRAY, 2) If @error = 2 Then For $i = $iROWstart To $iROWend FileWrite($fh, $ARRAY[$i]) Next Else If $iCOLend = 0 Then $iCOLend = $Ubound2nd-1 Select Case $iCOLstart < 0 Or $iCOLstart > $Ubound2nd-1 $iCOLstart = 0 ContinueCase Case $iCOLend < 0 Or $iCOLend > $Ubound2nd-1 $iCOLend = $Ubound2nd-1 ContinueCase Case $iCOLstart > $iCOLend $tmp = $iCOLstart $iCOLstart = $iCOLend $iCOLend = $tmp EndSelect For $i = $iROWstart To $iROWend $tmp = '' For $k = $iCOLstart To $iCOLend If $k < $iCOLend Then $tmp &= $ARRAY[$i][$k] & $DELIM Else $tmp &= $ARRAY[$i][$k] EndIf Next $tmp = '["' & $tmp & '"]' if $i > 0 then $tmp = ',' & $tmp endif FileWrite($fh, $tmp) Next EndIf EndIf FileWrite($fh, ']});') FileClose($fh) Return -1 EndFunc ;==>_FileWriteFromArray2D ;==================================================================================================== ; Begin file upload ;================================================================================================== Func _FileUpload() $host = "your.site.com" $port = "80" $page = "/upload.aspx" $vars = "action=upload" $url = $page&"?"&_HTTPEncodeString($vars) $socket = _HTTPConnect($host, $port) $get = _HTTPPost_File($host,$url,$socket,$fileDir & "\callstatus.txt", "uploadedfile") $recv = _HTTPRead($socket,1) ;~ MsgBox(0, "Info", "Data received:" & @CRLF & $recv[4] & @CRLF) EndFunc Func _HTTPPost_File($host, $page, $socket = -1, $file = "", $fieldname = "") Dim $command If $socket == -1 Then If $_HTTPLastSocket == -1 Then SetError(1) Return EndIf $socket = $_HTTPLastSocket EndIf $contenttype = _HTTPPost_contenttype($file) ; Maybe this can be done easier/better? $boundary = "------"&Chr(Random(Asc("A"), Asc("Z"), 3))&Chr(Random(Asc("a"), Asc("z"), 3))&Chr(Random(Asc("A"), Asc("Z"), 3))&Chr(Random(Asc("a"), Asc("z"), 3))&Random(1, 9, 1)&Random(1, 9, 1)&Random(1, 9, 1) $fileopen = FileOpen($file, 0); Open in read only mode $fileread = FileRead($fileopen) FileClose($fileopen) $extra_commands = "--"&$boundary&@CRLF $extra_commands &= "Content-Disposition: form-data; name="""&$fieldname&"""; filename=""" & $file & """" &@CRLF $extra_commands &= "Content-Type: "&$contenttype&@CRLF&@CRLF $extra_commands &= $fileread&@CRLF $extra_commands &= "--"&$boundary&"--" Dim $datasize = StringLen($extra_commands) $command = "POST "&$page&" HTTP/1.1"&@CRLF $command &= "Host: " &$host&@CRLF $command &= "User-Agent: "&$_HTTPUserAgent&@CRLF $command &= "Connection: close"&@CRLF $command &= "Content-Type: multipart/form-data; boundary="&$boundary&@CRLF $command &= "Content-Length: "&$datasize&@CRLF&@CRLF $command &= $extra_commands ;debug info If FileExists($fileDir & "\output.txt") Then FileDelete($fileDir & "\output.txt") $file = FileOpen($fileDir & "\output.txt", 1) FileWrite($file, $command) FileClose($file) ;end debug info Dim $bytessent = TCPSend($socket, $command) If $bytessent == 0 Then SetExtended(@error) SetError(2) return 0 EndIf SetError(0) Return $bytessent EndFunc Func _HTTPPost_contenttype($file = "") $fileextension = StringRight($file,4) ; I blieve these are the only 2 types that matter when uploading Switch $fileextension Case ".txt" $contenttype = "text/plain" Case Else $contenttype = "application/octet-stream" EndSwitch Return $contenttype EndFunc ;==> End _FileUploadHTTP.au3 Edited October 24, 2011 by chachew Link to comment Share on other sites More sharing options...
guinness Posted October 24, 2011 Share Posted October 24, 2011 I don't have HTTP.au3 & I'm not going to start searching the forum for it. My advice is check where there is an Array add IsArray() and/or run in SciTE which will then print the error to the console. UDF List: _AdapterConnections() • _AlwaysRun() • _AppMon() • _AppMonEx() • _ArrayFilter/_ArrayReduce • _BinaryBin() • _CheckMsgBox() • _CmdLineRaw() • _ContextMenu() • _ConvertLHWebColor()/_ConvertSHWebColor() • _DesktopDimensions() • _DisplayPassword() • _DotNet_Load()/_DotNet_Unload() • _Fibonacci() • _FileCompare() • _FileCompareContents() • _FileNameByHandle() • _FilePrefix/SRE() • _FindInFile() • _GetBackgroundColor()/_SetBackgroundColor() • _GetConrolID() • _GetCtrlClass() • _GetDirectoryFormat() • _GetDriveMediaType() • _GetFilename()/_GetFilenameExt() • _GetHardwareID() • _GetIP() • _GetIP_Country() • _GetOSLanguage() • _GetSavedSource() • _GetStringSize() • _GetSystemPaths() • _GetURLImage() • _GIFImage() • _GoogleWeather() • _GUICtrlCreateGroup() • _GUICtrlListBox_CreateArray() • _GUICtrlListView_CreateArray() • _GUICtrlListView_SaveCSV() • _GUICtrlListView_SaveHTML() • _GUICtrlListView_SaveTxt() • _GUICtrlListView_SaveXML() • _GUICtrlMenu_Recent() • _GUICtrlMenu_SetItemImage() • _GUICtrlTreeView_CreateArray() • _GUIDisable() • _GUIImageList_SetIconFromHandle() • _GUIRegisterMsg() • _GUISetIcon() • _Icon_Clear()/_Icon_Set() • _IdleTime() • _InetGet() • _InetGetGUI() • _InetGetProgress() • _IPDetails() • _IsFileOlder() • _IsGUID() • _IsHex() • _IsPalindrome() • _IsRegKey() • _IsStringRegExp() • _IsSystemDrive() • _IsUPX() • _IsValidType() • _IsWebColor() • _Language() • _Log() • _MicrosoftInternetConnectivity() • _MSDNDataType() • _PathFull/GetRelative/Split() • _PathSplitEx() • _PrintFromArray() • _ProgressSetMarquee() • _ReDim() • _RockPaperScissors()/_RockPaperScissorsLizardSpock() • _ScrollingCredits • _SelfDelete() • _SelfRename() • _SelfUpdate() • _SendTo() • _ShellAll() • _ShellFile() • _ShellFolder() • _SingletonHWID() • _SingletonPID() • _Startup() • _StringCompact() • _StringIsValid() • _StringRegExpMetaCharacters() • _StringReplaceWholeWord() • _StringStripChars() • _Temperature() • _TrialPeriod() • _UKToUSDate()/_USToUKDate() • _WinAPI_Create_CTL_CODE() • _WinAPI_CreateGUID() • _WMIDateStringToDate()/_DateToWMIDateString() • Au3 script parsing • AutoIt Search • AutoIt3 Portable • AutoIt3WrapperToPragma • AutoItWinGetTitle()/AutoItWinSetTitle() • Coding • DirToHTML5 • FileInstallr • FileReadLastChars() • GeoIP database • GUI - Only Close Button • GUI Examples • GUICtrlDeleteImage() • GUICtrlGetBkColor() • GUICtrlGetStyle() • GUIEvents • GUIGetBkColor() • Int_Parse() & Int_TryParse() • IsISBN() • LockFile() • Mapping CtrlIDs • OOP in AutoIt • ParseHeadersToSciTE() • PasswordValid • PasteBin • Posts Per Day • PreExpand • Protect Globals • Queue() • Resource Update • ResourcesEx • SciTE Jump • Settings INI • SHELLHOOK • Shunting-Yard • Signature Creator • Stack() • Stopwatch() • StringAddLF()/StringStripLF() • StringEOLToCRLF() • VSCROLL • WM_COPYDATA • More Examples... Updated: 22/04/2018 Link to comment Share on other sites More sharing options...
chachew Posted October 24, 2011 Author Share Posted October 24, 2011 guinness, ill try your suggestion...I have attached HTTP.au3 if you care to see it Link to comment Share on other sites More sharing options...
chachew Posted October 24, 2011 Author Share Posted October 24, 2011 I believe i have figured it out...It was the placement of the Global $array[$iRow][$iCol] Testing it live now so hopefully, no more crashing Link to comment Share on other sites More sharing options...
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