Jump to content
Sign in to follow this  
IAMK

Misbehaving FileWrite

Recommended Posts

IAMK

Hello,

Can someone explain what I've done wrong?

The code is supposed to call a function which brings up a GUI with "Pass" and "Fail" buttons. $pass is True/False, using in the following code:

Func getStatus($pass)
   If($pass = "True") Then
      Return " passed "
   Else
      Return " failed "
   EndIf
EndFunc

I write a line to a .txt file, saying whether Step # passed or failed and how long it took. Then, if the button pressed was "Fail", an InputBox was created, which is the "Return" of SanityCheckGUI() which goes into $failLog. Refer to code below:

Local $failLog = SanityCheckGUI($pass, $stepMessage[$step]) ;Returns a message to log if the step failed.

   FileWrite($filename, _Now() & ": Step " & $step & getStatus($pass) & "and took " & (TimerDiff($timer) / 1000) & " seconds." & @CRLF)

   If($failLog <> "") Then
      FileWrite($file, _Now() & ": " & $failLog & @CRLF)
   EndIf

However... this is what I actually get when I press:

Pass: (This is correct)

14/11/2017 12:30:27 PM: Step 2 passed and took 1.48731919633846 seconds.

Fail: (How does "jfuer6", the thing I put into the InputBox, come before the long line and cut it in half?)

14/11/2017 12:29:54 PM: jfuer6
ailed and took 4.73581847206323 seconds.

Expected for Fail:

14/11/2017 12:29:54 PM: Step 2 failed and took 4.73581847206323 seconds.
14/11/2017 12:29:54 PM: jfuer6

Thank you in advance.

Edited by IAMK

Share this post


Link to post
Share on other sites
IAMK

I found the issue.

<$filename> should be <$file>

 

Question: Why does this mistake not get picked up by AutoIT / keep the text in the buffer?

Share this post


Link to post
Share on other sites
kylomas

IANK,

If $file is a handle and $filename is a fully qualified file name then both syntaxes are correct.

kylomas

Edited by kylomas

Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Similar Content

    • TheDcoder
      By TheDcoder
      Hello, I found that its quite challenging to do this:
      text.txt:
      Hello, I am a text file :). I love line No. 1 I want to change it like this:
      I am line No. 1 now :P Hello, I am a text file :). I love line No. 1 How can I do this in AutoIt without storing it?



      Thanks in advance!
      TD
×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.