vi6ora Posted August 16, 2009 Share Posted August 16, 2009 Hi. I am learning with a text editor i found here. I tryied to put something mine in it but i am getting annoying error. Here Is the code expandcollapse popup#include <GUIConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <Misc.au3> #include <String.au3> #include <ModernMenu.au3> Local $WIDTH, $HEIGHT, $WS_OVERLAPPEDWINDOW , $WS_VISIBLE , $WS_CLIPSIBLINGS, $WS_EX_ACCEPTFILES $OpenedFilePath = "no file" $OpenedFile = "no file" $TextEditor = GUICreate("Simple Text Editor", 800, 600, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $EditControl = GUICtrlCreateEdit("", 0, 0, 800, 600, -1, $WS_EX_ACCEPTFILES) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) $FileMenu = GUICtrlCreateMenu("&File") $nSideItem1 = _CreateSideMenu($FileMenu) _SetSideMenuText($nSideItem1, "UTE Menu") _SetSideMenuColor($nSideItem1, 0xAAFFAA) ; default color - white _SetSideMenuBkColor($nSideItem1, 0x921801) ; bottom start color - dark blue _SetSideMenuBkGradColor($nSideItem1, 0xFBCE92) ; top end color - light blue $NEW = _GUICtrlCreateODMenuItem("&Print" & @Tab & "Ctrl+S", $FileMenu, "shell32.dll", -55) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -55) _GUICtrlCreateODMenuItem("", $FileMenu) $OpenFile = _GUICtrlCreateODMenuItem("&Open..." & @Tab & "Ctrl+O", $FileMenu) _GUICtrlODMenuItemSetIcon(-1, "shell32.dll", -4) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -5) $SaveFile = _GUICtrlCreateODMenuItem("&Save" & @Tab & "Ctrl+S", $FileMenu, "shell32.dll", -7) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -79) _GUICtrlCreateODMenuItem("", $FileMenu) $PrintFile = _GUICtrlCreateODMenuItem("&Print" & @Tab & "Ctrl+S", $FileMenu, "shell32.dll", -17) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -164) _GUICtrlCreateODMenuItem("", $FileMenu) $ExitFile = _GUICtrlCreateODMenuItem("E&xit", $FileMenu, "shell32.dll", -28) _SetMenuBkColor(0xAAFFAA) _SetMenuIconBkColor(0x66BB66) _SetMenuSelectBkColor(0xBBCC88) _SetMenuSelectRectColor(0x222277) _SetMenuSelectTextColor(0x770000) _SetMenuTextColor(0x000000) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If $OpenedFilePath <> "no file" Then If GUICtrlRead($EditControl) <> FileRead($OpenedFile) Then $SaveChangesBox = MsgBox(3, "Save File?", "Would you like to save the changes you made?") If $SaveChangesBox = 6 Then FileDelete($OpenedFilePath) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, GUICtrlRead($EditControl)) Exit ElseIf $SaveChangesBox = 7 Then Exit EndIf Else Exit EndIf Else Exit EndIf Case $PrintFile $PrintFileFunction = _FilePrint($OpenedFilePath) If $PrintFileFunction Then MsgBox(0, "Print", "The file was printed.") Else MsgBox(0, "Print Error", "The file was not printed.") EndIf Case $OpenFile $OpenFileDialog = FileOpenDialog("Load Text File", "", "Text Files (*.txt)") If FileExists($OpenFileDialog) Then $OpenedFilePath = $OpenFileDialog $PreviousFileRead = FileRead($OpenedFilePath) FileDelete($OpenedFilePath) GUICtrlSetData($EditControl, $PreviousFileRead) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, $PreviousFileRead) EndIf Case $ExitFile Terminate() Case $SaveFile If $OpenedFilePath = "no file" Then $NewDialog = FileSaveDialog("New File", "", "Text Files (*.txt)") If $NewDialog <> "" Then $OpenedFilePath = $NewDialog & ".txt" $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, GUICtrlRead($EditControl)) EndIf Else FileDelete($OpenedFilePath) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFilePath, GUICtrlRead($EditControl)) EndIf Case $MSG = $NEW If GUICtrlRead($EditControl) <> "" Then $SaveChangesBox = MsgBox(3, "Save?", "Would you like to save?") If $SaveChangesBox = 6 Then SaveFile() EndIf If $SaveChangesBox = 7 Then FileDelete($OpenFile) FileWrite($OpenFile, GUICtrlRead($EditControl)) EndIf If $SaveChangesBox = 7 Then GUICtrlSetData($EditControl, "") Wend EndSwitch Func Terminate() Exit EndFunc Func SaveFile() If $OpenedFilePath = "no file" Then $NewDialog = FileSaveDialog("New File", "", "Text Files (*.txt)") If $NewDialog <> "" Then $OpenedFilePath = $NewDialog & ".txt" $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, GUICtrlRead($EditControl)) EndIf Else FileDelete($OpenedFilePath) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFilePath, GUICtrlRead($EditControl)) EndFunc The error is saying: Error line 112 Error: "Wend statement with no matching "While" Statement" Help me please. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted August 16, 2009 Moderators Share Posted August 16, 2009 vi6ora,If you were to try running the code through Tidy (Ctrl-T in SciTE) you would soon see that you are missing the EndIf for the If on line 102.M23 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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Valuater Posted August 16, 2009 Share Posted August 16, 2009 According to what I see... it's a mess for sure here is the wend If $SaveChangesBox = 7 Then GUICtrlSetData($EditControl, "") Wend EndSwitch In the lower window pane of SciTE, click on the RED line The upper window will go directly to the problem 8) Link to comment Share on other sites More sharing options...
vi6ora Posted August 16, 2009 Author Share Posted August 16, 2009 Thanks i fixed it now. But i have one more problem [ hope its the last one ]. When i type somthing the save msg box popsup how can i fix it? I want to pop only if i pressed New or save or close, not only when i type something. Thanks in advance.expandcollapse popup#include <GUIConstants.au3> #include <File.au3> #include <GuiEdit.au3> #include <Misc.au3> #include <String.au3> #include <ModernMenu.au3> Local $WIDTH, $HEIGHT, $WS_OVERLAPPEDWINDOW, $WS_VISIBLE, $WS_CLIPSIBLINGS, $WS_EX_ACCEPTFILES $OpenedFilePath = "no file" $OpenedFile = "no file" $TextEditor = GUICreate("Simple Text Editor", 800, 600, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) $EditControl = GUICtrlCreateEdit("", 0, 0, 800, 600, -1, $WS_EX_ACCEPTFILES) GUICtrlSetData(-1, "") GUICtrlSetFont(-1, 10, 800, 0, "MS Sans Serif") GUICtrlSetColor(-1, 0x00FF00) GUICtrlSetBkColor(-1, 0x000000) GUISetState(@SW_SHOW) $FileMenu = GUICtrlCreateMenu("&File") $nSideItem1 = _CreateSideMenu($FileMenu) _SetSideMenuText($nSideItem1, "UTE Menu") _SetSideMenuColor($nSideItem1, 0xAAFFAA) ; default color - white _SetSideMenuBkColor($nSideItem1, 0x921801) ; bottom start color - dark blue _SetSideMenuBkGradColor($nSideItem1, 0xFBCE92) ; top end color - light blue $NEW = _GUICtrlCreateODMenuItem("&Print" & @TAB & "Ctrl+S", $FileMenu, "shell32.dll", -55) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -55) _GUICtrlCreateODMenuItem("", $FileMenu) $OpenFile = _GUICtrlCreateODMenuItem("&Open..." & @TAB & "Ctrl+O", $FileMenu) _GUICtrlODMenuItemSetIcon(-1, "shell32.dll", -4) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -5) $SaveFile = _GUICtrlCreateODMenuItem("&Save" & @TAB & "Ctrl+S", $FileMenu, "shell32.dll", -7) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -79) _GUICtrlCreateODMenuItem("", $FileMenu) $PrintFile = _GUICtrlCreateODMenuItem("&Print" & @TAB & "Ctrl+S", $FileMenu, "shell32.dll", -17) _GUICtrlODMenuItemSetSelIcon(-1, "shell32.dll", -164) _GUICtrlCreateODMenuItem("", $FileMenu) $ExitFile = _GUICtrlCreateODMenuItem("E&xit", $FileMenu, "shell32.dll", -28) _SetMenuBkColor(0xAAFFAA) _SetMenuIconBkColor(0x66BB66) _SetMenuSelectBkColor(0xBBCC88) _SetMenuSelectRectColor(0x222277) _SetMenuSelectTextColor(0x770000) _SetMenuTextColor(0x000000) While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE If $OpenedFilePath <> "no file" Then If GUICtrlRead($EditControl) <> FileRead($OpenedFile) Then $SaveChangesBox = MsgBox(3, "Save File?", "Would you like to save the changes you made?") If $SaveChangesBox = 6 Then FileDelete($OpenedFilePath) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, GUICtrlRead($EditControl)) Exit ElseIf $SaveChangesBox = 7 Then Exit EndIf Else Exit EndIf Else Exit EndIf Case $PrintFile $PrintFileFunction = _FilePrint($OpenedFilePath) If $PrintFileFunction Then MsgBox(0, "Print", "The file was printed.") Else MsgBox(0, "Print Error", "The file was not printed.") EndIf Case $OpenFile $OpenFileDialog = FileOpenDialog("Load Text File", "", "Text Files (*.txt)") If FileExists($OpenFileDialog) Then $OpenedFilePath = $OpenFileDialog $PreviousFileRead = FileRead($OpenedFilePath) FileDelete($OpenedFilePath) GUICtrlSetData($EditControl, $PreviousFileRead) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, $PreviousFileRead) EndIf Case $ExitFile Terminate() Case $SaveFile If $OpenedFilePath = "no file" Then $NewDialog = FileSaveDialog("New File", "", "Text Files (*.txt)") If $NewDialog <> "" Then $OpenedFilePath = $NewDialog & ".txt" $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, GUICtrlRead($EditControl)) EndIf Else FileDelete($OpenedFilePath) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFilePath, GUICtrlRead($EditControl)) EndIf Case $msg = $NEW If GUICtrlRead($EditControl) <> "" Then $SaveChangesBox = MsgBox(3, "Save?", "Would you like to save?") If $SaveChangesBox = 6 Then SaveFile() EndIf If $SaveChangesBox = 7 Then FileDelete($OpenFile) FileWrite($OpenFile, GUICtrlRead($EditControl)) EndIf If $SaveChangesBox = 7 Then GUICtrlSetData($EditControl, ""). EndIf EndSwitch WEnd Func Terminate() Exit EndFunc ;==>Terminate Func SaveFile() If $OpenedFilePath = "no file" Then $NewDialog = FileSaveDialog("New File", "", "Text Files (*.txt)") If $NewDialog <> "" Then $OpenedFilePath = $NewDialog & ".txt" $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFile, GUICtrlRead($EditControl)) EndIf Else FileDelete($OpenedFilePath) $OpenedFile = FileOpen($OpenedFilePath, 0 + 2) FileWrite($OpenedFilePath, GUICtrlRead($EditControl)) EndIf EndFunc ;==>SaveFile Link to comment Share on other sites More sharing options...
Developers Jos Posted August 16, 2009 Developers Share Posted August 16, 2009 This looks wrong: Case $msg = $NEW 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 More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now