Jump to content

Quick Question


 Share

Recommended Posts

Why doesn't this work

$file = FileOpen("vardata.au3", 2)
if $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

For $f = 1 to $tempData[0]
    FileWrite($file, $tempData[$f] & @CRLF)
next
FileClose($file)

But This does?

$file = FileOpen("test.au3", 2)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, $tempData[1] & @CRLF)
FileWrite($file, $tempData[2] & @CRLF)
FileWrite($file, $tempData[3] & @CRLF)

FileClose($file)
Link to comment
Share on other sites

Why doesn't this work

$file = FileOpen("vardata.au3", 2)
if $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

For $f = 1 to $tempData[0]
    FileWrite($file, $tempData[$f] & @CRLF)
next
FileClose($file)

But This does?

$file = FileOpen("test.au3", 2)
If $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

FileWrite($file, $tempData[1] & @CRLF)
FileWrite($file, $tempData[2] & @CRLF)
FileWrite($file, $tempData[3] & @CRLF)

FileClose($file)

<{POST_SNAPBACK}>

Think it should be this:

$file = FileOpen("vardata.au3", 2)
if $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

For $f = 1 to Ubound($tempData)
    FileWrite($file, $tempData[$f] & @CRLF)
next
FileClose($file)

Don't think '$tempData[0]' holds the size of the array. Use UBound instead.

“Give a man a script; you have helped him for today. Teach a man to script; and you will not have to hear him whine for help.”AutoIt4UE - Custom AutoIt toolbar and wordfile for UltraEdit/UEStudio users.AutoIt Graphical Debugger - A graphical debugger for AutoIt.SimMetrics COM Wrapper - Calculate string similarity.

Link to comment
Share on other sites

Think it should be this:

$file = FileOpen("vardata.au3", 2)
if $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf

For $f = 1 to Ubound($tempData)
    FileWrite($file, $tempData[$f] & @CRLF)
next
FileClose($file)

Don't think '$tempData[0]' holds the size of the array. Use UBound instead.

<{POST_SNAPBACK}>

Ahh, well you got me close enough =D correct syntax is

$file = FileOpen("vardata.au3", 2)
if $file = -1 Then
    MsgBox(0, "Error", "Unable to open file.")
    Exit
EndIf
For $f = 0 to UBound($tempData, 1) - 1
    FileWrite($file, $tempData[$f] & @CRLF)
next
FileClose($file)

Which works perfectly, thanks for your help :whistle:

Link to comment
Share on other sites

Quick suggestion... use FileWriteLine().

JS

AutoIt Links

File-String Hash Plugin Updated! 04-02-2008 Plugins have been discontinued. I just found out.

ComputerGetInfo UDF's Updated! 11-23-2006

External Links

Vortex Revolutions Engineer / Inventor (Web, Desktop, and Mobile Applications, Hardware Gizmos, Consulting, and more)

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...