Jump to content
ruxer100

FileWrite Error

Recommended Posts

ruxer100

Fixed. 

topic close
Edited by ruxer100

Share this post


Link to post
Share on other sites
JLogan3o13

Do an _ArrayDisplay on $aArray. Does $aArray[0] hold the information you expect it to


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
ruxer100

Do an _ArrayDisplay on $aArray. Does $aArray[0] hold the information you expect it to

​still the same error, sometimes i have this error ,sometimes script work well

Edited by ruxer100

Share this post


Link to post
Share on other sites
water

This error tells you that _StringBetween was not successful and didn't create an array.
Check the return value of _StringBeetween and see if there happened an error.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2018-06-01 - Version 1.4.9.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-01-27 - Version 1.3.3.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
ruxer100

This error tells you that _StringBetween was not successful and didn't create an array.
Check the return value of _StringBeetween and see if there happened an error.

​_StringBetween return 0 and filewrite error.  when i use this function first time error not shown but use this function second time error shown

Edited by ruxer100

Share this post


Link to post
Share on other sites
hydranix

Add error checking to your script, if _StringBetween() returns an error, try repeating the _IEBodyReadHTML() part of the script a couple tomes until _StringBetween() either works or until it has failed a few times and exit the script with your own error stating this.

  • Like 1

Share this post


Link to post
Share on other sites
iamtheky

Yup, I would check the array and contents prior to the file ops

If IsArray($aArray) Then
    If stringlen($aArray[0]) = 0 Then $aArray[0] = "No Data"
    ; FileOpen
    ; FileWrite
    ; FileClose
EndIf

 

 

 

 


,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
ruxer100

I have that 

Do
       Local $sHTML = _IEBodyReadHTML($oIE)
      $serwer = GUICtrlRead($serwer)
      $start = "<h2>Świat " & $serwer & " </h2>"
      $end = "</p>"
     Local $aArray = _StringBetween($sHTML, $start, $end)
     Until $aArray = 0
 If $aArray = 0 then
     MsgBox(0, "", "work")
     $handle=FileOpen("odbiorcy.txt",2)
      FileWrite($handle,$aArray[0])
      FileClose($handle)
     EndIf

and when $aArray = 0 shows this same error, MsgBox shows after close him shows error

Edited by ruxer100

Share this post


Link to post
Share on other sites
SadBunny

That loop exits as soon as _StringBetween fails. Didn't you mean to have the loop exit as soon as it succeeds instead? Something like...

$attemptCount = 0

Do
    $attemptCount += 1
    If $attemptCount > 1 Then Sleep(1000)
    Local $sHTML = _IEBodyReadHTML($oIE)
    $serwer = GUICtrlRead($serwer)
    $start = "<h2>Swiat " & $serwer & " </h2>"
    $end = "</p>"
    Local $aArray = _StringBetween($sHTML, $start, $end)
Until IsArray($aArray) ; or: Until @error = 0, or: Until $aArray <> 0

;If $aArray = 0 Then  ; <-- this check isn't necessary any more if you make sure you only reach this point if and when the _StringBetween returned an array
MsgBox(0, "", "work")
$handle = FileOpen("odbiorcy.txt", 2)
FileWrite($handle, $aArray[0])
FileClose($handle)
;EndIf

/edit: you may also want to throw a Sleep(1000) in that loop to wait a second between each check.

/edit 2: indentation in codebox above is broken for some reason.

Edited by SadBunny
  • Like 1

Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
ruxer100

That loop exits as soon as _StringBetween fails. Didn't you mean to have the loop exit as soon as it succeeds instead? Something like...

$attemptCount = 0

Do
    $attemptCount += 1
    If $attemptCount > 1 Then Sleep(1000)
    Local $sHTML = _IEBodyReadHTML($oIE)
    $serwer = GUICtrlRead($serwer)
    $start = "<h2>Swiat " & $serwer & " </h2>"
    $end = "</p>"
    Local $aArray = _StringBetween($sHTML, $start, $end)
Until IsArray($aArray) ; or: Until @error = 0, or: Until $aArray <> 0

;If $aArray = 0 Then  ; <-- this check isn't necessary any more if you make sure you only reach this point if and when the _StringBetween returned an array
MsgBox(0, "", "work")
$handle = FileOpen("odbiorcy.txt", 2)
FileWrite($handle, $aArray[0])
FileClose($handle)
;EndIf

/edit: you may also want to throw a Sleep(1000) in that loop to wait a second between each check.

/edit 2: indentation in codebox above is broken for some reason.

​This works but when i click button second time nothing do.

Share this post


Link to post
Share on other sites
ruxer100

​Maybe show your script so we can see?

Jos

#include <string.au3>
#include <Array.au3>
#include <File.au3>
#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=c:\users\szymon\desktop\margospam.kxf
$MargoSpam = GUICreate("MargoSpam", 438, 292, 284, 204)
$Trescwiadomosci = GUICtrlCreateInput("Treść wiadomości", 112, 168, 257, 21)
$serwer = GUICtrlCreateInput("serwer", 288, 72, 121, 21)
$normal = GUICtrlCreateButton("normal", 56, 72, 75, 25)
$priv = GUICtrlCreateButton("priv", 160, 72, 75, 25)
$START = GUICtrlCreateButton("START", 160, 224, 155, 41)
$czas = GUICtrlCreateInput("", 288, 136, 41, 21)
$labeltaki = GUICtrlCreateLabel("Odstępy między wiadomościami", 24, 136, 207, 17)
$Label1 = GUICtrlCreateLabel("w sekundach", 180, 136, 108, 17)
Global $oIE =  _IECreate("http://www.margonem.pl/?task=stats")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg

    Case $GUI_EVENT_CLOSE
            Exit
case $normal
       normalny()
    EndSwitch
 WEnd


func normalny()
$attemptCount = 0

Do
    $attemptCount += 1
    If $attemptCount > 1 Then Sleep(1000)
    Local $sHTML = _IEBodyReadHTML($oIE)
    $serwer = GUICtrlRead($serwer)
    $start = "<h2>Świat " & $serwer & " </h2>"
    $end = "</p>"
    Local $aArray = _StringBetween($sHTML, $start, $end)
Until IsArray($aArray)

MsgBox(0, "", "work")
$handle = FileOpen("odbiorcy.txt", 2)
FileWrite($handle, $aArray[0])
FileClose($handle)

EndFunc

 

Share this post


Link to post
Share on other sites
Jos

Somehow I get the feeling this is for an online game ....right?
Did you actually read our forum rules you were pointed to on Monday in this post?

Jos

 


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
SadBunny

You are making a spam bot?! Yuck, that's just purely for clickbaiting and/or trolling and it makes you look like a total asshole in any game. And you break two forum rules (game / removing first post)? And you are ungrateful. Come on man... Don't be that guy.


Roses are FF0000, violets are 0000FF... All my base are belong to you.

Share this post


Link to post
Share on other sites
JLogan3o13

SadBunny, as you are quoting the rules, I would have you look at item 4 regarding flaming users, as well as the section regarding reporting. You've been around long enough to know that you should let it lie and allow the Mods to handle an issue once they've intervened.

 


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites
Jos

Guess what .. it is already handled and the OP has gotten a couple of days vacation to read them properly.

*click*

Jos

@Melbe23: Great minds ........ etc

Edited by Jos

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×