Jump to content

new to autiit, need help with creating a file


zellis
 Share

Recommended Posts

as simple as i know this is im having problems with it. i just started using autoit a week ago and im having problems with creating a file. My goal is to creat a file, namt it "XXXXX.ini", write some values to it, save the file cand then close the file.. so another script can read it. i can not seem to find the function i need to do this. here is the script i have so far. please let me know where im going wrong. the block is not done by any means, im still trying to debug it.

" "

" "

$submitbutton = GuiCtrlCreateButton ("submit",50,130,70,20)

;init vars for ALT

$ALT_raido_value1 = 1

$ALT_raido_value2 = 3

;init vars in file delete

$tokenini = 1

" "

my GUI and some vars are up here ^

select

Case $msg = $submitbutton

if FileExists ("c:\ipu_final_config\token.ini") then

FileDelete ("c:\ipu_final_config\token.ini")

$tokenini = 0

;run ("notepad.exe")

$file = FileOpen("token.ini", 1)

; Check if file opened for writing OK

If $file = -1 Then

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

Exit

EndIf

FileWrite($file, "test line 1")

FileWrite($file, "Still Line1 test" & @CRLF)

FileWrite($file, " test Line2")

FileClose($file)

MsgBox(0, "siu altitude value1", "Radio " & $ALT_raido_value1 )

endif

;$path = "c:\ipu_final_config\token.ini"

;$var = FileSaveDialog( "saving token", $path, "All (*.*)", 8,"token.txt")

; option 3 = dialog remains until valid path/file selected

thankyou for your help.

shawn

Link to comment
Share on other sites

  • Developers

You didn't really explain what your problem is...

But look at your own code with proper indentation...

Select
    Case $msg = $submitbutton
        If FileExists("c:\ipu_final_config\token.ini") Then
            FileDelete("c:\ipu_final_config\token.ini")
            $tokenini = 0
        ;run ("notepad.exe")
            $file = FileOpen("token.ini", 1)
        ; Check if file opened for writing OK
            If $file = -1 Then
                MsgBox(0, "Error", "Unable to open file.")
                Exit
            EndIf
            
            FileWrite($file, "test line 1")
            FileWrite($file, "Still Line1 test" & @CRLF)
            FileWrite($file, " test Line2")
            FileClose($file)
            MsgBox(0, "siu altitude value1", "Radio " & $ALT_raido_value1)
        EndIf
    ;$path = "c:\ipu_final_config\token.ini"
    ;$var = FileSaveDialog( "saving token", $path, "All (*.*)", 8,"token.txt") 
    ; option 3 = dialog remains until valid path/file selected

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

I think he means AutoIt :geek:

i think so to... the "i" and "o" get mixed up at times :"> . thanks for the ini functions, i will try them, but what if i wanted to create a *.dat or *.txt file? i cannot seem to find a sutiable function to do this. if i open the help menu on the SCITE editor, it refers you to a function called "_fileCreate". but the editor/AUTOIT does not seem to support that function anymore :o . i will try to make the ini commands work. thanks.
Link to comment
Share on other sites

i think so to... the "i" and "o" get mixed up at times :"> . thanks for the ini functions, i will try them, but what if i wanted to create a *.dat or *.txt file? i cannot seem to find a sutiable function to do this. if i open the help menu on the SCITE editor, it refers you to a function called "_fileCreate". but the editor/AUTOIT does not seem to support that function anymore :o . i will try to make the ini commands work. thanks.

Nice! I thought there was some new feature out that I didn't know about...

[quote] Gilbertson's Law: Nothing is foolproof to a sufficiently talented fool.Sandro Alvares: Flaxcrack is please not noob! i can report you is stop stupid. The Post[/quote]I made this: FWD & MD5PWD()

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