Jump to content

[HELP]Script Function Error


Recommended Posts

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!

Link to comment
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

Link to comment
Share on other sites

  • Developers

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

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

Link to comment
Share on other sites

  • Moderators

Jos,

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

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see 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

 

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