imperialawe Posted October 2, 2013 Share Posted October 2, 2013 (edited) here is my program, service monitor. Its check availability of servers. and make loongg log in excel. could not understand properly what is going wrong???ive test this function is awe sowe, but does not work in mine script ??? (((_ExcelSheetWriteFromArray thx to help!sry my worst english)))regards vyacheslav code error(124) : ==> The requested action with this object has failed.:.Range(.Cells($iExcelStartRow, $iExcelStartCol), .Cells($iExcelEndRow, $iExcelEndCol)).value = $oExcel.Application.WorksheetFunction.Transpose($aTemp).Range(.Cells($iExcelStartRow, $iExcelStartCol), .Cells($iExcelEndRow, $iExcelEndCol)).value = $oExcel.Application.WorksheetFunction.Transpose($aTemp)^ ERROR main program, expandcollapse popup #include <Excel_ext.au3> #include <Array.au3> #include <String.au3> #include <File.au3> #include <Date.au3> UDPStartup() OnAutoItExitRegister("Cleanup") dim $srv_array[999][99] , $port_pull, $cd, $oExcel _main() _save() Func _inirun() ;определение порта и кд $cd = 0 $port_pull = 65000 EndFunc Func _srvrun() ;чтение регулярных выражении из файла в массив $srv_array local $j = 1 local $file_ini = FileOpen("srv.txt", 0) While 1 Local $line = FileReadLine($file_ini) If @error = -1 Then ExitLoop local $key = stringInStr( String($line), string ("=")) $key = $key -1 $srv_array[$j] [1] = StringTrimLeft($line, ($key+1)) $srv_array[$j] [0] = StringTrimRight($line, int(StringLen($line)-$key)) $srv_array[0] [0] = $j $j +=1 WEnd EndFunc func _bind() ;назначение портов и связей local $i = 0 while $i <> $srv_array[0][0]+1 $srv_array[$i][2] = UDPBind("127.0.0.1", $port_pull +$i) $srv_array[$i][3] = $port_pull +$i $i +=1 WEnd EndFunc func _trrun() ;запуск программ и передача данных local $i = 1 while $i <> $srv_array[0][0] +1 local $s= string($srv_array[$i][1] & " "& $port_pull+$i) ;msgbox (1,"",$s) run("tr.exe " & $s) $i +=1 WEnd $i = 0 EndFunc func _Recvsrv() ;while 1 local $i = 0 while $i <> $srv_array[0][0] +1 $srv_array[$i][4+$cd] = UDPRecv($srv_array[$i][2], 15) If $srv_array[$i][4+$cd] <> "" Then ; MsgBox(0, "UDP DATA", $srv_array[$i][3],1 ) EndIf $i +=1 ;Sleep(100) ;WEnd WEnd ;MsgBox(0, "UDP DATA", $i,0.1) EndFunc Func _cleanup() UDPCloseSocket($srv_array) UDPShutdown() EndFunc ;==>Cleanup Func _visual() _arraydisplay($srv_array) ;_ExcelWriteArray($oExcel, 1, 1, $srv_array) EndFunc Func _ExcelSheetWriteFromArray($oExcel, ByRef $aArray, $iExcelStartRow = Default, $iExcelStartCol = Default, $iArrayStartRow = Default, $iArrayStartCol = Default, $iArrayEndRow = Default, $iArrayEndCol = Default) Local $iExcelEndRow = 1 Local $iExcelEndCol = 1 If Not IsObj($oExcel) Then Return SetError(1, 0, 0) If UBound($aArray, 0) <> 2 Then Return SetError(2, 0, 0) If $iExcelStartRow = Default Then $iExcelStartRow = 1 If $iExcelStartCol = Default Then $iExcelStartCol = 1 If $iArrayStartRow = Default Then $iArrayStartRow = 0 If $iArrayStartCol = Default Then $iArrayStartCol = 0 If $iArrayEndRow = Default Then $iArrayEndRow = UBound($aArray) - 1 If $iArrayEndCol = Default Then $iArrayEndCol = UBound($aArray, 2) - 1 If $iExcelStartRow < 1 Then $iExcelStartRow = 1 If $iExcelStartCol < 1 Then $iExcelStartCol = 1 If $iArrayStartRow < 0 Then $iArrayStartRow = 0 If $iArrayStartCol < 0 Then $iArrayStartCol = 0 If $iArrayEndRow < $iArrayStartRow Then Return SetError(3, 1, 0) If $iArrayEndCol < $iArrayStartCol Then Return SetError(4, 1, 0) $iExcelEndRow = $iExcelStartRow + $iArrayEndRow - $iArrayStartRow $iExcelEndCol = $iExcelStartCol + $iArrayEndCol - $iArrayStartCol ; Check if only part of the array is to written to the speadsheet If $iArrayStartRow <> 0 Or $iArrayStartCol <> 0 Or $iArrayEndRow <> UBound($aArray) - 1 Or $iArrayEndCol = UBound($aArray, 2) - 1 Then ;Copy specified array range to a temporary array Local $aTemp[$iArrayEndRow - $iArrayStartRow + 1][$iArrayEndCol - $iArrayStartCol + 1] Local $iRow = 0 Local $iCol = 0 For $i = $iArrayStartRow To $iArrayEndRow $iCol = 0 For $j = $iArrayStartCol To $iArrayEndCol $aTemp[$iRow][$iCol] = $aArray[$i][$j] $iCol += 1 Next $iRow += 1 Next With $oExcel.ActiveSheet .Range(.Cells($iExcelStartRow, $iExcelStartCol), .Cells($iExcelEndRow, $iExcelEndCol)).Select .Range(.Cells($iExcelStartRow, $iExcelStartCol), .Cells($iExcelEndRow, $iExcelEndCol)).value = $oExcel.Application.WorksheetFunction.Transpose($aTemp) EndWith Else With $oExcel.ActiveSheet .Range(.Cells($iExcelStartRow, $iExcelStartCol), .Cells($iExcelEndRow, $iExcelEndCol)).Select .Range(.Cells($iExcelStartRow, $iExcelStartCol), .Cells($iExcelEndRow, $iExcelEndCol)).value = $oExcel.Application.WorksheetFunction.Transpose($aArray) EndWith EndIf EndFunc ;==>_ExcelSheetWriteFromArray Func _save() $oExcel = _ExcelBookOpen(@ScriptDir & "\test2.xls") _visual() _ExcelSheetWriteFromArray($oExcel, $srv_array) sleep (1000) ;_ExcelBookSaveAs($oExcel, @ScriptDir & "\" & @min, "xls",0,1) ;sleep(1000) ; _ExcelSheetWriteFromArray($oExcel, $srv_array, 2, 2 , 2, 2) ;_ExcelWriteArray($oExcel, 1, 1, $srv_array) EndFunc Func _main() _inirun() _srvrun() _bind() while $cd <> 4 _trrun() sleep (2000) _Recvsrv() $cd += 1 WEnd EndFunc ;_visual() *************************tr.exe/au3 code is : ;Тело "потока" #NoTrayIcon ;#include <Excel.au3> ;#include <String.au3> ;AutoItSetOption('WinTitleMatchMode', 1) UDPStartup() OnAutoItExitRegister("Cleanup") if $CmdLineRaw= "" then exit local $p = ping(string($cmdline[1]),1000) if $p = 0 then $p = 999 sleep(1000) local $s = UDPOpen("127.0.0.1", int($cmdline[2])) UDPSend($s, string($p)) Func _cleanup() UDPCloseSocket($data) UDPShutdown() EndFunc ;==>Cleanup ;msgBox(1, "", $p &" "& $cmdline[1] &":" & $cmdline[2],3) Edited October 2, 2013 by Melba23 Added code tags Link to comment Share on other sites More sharing options...
imperialawe Posted October 2, 2013 Author Share Posted October 2, 2013 _ExcelSheetWriteFromArray fucntion took from here '?do=embed' frameborder='0' data-embedContent>> Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted October 2, 2013 Moderators Share Posted October 2, 2013 imperialawe,Welcome to the AutoIt forum. But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved the thread for you, but would ask you to be more careful in future. And when you post code please use Code tags - see here how to do it. Then you get a scrolling box and syntax colouring as you can see above now I have added the tags. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
imperialawe Posted October 2, 2013 Author Share Posted October 2, 2013 (edited) Melba23! my bad, but im trying))) about code tags, didnt know how does it work out. Now all is clear)) thx excel_ext.au3 - based on original excel.au3 +added support for xlsx, srv.txt is contain 'servers name '='ip v4 address' u could add any server. like google =8.8.8.8 local=127.0.0.1 etc Edited October 2, 2013 by imperialawe 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