Jump to content

help with write line


 Share

Recommended Posts

I am trying to figure out how to make the FileWriteLine write to the same line until I hit a button forcing it to go to the next line.  Any ideas?  Here is a rough gui with buttons to help understand what I am trying to do.  Thanks!

 

 
 
#include <GUIConstantsEx.au3>


Example()


Func Example()
    Local $Button_1, $Button_2, $msg
    GUICreate("My GUI Button") ; will create a dialog box that when displayed is centered


    Opt("GUICoordMode", 2)
    $Button_1 = GUICtrlCreateButton("log 1", 10, 30, 100)
    $Button_2 = GUICtrlCreateButton("log 2", 0, -1)
$Button_3 = GUICtrlCreateButton("newline 1", 0, -1)
$Button_4 = GUICtrlCreateButton("newline 2", 0, -1)


    GUISetState() ; will display an  dialog box with 2 button


    ; Run the GUI until the dialog is closed
    While 1
        $msg = GUIGetMsg()
        Select
            Case $msg = $GUI_EVENT_CLOSE
                ExitLoop
            Case $msg = $Button_1
                Local $file = FileOpen("button1.txt", 1)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
FileWriteLine($file, "1") ;;help write to same line here;;;;;;
FileClose($file)
            Case $msg = $Button_2
                Local $file = FileOpen("button2.txt", 1)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
FileWriteLine($file, "2") ;;help write to same line here;;;;;;
FileClose($file)
            Case $msg = $Button_3
                Local $file = FileOpen("button1.txt", 1)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
;;help create new line here;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
            Case $msg = $Button_4
                Local $file = FileOpen("button2.txt", 1)
If $file = -1 Then
MsgBox(0, "Error", "Unable to open file.")
Exit
EndIf
;;help create new line here;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
FileClose($file)
        EndSelect
    WEnd
EndFunc

 

Link to comment
Share on other sites

  • Developers

FileWriteLine implies you are writing a line/record each time. Use FileWrite() when you want to write information to a file without the CRLF.

Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

  • Developers

How about going to a new line after like 50 characters are on a line?  

Keep count on how many characters you have written and write the @CRLF when you hit 50 characters.

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

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...