' Very simple notepad like editor, in less than 200 lines of code! $APPTYPE GUI $TYPECHECK ON '' Strict type checking, so I don't make mistakes. $INCLUDE "RAPIDQ.INC" '' You don't need them all in this example. DIM MainForm AS QForm DIM DialogBox AS QForm DIM EditBox AS QEdit DIM RichEdit AS QRichEdit DIM MainMenu AS QMainMenu DIM File AS QMenuItem, Edit AS QMenuItem DIM New AS QMenuItem, Open AS QMenuItem, ReOpen AS QMenuItem DIM ReOpen1 AS QMenuItem, ReOpen2 AS QMenuItem, ReOpen3 AS QMenuItem DIM Save AS QMenuItem, SaveAs AS QmenuItem DIM Break1 AS QMenuItem DIM ExitEditor AS QMenuItem DIM Copy AS QMenuItem, Cut AS QMenuItem, Paste AS QMenuItem, SelectAll AS QMenuItem DIM Search AS QMenuItem, Find AS QMenuItem DIM FileName AS STRING FileName = "UNTiTLED" DIM CountFiles AS BYTE CountFiles = 0 SUB ExitEditorClick '' Exit item clicked MainForm.Close END SUB SUB NewClick '' New item clicked RichEdit.Clear FileName = "UNTiTLED" END SUB SUB OpenClick '' Open item clicked DIM OpenDialog AS QOpenDialog IF OpenDialog.Execute THEN FileName = OpenDialog.FileName RichEdit.LoadFromFile FileName IF CountFiles = 0 THEN ReOpen.Enabled = True ReOpen1.Caption = "&1. "+FileName ReOpen.Insert 0, ReOpen1 ELSEIF CountFiles = 1 THEN ReOpen2.Caption = "&2. "+FileName ReOpen.Insert 1, ReOpen2 ELSEIF CountFiles = 2 THEN ReOpen3.Caption = "&3. "+FileName ReOpen.Insert 2, ReOpen3 ELSE CountFiles = CountFiles - 1 ReOpen1.Caption = "&1. "+RIGHT$(ReOpen2.Caption, LEN(ReOpen2.Caption)-4) ReOpen2.Caption = "&2. "+RIGHT$(ReOpen3.Caption, LEN(ReOpen3.Caption)-4) ReOpen3.Caption = "&3. "+FileName END IF CountFiles = CountFiles + 1 RichEdit.Modified = False END IF END SUB SUB SaveAsClick '' SaveAs item clicked DIM SaveDialog AS QSaveDialog IF SaveDialog.Execute THEN RichEdit.SaveToFile SaveDialog.FileName END IF END SUB SUB SaveClick IF FileName = "UNTiTLED" THEN SaveAsClick ELSE RichEdit.SaveToFile FileName END IF END SUB SUB CopyClick: RichEdit.CopyToClipBoard: END SUB '' Oh yeah, that was easy SUB CutClick: RichEdit.CutToClipBoard: END SUB SUB PasteClick: RichEdit.PasteFromClipBoard: END SUB SUB SelectAllClick: RichEdit.SelectAll: END SUB SUB Reopen1Click IF RichEdit.Modified THEN SHOWMESSAGE "Abandoning changes" END IF RichEdit.LoadFromFile RIGHT$(ReOpen1.Caption, LEN(ReOpen1.Caption)-4) RichEdit.Modified = False END SUB SUB Reopen2Click IF RichEdit.Modified THEN SHOWMESSAGE "Abandoning changes" END IF RichEdit.LoadFromFile RIGHT$(ReOpen2.Caption, LEN(ReOpen2.Caption)-4) RichEdit.Modified = False END SUB SUB Reopen3Click IF RichEdit.Modified THEN SHOWMESSAGE "Abandoning changes" END IF RichEdit.LoadFromFile RIGHT$(ReOpen3.Caption, LEN(ReOpen3.Caption)-4) RichEdit.Modified = False END SUB SUB FindText '' Primitive search... RichEdit.SelStart = INSTR(UCASE$(RichEdit.Text), UCASE$(EditBox.Text))-1 IF RichEdit.SelStart > 0 THEN RichEdit.SelLength = LEN(EditBox.Text) DialogBox.Close ELSE SHOWMESSAGE EditBox.Text+" not found." END IF END SUB SUB FindClick DIM Button AS QButton Button.Parent = DialogBox Button.OnClick = FindText Button.Caption = "&OK" Button.Top = 13 Button.Left = 210 Button.Width = 70 EditBox.Parent = DialogBox EditBox.Top = 15 EditBox.Left = 20 EditBox.Width = 170 DialogBox.BorderStyle = bsDialog DialogBox.Caption = "Search..." DialogBox.Width = 300 DialogBox.Height = 80 DialogBox.Center DialogBox.ShowModal END SUB SUB FormResize RichEdit.Width = MainForm.ClientWidth RichEdit.Height = MainForm.ClientHeight END SUB New.Caption = "&New" : New.OnClick = NewClick Open.Caption = "&Open" : Open.OnClick = OpenClick ReOpen.Caption = "&ReOpen" ReOpen.Enabled = False ReOpen1.Caption = "" : ReOpen1.OnClick = Reopen1Click ReOpen2.Caption = "" : ReOpen2.OnClick = Reopen2Click ReOpen3.Caption = "" : ReOpen3.OnClick = Reopen3Click Save.Caption = "&Save" : Save.OnClick = SaveClick SaveAs.Caption = "Save &As..." : SaveAs.OnClick = SaveAsClick Break1.Caption ="-" ExitEditor.Caption = "E&xit" : ExitEditor.OnClick = ExitEditorClick File.Caption = "&File" File.AddItems New,Open,ReOpen,Save,SaveAs,Break1,ExitEditor Copy.Caption = "&Copy" : Copy.OnClick = CopyClick Copy.ShortCut = "CTRL+C" Cut.Caption = "Cu&t" : Cut.OnClick = CutClick Cut.ShortCut = "CTRL+X" Paste.Caption = "&Paste" : Paste.OnClick = PasteClick Paste.ShortCut = "CTRL+V" SelectAll.Caption = "&Select All" : SelectAll.OnClick = SelectAllClick Edit.Caption = "&Edit" Edit.AddItems Copy,Cut,Paste,SelectAll Find.Caption = "&Find" Find.OnClick = FindClick Search.Caption = "&Search" Search.AddItems Find MainMenu.Parent = MainForm MainMenu.AddItems File,Edit,Search RichEdit.Parent = MainForm RichEdit.Width = MainForm.ClientWidth RichEdit.Height = MainForm.ClientHeight RichEdit.ScrollBars = ssBoth RichEdit.PlainText = True RichEdit.WordWrap = False MainForm.Caption = "Simple, notepad like editor" MainForm.Width = 500 MainForm.Height = 400 MainForm.Center MainForm.OnResize = FormResize MainForm.ShowModal