Sign in to follow this  
Followers 0
GianAutoitprogrammer

[HELP]Script Function Error

8 posts in this topic

Hellow, Why my script cant write the file...

Here is the code:

;GUI
;1button = $save
;1edit = $editbox2

global $save1, $fileopened2 = 0, $Fileopen2

Case $SAVE1 And $FILEOPENED2 = 1
        Filesetattrib(@Homedrive & "\config.sys", "-RASHOT")
        Filesetattrib(@Homedrive & "\config.sys", "+N")
            $FILEOPEN2 = @Homedrive & "\config.sys"
            FileDelete($FILEOPEN2)
            FileWrite($FILEOPEN2, GUICtrlRead($EDITBOX2))
            _GUICtrlEdit_EmptyUndoBuffer($EDITBOX2)
;It cant write the modified file config.sys!

I need help!

Share this post


Link to post
Share on other sites



Hellow, Why my script cant write the file...

global $save1, $fileopened2 = 0, $Fileopen2

Case $SAVE1 And $FILEOPENED2 = 1

In your example you have set $fileopened2 = 0 and your Case is expecting 1

REB


MEASURE TWICE - CUT ONCE

Share this post


Link to post
Share on other sites

@reb No it will turn into 1 because I will click the Save Button in the GUI

The editbox2 = will open the file C:\config.sys and you will edit the config.sys, If you edit it you must click the save button and then the C:\config.sys will be modified...

Share this post


Link to post
Share on other sites

Try posting script that can be ran in stead of a portion that cannot function on it own.

First of all I would start with error checking for each of the functions you do as currently you have no idea which function is successful and which fails.

Jos


Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

GianAutoitprogrammer,

Add some debug code to your script like this so you can see what is going on: :>

Case $SAVE1 And $FILEOPENED2 = 1

    ; Check we get into the loop
    ConsoleWrite("We are in the loop" & @CRLF)

    $FILEOPEN2 = @Homedrive & "\config.sys"

    ; Check we set the attribs as we wish
    ConsoleWrite("Initial = " & FileGetAttrib($FILEOPEN2) & @CRLF) 
    Filesetattrib($FILEOPEN2, "-RASHOT")
    ConsoleWrite("Next = " & FileGetAttrib($FILEOPEN2) & @CRLF) 
    Filesetattrib($FILEOPEN2, "+N")
    ConsoleWrite("Final = " & FileGetAttrib($FILEOPEN2) & @CRLF) 

    ; Now see if we delete the original
    Local $iRet = FileDelete($FILEOPEN2)
    ConsoleWrite("Deletion = " & $iRet & @CRLF)

    ; And finally see if we write to the new file
    $iRet = FileWrite($FILEOPEN2, GUICtrlRead($EDITBOX2))
    ConsoleWrite("Writing = " & $iRet & @CRLF)

    _GUICtrlEdit_EmptyUndoBuffer($EDITBOX2)

Now you can see if your commands are being successfully executed. :unsure:

What OS are you running? If it is Vista or Win7 I would hazard a guess that you are not amending the config.sys file at all. If that is the case, then try adding #RequireAdmin at the top of your script. ;)

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

Jos,

And a good morning to you as well! :unsure:

M23


Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind._______My UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Share this post


Link to post
Share on other sites

The variables $fileopened2, $Fileopen2, $FILEOPENED2 and $FILEOPEN2 will probably conflict with each other.


- Bruce /*somdcomputerguy */  If you change the way you look at things, the things you look at change.

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