Jump to content
Sign in to follow this  
Nezoic

Quick Question

Recommended Posts

Nezoic

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)

Share this post


Link to post
Share on other sites
Stumpii

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.

Share this post


Link to post
Share on other sites
Nezoic

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:

Share this post


Link to post
Share on other sites
JSThePatriot

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)

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  

×