Fink89 Posted May 8, 2018 Share Posted May 8, 2018 (edited) I use _FileWriteFromArray to write data output. $FileOpen = FileOpen(@ScriptDir & '\Test\' & $i & '.txt', 2 + 8 + 128) _FileWriteFromArray($FileOpen, $array) FileClose($FileOpen) If I write 5-10 file, data written good. But I write more than 200+ file , file is empty. Please help me fix this Edited May 8, 2018 by Fink89 Link to comment Share on other sites More sharing options...
Andreik Posted May 8, 2018 Share Posted May 8, 2018 You know that your code can't reproduce your problem since we have to guess what exactly contains $array. When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Fink89 Posted May 8, 2018 Author Share Posted May 8, 2018 expandcollapse popupfunc getall() $all=_GUIList_GetAllItems($mylist) ;$Result = _ArrayFindAll($all,$b ) _GUICtrlListBox_AddString($totalview,ubound($all)) ; _GUICtrlListBox_AddString($selectview,$Result[0]+1) For $z=0 to ubound($all)-1 $FileOpen = FileOpen(@ScriptDir & '\Test\' & $all[$z] & '.txt', 2 + 8 + 128) $search = 'https://api.ethplorer.io/getAddressInfo/' & $all[$z] & '?apiKey=freekey' $rq1 = _HttpRequest(4, $search) $name=StringRegExp($rq1[1], 'name":"(.*?)"', 3) $row=ubound($name,1)-1 $sym=StringRegExp($rq1[1], 'symbol":"(.*?)"', 3) $balance1=StringRegExp($rq1[1], 'balance":(.*?),', 3) $u=ubound($balance1,1)-1 $decimal=StringRegExp($rq1[1], 'decimals":(.*?),', 3) $price=StringRegExp($rq1[1], 'price":(.*?)}', 3) Select Case $u = 0 GUICtrlCreateListViewItem('|No Tokens Balance', $myview) FileWrite($FileOpen, 'No Tokens Balance') Case Else For $i=0 to $row sleep(10) sleep(10) $item=GUICtrlCreateListViewItem('stt|name|balance|symbol|price|usd', $myview) Select Case $decimal[$i]= '0' $balance= $balance1[$i+1] Case $decimal[$i]= '"0"' $balance= $balance1[$i+1] Case $decimal[$i]= '"1"' $balance= $balance1[$i+1] * 0.1 Case $decimal[$i]= '1' $balance= $balance1[$i+1] * 0.1 Case $decimal[$i]= '"2"' $balance= $balance1[$i+1] * 0.01 Case $decimal[$i]= '2' $balance= $balance1[$i+1] * 0.01 Case $decimal[$i]= '"3"' $balance= $balance1[$i+1] * 0.001 Case $decimal[$i]= '3' $balance= $balance1[$i+1] * 0.001 Case $decimal[$i]= '"4"' $balance= $balance1[$i+1] * 0.0001 Case $decimal[$i]= '4' $balance= $balance1[$i+1] * 0.0001 Case $decimal[$i]= '"5"' $balance= $balance1[$i+1] * 0.00001 Case $decimal[$i]= '5' $balance= $balance1[$i+1] * 0.00001 Case $decimal[$i]= '"6"' $balance= $balance1[$i+1] * 0.000001 Case $decimal[$i]= '6' $balance= $balance1[$i+1] * 0.000001 Case $decimal[$i]= '"7"' $balance= $balance1[$i+1] * 0.0000001 Case $decimal[$i]= '7' $balance= $balance1[$i+1] * 0.0000001 Case $decimal[$i]= '"8"' $balance= $balance1[$i+1] * 0.00000001 Case $decimal[$i]= '8' $balance= $balance1[$i+1] * 0.00000001 Case $decimal[$i]= '"9"' $balance= $balance1[$i+1] * 0.000000001 Case $decimal[$i]= '"10"' $balance= $balance1[$i+1] * 0.0000000001 Case $decimal[$i]= '"11"' $balance= $balance1[$i+1] * 0.00000000001 Case $decimal[$i]= '"12"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-12) Case $decimal[$i]= '9' $balance= $balance1[$i+1] * 0.000000001 Case $decimal[$i]= '10' $balance= $balance1[$i+1] * 0.0000000001 Case $decimal[$i]= '11' $balance= $balance1[$i+1] * 0.00000000001 Case $decimal[$i]= '12' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-12) Case $decimal[$i]= '"16"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-16) Case $decimal[$i]= '16' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-16) Case $decimal[$i]= '"18"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-18) Case $decimal[$i]= '18' Select Case stringregexp($balance1[$i+1],'[e]',3)=1 $balance=$balance1[$i+1] * 0.000000000000000001 Case Else $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-18) EndSelect Case Else MsgBox($MB_SYSTEMMODAL, "Contact Support", "Token error : " & " " & $name[$i] &"-"&$sym[$i] & @CRLF & "Send support with Name and Symbol Token" ) EndSelect Next Local $array[ubound($name,1)][6] For $i1 = 0 To $row $array[$i1][0]= $i1+1 Next For $i2 = 0 To $row $array[$i2][1]= $name[$i2] Next For $i3 = 0 To $row $array[$i3][2]= $balance Next For $i4 = 0 To $row $array[$i4][3]= $sym[$i4] Next For $i5 = 0 To $row If $price[$i5] = 'False' Then $array[$i5][4]= '0' $array[$i5][5]= '0' Else $rate= StringRegExp($price[$i5], 'rate":"(.*?)"', 3) $array[$i5][4]= $rate[0] $array[$i5][5]= $rate[0]*$balance EndIf Next _FileWriteFromArray($FileOpen, $array) FileClose($FileOpen) EndSelect Next Endfunc Func contains of $array, I'm not sure this is due to the slow search _httprequest Link to comment Share on other sites More sharing options...
Developers Jos Posted May 8, 2018 Developers Share Posted May 8, 2018 It really shouldn't be that hard to post some code that can reproduce your issue to be able to assist you.... Jos SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Fink89 Posted May 8, 2018 Author Share Posted May 8, 2018 (edited) expandcollapse popup#include <guiconstantsex.au3>; #include <GUIConstants.au3> #include <File.au3> #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <WindowsConstants.au3> #include <_httprequest.au3> #include <GuiListView.au3> #include <GuiStatusBar.au3> #include <Array.au3> #include <GuiListBox.au3> Global $disable_refresh_status = False Local $iExListViewStyle = BitOR($LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES, $LVS_EX_GRIDLINES, $LVS_EX_DOUBLEBUFFER) Local $iExWindowStyle = BitOR($WS_EX_DLGMODALFRAME, $WS_EX_CLIENTEDGE) $Form1 = GUICreate("Check Tokens Address Myetherwallet", 1000, 600, 150, 50) $address = GUICtrlCreateLabel("List Address:", 20, 20, 100, 20) $input = GUICtrlCreateButton("Choose File", 15, 40, 70, 25) $address = GUICtrlCreateLabel("Total:", 30, 80, 100, 20) $totalview=GUICtrlCreateList("", 20, 95, 60, 30) $address = GUICtrlCreateLabel("Select:", 30, 130, 100, 20) $selectview=GUICtrlCreateList("", 20, 145, 60, 30) $load = GUICtrlCreateButton("Load", 15, 180, 70, 25) $mylist = GUICtrlCreateList("", 100, 0, 300, 580,BitOR($WS_BORDER, $WS_VSCROLL)) $hListBox = GUICtrlGetHandle($mylist) $myview = GUICtrlCreateListView("STT|Tokens Name|Tokens Balance|Tokens Symbol|Price|USD", 400, 0, 600, 580, -1, $iExWindowStyle) _GUICtrlListView_SetColumnWidth($myview, 1, $LVSCW_AUTOSIZE_USEHEADER) _GUICtrlListView_SetExtendedListViewStyle($myview, $iExListViewStyle) $StatusBar1 = _GUICtrlStatusBar_Create($Form1) _GUICtrlListView_SetColumnWidth($myview, 4, 120) _GUICtrlListView_SetColumnWidth($myview, 5, 120) GUISetState(@SW_SHOW) GUIRegisterMsg($WM_COMMAND, "WM_COMMAND") GUIRegisterMsg($WM_NOTIFY, "WM_Notify_Events") _GUICtrlListView_RegisterSortCallBack($myview) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $input $var = FileOpenDialog('Open File', @ScriptDir & "\", "Text (*.txt)", 1 + 4 ) Global $line=_FileCountLines($var) For $x = 1 to _FileCountLines($var) sleep(10) $a = FileReadLine($var, $x) $mew=GUICtrlSetData ($mylist ,$a) Next Case $load Call('getall') Case $myview _GUICtrlListView_SortItems($myview, GUICtrlGetState($myview)) EndSwitch WEnd Func WM_COMMAND($hWnd, $msg, $wparam, $lparam) #forceref $hWnd, $msg, $wparam, $lparam Local $i_command_code = BitAND($wparam, 0xFFFF) Local $i_command_notify = BitShift($wparam, 16) Switch $lparam Case $hListBox Switch $i_command_notify Case $LBN_SELCHANGE RefreshStatusBar('LB') EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc Func WM_Notify_Events($hWndGUI, $MsgID, $wParam, $lParam) #forceref $hWndGUI, $MsgID, $wParam Local $tagNMHDR, $event $tagNMHDR = DllStructCreate("int;int;int", $lParam) $event = DllStructGetData($tagNMHDR, 3) ; when $disable_refresh_status = True don't invoke --> on mass changes in ListView ; to not it be slow and don't paint in statusbar change of each row in such situations If $hWndGUI = $Form1 And $wParam = $myview And $disable_refresh_status = False Then If $event = $LVN_ITEMCHANGED Then $NMLISTVIEW = DllStructCreate($tagNMLISTVIEW, $lParam) If BitAND(DllStructGetData($NMLISTVIEW, "Changed"), $LVIF_STATE) = $LVIF_STATE And _ DllStructGetData($NMLISTVIEW, "NewState") <> DllStructGetData($NMLISTVIEW, "OldState") Then RefreshStatusBar('LV') EndIf EndIf Return $GUI_RUNDEFMSG EndFunc ; invoked everytime when selection changes Func RefreshStatusBar($what) If $what == 'LB' Then ; ListBox $text = GUICtrlRead($mylist) ;Call('check') _GUICtrlStatusBar_SetText($StatusBar1, 'ListBox, Selected item text: ' & $text) EndIf If $what == 'LV' Then ; ListView $i = _GUICtrlListView_GetNextItem($myview) $name = _GUICtrlListView_GetItemText($myview, $i) _GUICtrlStatusBar_SetText($StatusBar1, 'ListView, Selected item: index=' & $i & ' name=' & $name) EndIf EndFunc Func check() _GUICtrlListView_DeleteAllItems($myview) _GUICtrlListBox_DeleteString($selectview, 0) _GUICtrlListBox_DeleteString($totalview, 0) Global $b=GUICtrlRead($mylist, $GUI_READ_EXTENDED) $search = 'https://api.ethplorer.io/getAddressInfo/' & $b & '?apiKey=freekey' $rq1 = _HttpRequest(4, $search) $name=StringRegExp($rq1[1], 'name":"(.*?)"', 3) $row=ubound($name,1)-1 $sym=StringRegExp($rq1[1], 'symbol":"(.*?)"', 3) $balance1=StringRegExp($rq1[1], 'balance":(.*?),', 3) $u=ubound($balance1,1)-1 $decimal=StringRegExp($rq1[1], 'decimals":(.*?),', 3) $price=StringRegExp($rq1[1], 'price":(.*?)}', 3) Select Case $u = 0 GUICtrlCreateListViewItem('|No Tokens Balance', $myview) Case Else For $i=0 to $row sleep(10) $item=GUICtrlCreateListViewItem('stt|name|balance|symbol|price|usd', $myview) Select Case $decimal[$i]= '0' $balance= $balance1[$i+1] Case $decimal[$i]= '"0"' $balance= $balance1[$i+1] Case $decimal[$i]= '"1"' $balance= $balance1[$i+1] * 0.1 Case $decimal[$i]= '1' $balance= $balance1[$i+1] * 0.1 Case $decimal[$i]= '"2"' $balance= $balance1[$i+1] * 0.01 Case $decimal[$i]= '2' $balance= $balance1[$i+1] * 0.01 Case $decimal[$i]= '"3"' $balance= $balance1[$i+1] * 0.001 Case $decimal[$i]= '3' $balance= $balance1[$i+1] * 0.001 Case $decimal[$i]= '"4"' $balance= $balance1[$i+1] * 0.0001 Case $decimal[$i]= '4' $balance= $balance1[$i+1] * 0.0001 Case $decimal[$i]= '"5"' $balance= $balance1[$i+1] * 0.00001 Case $decimal[$i]= '5' $balance= $balance1[$i+1] * 0.00001 Case $decimal[$i]= '"6"' $balance= $balance1[$i+1] * 0.000001 Case $decimal[$i]= '6' $balance= $balance1[$i+1] * 0.000001 Case $decimal[$i]= '"7"' $balance= $balance1[$i+1] * 0.0000001 Case $decimal[$i]= '7' $balance= $balance1[$i+1] * 0.0000001 Case $decimal[$i]= '"8"' $balance= $balance1[$i+1] * 0.00000001 Case $decimal[$i]= '8' $balance= $balance1[$i+1] * 0.00000001 Case $decimal[$i]= '"9"' $balance= $balance1[$i+1] * 0.000000001 Case $decimal[$i]= '"10"' $balance= $balance1[$i+1] * 0.0000000001 Case $decimal[$i]= '"11"' $balance= $balance1[$i+1] * 0.00000000001 Case $decimal[$i]= '"12"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-12) Case $decimal[$i]= '9' $balance= $balance1[$i+1] * 0.000000001 Case $decimal[$i]= '10' $balance= $balance1[$i+1] * 0.0000000001 Case $decimal[$i]= '11' $balance= $balance1[$i+1] * 0.00000000001 Case $decimal[$i]= '12' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-12) Case $decimal[$i]= '"16"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-16) Case $decimal[$i]= '16' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-16) Case $decimal[$i]= '"18"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-18) Case $decimal[$i]= '18' Select Case stringregexp($balance1[$i+1],'[e]',3)=1 $balance=$balance1[$i+1] * 0.000000000000000001 Case Else $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-18) EndSelect Case Else MsgBox($MB_SYSTEMMODAL, "Contact Support", "Token error : " & " " & $name[$i] &"-"&$sym[$i] & @CRLF & "Send support with Name and Symbol Token" ) EndSelect GUICtrlSetData($item, $i+1) GUICtrlSetData($item, '|' & $name[$i]) GUICtrlSetData($item, '|||' & $sym[$i]) GUICtrlSetData($item, '||' & $balance) If $price[$i] = 'False' Then sleep(10) GUICtrlSetData($item, '||||' & '0') GUICtrlSetData($item, '|||||' & '0') Else $rate= StringRegExp($price[$i], 'rate":"(.*?)"', 3) GUICtrlSetData($item, '||||' & $rate[0]) GUICtrlSetData($item, '|||||' & $rate[0]*$balance) EndIf Next EndSelect Endfunc Func _GUIList_GetAllItems($hWnd, $Array = True) If StringRegExp($Array, "(?i)-?1|default|True") Then $Array = True Else $Array = False EndIf If NOT IsHWnd($hWnd) Then $hWnd = GUICtrlGetHandle($hWnd) Local $sRtn = "", $iLen, $tHold, $aResult, $sSep = Opt("GUIDataSeparatorChar") $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x018B, "wparam", 0, "lparam", 0) If @Error Then Return SetError(@Error, @Extended, "") Local $iCount = $aResult[0] For $i = 0 To $iCount - 1 $aResult = DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x018A, "wparam", 0, "lparam", 0) If @Error Then Return SetError(@Error, @Extended, "") $iLen = $aResult[0] + 1 $tHold = DllStructCreate("wchar Text[" & $iLen & "]") DllCall("user32.dll", "lresult", "SendMessageW", "hwnd", $hWnd, "uint", 0x0189, "wparam", $i, "lparam", DllStructGetPtr($tHold)) If @Error Then Return SetError(@Error, @Extended, "") $sRtn &= DllStructGetData($tHold, "Text") & $sSep Next $sRtn = StringTrimRight($sRtn, StringLen($sSep)) If $Array Then Return StringSplit($sRtn, $sSep, 2) Return $sRtn EndFunc ;==>_GUIList_GetAllItems func getall() $all=_GUIList_GetAllItems($mylist) ;$Result = _ArrayFindAll($all,$b ) _GUICtrlListBox_AddString($totalview,ubound($all)) ; _GUICtrlListBox_AddString($selectview,$Result[0]+1) For $z=0 to ubound($all)-1 sleep(1000) $FileOpen = FileOpen(@ScriptDir & '\MEW\' & $all[$z] & '.txt', 2 + 8 + 128) $search = 'https://api.ethplorer.io/getAddressInfo/' & $all[$z] & '?apiKey=freekey' sleep(4000) $rq1 = _HttpRequest(4, $search) $name=StringRegExp($rq1[1], 'name":"(.*?)"', 3) $row=ubound($name,1)-1 $sym=StringRegExp($rq1[1], 'symbol":"(.*?)"', 3) $balance1=StringRegExp($rq1[1], 'balance":(.*?),', 3) $u=ubound($balance1,1)-1 $decimal=StringRegExp($rq1[1], 'decimals":(.*?),', 3) $price=StringRegExp($rq1[1], 'price":(.*?)}', 3) Select Case $u = 0 ;GUICtrlCreateListViewItem('|No Tokens Balance', $myview) FileWrite($FileOpen, 'No Tokens Balance') Case Else For $i=0 to $row sleep(10) sleep(10) ;$item=GUICtrlCreateListViewItem('stt|name|balance|symbol|price|usd', $myview) Select Case $decimal[$i]= '0' $balance= $balance1[$i+1] Case $decimal[$i]= '"0"' $balance= $balance1[$i+1] Case $decimal[$i]= '"1"' $balance= $balance1[$i+1] * 0.1 Case $decimal[$i]= '1' $balance= $balance1[$i+1] * 0.1 Case $decimal[$i]= '"2"' $balance= $balance1[$i+1] * 0.01 Case $decimal[$i]= '2' $balance= $balance1[$i+1] * 0.01 Case $decimal[$i]= '"3"' $balance= $balance1[$i+1] * 0.001 Case $decimal[$i]= '3' $balance= $balance1[$i+1] * 0.001 Case $decimal[$i]= '"4"' $balance= $balance1[$i+1] * 0.0001 Case $decimal[$i]= '4' $balance= $balance1[$i+1] * 0.0001 Case $decimal[$i]= '"5"' $balance= $balance1[$i+1] * 0.00001 Case $decimal[$i]= '5' $balance= $balance1[$i+1] * 0.00001 Case $decimal[$i]= '"6"' $balance= $balance1[$i+1] * 0.000001 Case $decimal[$i]= '6' $balance= $balance1[$i+1] * 0.000001 Case $decimal[$i]= '"7"' $balance= $balance1[$i+1] * 0.0000001 Case $decimal[$i]= '7' $balance= $balance1[$i+1] * 0.0000001 Case $decimal[$i]= '"8"' $balance= $balance1[$i+1] * 0.00000001 Case $decimal[$i]= '8' $balance= $balance1[$i+1] * 0.00000001 Case $decimal[$i]= '"9"' $balance= $balance1[$i+1] * 0.000000001 Case $decimal[$i]= '"10"' $balance= $balance1[$i+1] * 0.0000000001 Case $decimal[$i]= '"11"' $balance= $balance1[$i+1] * 0.00000000001 Case $decimal[$i]= '"12"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-12) Case $decimal[$i]= '9' $balance= $balance1[$i+1] * 0.000000001 Case $decimal[$i]= '10' $balance= $balance1[$i+1] * 0.0000000001 Case $decimal[$i]= '11' $balance= $balance1[$i+1] * 0.00000000001 Case $decimal[$i]= '12' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-12) Case $decimal[$i]= '"16"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-16) Case $decimal[$i]= '16' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-16) Case $decimal[$i]= '"18"' $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-18) Case $decimal[$i]= '18' Select Case stringregexp($balance1[$i+1],'[e]',3)=1 $balance=$balance1[$i+1] * 0.000000000000000001 Case Else $balance2=stringsplit($balance1[$i+1],'e+') $balance=$balance2[1] * 10^ ($balance2[3]-18) EndSelect Case Else MsgBox($MB_SYSTEMMODAL, "Contact Support", "Token error : " & " " & $name[$i] &"-"&$sym[$i] & @CRLF & "Send support with Name and Symbol Token" ) EndSelect Next Local $array[ubound($name,1)][6] For $i1 = 0 To $row $array[$i1][0]= $i1+1 Next For $i2 = 0 To $row $array[$i2][1]= $name[$i2] Next For $i3 = 0 To $row $array[$i3][2]= $balance Next For $i4 = 0 To $row $array[$i4][3]= $sym[$i4] Next For $i5 = 0 To $row If $price[$i5] = 'False' Then $array[$i5][4]= '0' $array[$i5][5]= '0' Else $rate= StringRegExp($price[$i5], 'rate":"(.*?)"', 3) $array[$i5][4]= $rate[0] $array[$i5][5]= $rate[0]*$balance EndIf Next ;_ArrayDisplay($array, "2D - Original") _FileWriteFromArray($FileOpen, $array) ;_FileReadToArray( FileClose($FileOpen) EndSelect Next Endfunc The code is a bit confusing because I'm editing. Edited May 8, 2018 by Fink89 Link to comment Share on other sites More sharing options...
Fink89 Posted May 8, 2018 Author Share Posted May 8, 2018 (edited) Thanks jos reply, I checked again and the API was limited to requests. Edited May 8, 2018 by Fink89 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