Sign in to follow this  
Followers 0
Appie78

FileWrite not working

8 posts in this topic

Hi Guys,

I've got a little problem with the Filewrite().

Below code isn't working, it does create the file and the Filewrite return a "Succes" in the Msgbox.

Func Begin()

$FileLog = FileOpen("C:\Images\" & $Begin & "\" & $Begin & "(" & @MDAY & "-" & @MON & "-" & @YEAR & ")" & ".log", 9)

If $FileLog = -1 Then

MsgBox(0, "Error", "Unable to open logfile.")

Return

EndIf

If Not $Stub = 1 Then

FileWrite($FileLog, @CRLF)

EndIf

$line = FileWrite($FileLog, "Started: " & @MDAY & "-" & @MON & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)

MsgBox(0, "", $line)

EndFunc ;==>Begin

Func Eind()

FileWrite($FileLog, "Reference number:Stub" & @CRLF)

FileWrite($FileLog, "Ammount of fields observed: " & $StepCount & @CRLF)

FileWrite($FileLog, "Ammount of fibres counted: " & $Vezel & @CRLF)

FileWrite($FileLog, "Ammount of pictures taken: " & $Number - 1 & @CRLF)

FileWrite($FileLog, "Finished: " & @MDAY & "-" & @MON & "-" & @YEAR & " " & @HOUR & ":" & @MIN & ":" & @SEC & @CRLF)

FileClose($FileLog)

EndFunc ;==>Eind

Anyone who can help me out?

Thanks


Electron microscopes rule!!!

Share this post


Link to post
Share on other sites



Works good for me, the file is created. The only problem might be with $Begin. What is it?

Hi Yashied,

$Begin = $Array[$i][$i]

Also tested this with a Msgbox which returns me the correct data.

The file is created when I run the script, but all the lines from the two functions don't get written into the file.

Thanks,

Appie


Electron microscopes rule!!!

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

hmmm...

Begin() doesn't call Eind().

how about this:

If Not $Stub = 1 Then
  FileWrite($FileLog, @CRLF)  ;<<--- should be changed to Eind()
EndIf
Edited by DYONISII

http://dev.dyonisii.com/

Share this post


Link to post
Share on other sites

hmmm...

Begin() doesn't call Eind().

how about this:

If Not $Stub = 1 Then
    FileWrite($FileLog, @CRLF)  ;<<--- should be changed to Eind()
  EndIf

Hi DYONISII,

Both functions are called from another function, so both get called but not after eachother.

Thanks for the reply

@Yashied,

I'll try and sort some things out tonight.

Thanks,

Appie


Electron microscopes rule!!!

Share this post


Link to post
Share on other sites

Hi all,

It's like a miracle happened, it's working now!!!!

The only thing that worries me is that I didn't change anything in my code.

The only thing is that I put my laptop to hibernate twice!

Well anyway thanks for the help.

Appie


Electron microscopes rule!!!

Share this post


Link to post
Share on other sites

perhaps you started talking to your computer. LOL!

a long time ago when i used to teach, a student was in a situation like yours. he asked me what was the error of his program because he was receiving an error message. i looked at it and didn't find anything wrong. then i ran it myself, and it did properly.

oh well, sometimes, you gotta be nicer to your puter. they behave better if you treat them as people too hehehe.


http://dev.dyonisii.com/

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  
Followers 0