SUB FormClose(Action AS INTEGER)
Action = 0
END SUB

DECLARE FUNCTION GetShortPathName Lib "kernel32" Alias "GetShortPathNameA"(ByVal lpszLongPath As String, ByVal lpszShortPath As long, ByVal lBuffer As Long) As Long
DOEVENTS
DIM Font AS QFONT
Font.Name = "OCR A Extended"
Font.Size = 12
Font.Color = 0
DOEVENTS
DECLARE SUB FWCoolBtn1Click (Sender AS QCOOLBTN)
DECLARE SUB FWCoolBtn2Click (Sender AS QCOOLBTN)
DECLARE SUB FWCoolBtn3Click (Sender AS QCOOLBTN)
DECLARE SUB FWCoolBtn4Click (Sender AS QCOOLBTN)
DECLARE SUB FWCoolBtn5Click (Sender AS QCOOLBTN)
DECLARE SUB FWCoolBtn6Click (Sender AS QCOOLBTN)
DECLARE SUB FWListBox1Click (Sender AS QLISTBOX)
DECLARE SUB FWEdit1Change (Sender AS QEDIT)
DECLARE SUB FWEdit2Change (Sender AS QEDIT)
DECLARE SUB FWRichEdit2Change (Sender AS QRICHEDIT)
DECLARE SUB FWButton1Click (Sender AS QBUTTON)
DECLARE SUB miFileNew_Click (Sender as QMENUITEM)
DECLARE SUB miFileOpen_Click (Sender as QMENUITEM)
DECLARE SUB miFileSave_Click (Sender as QMENUITEM)
DECLARE SUB miFileExit_Click (Sender as QMENUITEM)
DECLARE SUB miInsInc_Click (Sender as QMENUITEM)
DECLARE SUB miInsIns_Click (Sender as QMENUITEM)
DECLARE SUB Button1Click (Sender AS QBUTTON)
DECLARE SUB miAboutClick
DECLARE SUB miAbout2Click
DECLARE SUB OKD(Key AS WORD)
DECLARE SUB ButtonA1Click (Sender AS QBUTTON)
DECLARE SUB miSourceOptsClick
DECLARE SUB miSourceCompClick
DECLARE SUB miDelCommClick
DECLARE SUB miDelFontClick
DECLARE SUB miDelEnterClick
DECLARE SUB miToolsFormWClick

DOEVENTS
$RESOURCE Manifest AS "RunTime1.exe.manifest"

FUNCTION RemDir$(PathFile AS STRING) AS STRING
RemDir$ = RIGHT$(PathFile,LEN(PathFile) - RINSTR(PathFile,"\"))
END FUNCTION

FUNCTION RemExt$(PathFile AS STRING) AS STRING
DIM RE$ AS STRING
IF RINSTR(PathFile,".") > RINSTR(PathFile,"\") THEN RE$ = LEFT$(PathFile,RINSTR(PathFile,".") - 1) ELSE RE$ = PathFile
RemExt$ = RE$
END FUNCTION

FUNCTION GetExt$(PathFile AS STRING) AS STRING
DIM GE$ AS STRING
IF RINSTR(PathFile, ".") <> "" THEN GE$ = RIGHT$(PathFile, LEN(PathFile) - RINSTR(PathFile,".")) ELSE GE$ = ""
GetExt$ = GE$
END FUNCTION

FUNCTION GetDir$(PathFile AS STRING) AS STRING
GetDir$ = LEFT$(PathFile, RINSTR(PathFile,"\"))
END FUNCTION

DOEVENTS

DIM VERSION$ AS STRING
VERSION$ = "1.1.03.06 (Parts of...)"
CREATE FormA AS QFORM
    Caption = "About RunTime"
    ClientWidth = 356    
    ClientHeight = 200
    Center
    BorderStyle = 3
    CREATE ImageA1 AS QIMAGE
        Left = 8
        Top = 8
        Width = 32
        Height = 32
        Icon = Application.Icon
    END CREATE
    CREATE LabelA1 AS QLABEL
        Caption = "RunTime "+VERSION$+".1 SP0 by RapidBlue"
        Left = 48
        Top = 8
        Width = 300
        AutoSize=1
        Transparent = 1
    END CREATE
    CREATE PanelA1 AS QPANEL
        Left = 48
        Top = 24
        Width = 300
        Height = 135
        Color = &HFF0000
        BevelOuter = 1
        CREATE LabelA2 AS QLABEL
            Caption = "RapidBlue"+CHR$(10)+CHR$(10)+"Chief Programmer:"+CHR$(9)+"Robin Wellner"+CHR$(10)+"Programmers:"+CHR$(9)+CHR$(9)+"Neorej, Nibor Nebki"+CHR$(10)+"Thanks to:"+CHR$(9)+CHR$(9)+"Achilles B. Mina, William Yu, FMD,"+CHR$(10)+CHR$(9)+CHR$(9)+CHR$(9)+"John K., Oscar Fernandez,"+CHR$(10)+CHR$(9)+CHR$(9)+CHR$(9)+"Jordi Ramos, Borland and "+CHR$(10)+CHR$(9)+CHR$(9)+CHR$(9)+"Benjamin Maggi"+CHR$(10)+"Block2 icon by:"+CHR$(9)+CHR$(9)+"Robin Wellner"
            Left = 0
            Top = 135
                        AutoSize = 1
            Transparent = 1
        END CREATE
            END CREATE
 '   OnPaint = Draw
    CREATE ButtonA1 AS QBUTTON
        Caption = "&Close"
        Left = 48
        Top = 168
        Cancel = 1
        TabOrder = 1
        OnClick = ButtonA1Click
    END CREATE
END CREATE    
DOEVENTS
DIM TimerA AS QTIMER
SUB TimerATimer
LabelA2.Top = LabelA2.Top - 1
IF LabelA2.Top < -LabelA2.Height THEN TimerA.Enabled = 0
PanelA1.Color = &HFF0000 + (RND(&H4)* &H4)+(RND(&H4)* &H400)+&H5050
END SUB
TimerA.Enabled = 0
TimerA.OnTimer = TimerATimer
TimerA.Interval = 50
DOEVENTS
$INCLUDE  "rapidq2\RapidQ2.inc"
$INCLUDE "eMail.Inc"
CONST GWL_STYLE = -16
SUB FixIt(FixHandle AS LONG)
	SetWindowLong(FixHandle, GWL_STYLE, GetWindowLong(FixHandle, GWL_STYLE) XOR 11)
END SUB



DOEVENTS


CREATE Form AS QFORMEX
    Caption = "RunTime 1 (Less Funcs Edition) by RapidBlue, this program is freeware"
    Width = 733
    Height = 564
    Center
    CREATE mnuMain as QMAINMENU 'Created with menudesigner 
	CREATE miFile as QMENUITEM   
		Caption = "&File"
		Checked = 0
		Enabled = 1
		Visible = 1
		CREATE miFileNew as QMENUITEM   
			Caption = "&New"
			Checked = 0
			Enabled = 1
			Visible = 1
			ShortCut = "Ctrl+N"
			onclick = miFileNew_Click
		END CREATE 
		CREATE miFileOpen as QMENUITEM   
			Caption = "&Open..."
			Checked = 0
			Enabled = 1
			Visible = 1
			ShortCut = "Ctrl+O"
			onclick = miFileOpen_Click
		END CREATE 
		CREATE miFileSave as QMENUITEM   
			Caption = "&Save as..."
			Checked = 0
			Enabled = 1
			Visible = 1
			ShortCut = "Ctrl+S"
			onclick = miFileSave_Click
		END CREATE 
		CREATE miFileBreak as QMENUITEM   
			Caption = "-"
			Checked = 0
			Enabled = 1
			Visible = 1
		END CREATE 
		CREATE miFileExit as QMENUITEM   
			Caption = "&Exit"
			Checked = 0
			Enabled = 1
			Visible = 1
			ShortCut = "Alt+F4"
			onclick = miFileExit_Click
		END CREATE 
	END CREATE 
	CREATE miIns as QMENUITEM   
		Caption = "&Insert"
		Checked = 0
		Enabled = 1
		Visible = 1
		CREATE miInsInc as QMENUITEM   
			Caption = "Insert in&clude file..."
			Checked = 0
			Enabled = 1
			Visible = 1
			ShortCut = "Ctrl+I"
			onclick = miInsInc_Click
		END CREATE
		CREATE miInsBreak as QMENUITEM   
			Caption = "-"
			Checked = 0
			Enabled = 1
			Visible = 1
		END CREATE 
		CREATE miInsIns as QMENUITEM   
			Caption = "Insert &file..."
			Checked = 0
			Enabled = 1
			Visible = 1
			ShortCut = "Ctrl+F"
			onclick = miInsIns_Click
		END CREATE 
	END CREATE 
      CREATE miDel AS QMENUITEM
          Caption = "&Delete"
          CREATE miDelComm AS QMENUITEM
              Caption = "Delete &Comments"
              ShortCut = "Ctrl+D"
              OnClick = miDelCommClick
          END CREATE
          CREATE miDelFont AS QMENUITEM
              Caption = "Reset &Plain Text"
              ShortCut = "Ctrl+P"
              OnClick = miDelFontClick
          END CREATE
          CREATE miDelEnter AS QMENUITEM
              Caption = "Delete _ Returns"
              ShortCut = "Ctrl+R"
              OnClick = miDelEnterClick
          END CREATE
      END CREATE
      CREATE miSource AS QMENUITEM
          Caption = "&Code"
          CREATE miSourceComp AS QMENUITEM
              Caption = "&Compile!"
              ShortCut = "F5"
              OnClick = miSourceCompClick
          END CREATE
          CREATE miSourceOpts AS QMENUITEM
              Caption = "Options..."
              ShortCut = "Alt+F5"
              OnClick = miSourceOptsClick
          END CREATE
      END CREATE
      CREATE miTools AS QMENUITEM
          Caption = "&Tools"
          CREATE miToolsFormW AS QMENUITEM
              Caption = "Form &Wizard..."
              ShortCut = "Shift+F3"
              OnClick = miToolsFormWClick
          END CREATE
          CREATE miToolsBreak AS QMENUITEM
              Caption = "-"
          END CREATE
      END CREATE
      CREATE miHelp AS QMENUITEM
          Caption = "&Help"
          CREATE miAbout AS QMENUITEM
              Caption = "&Credits..."
              OnClick = miAboutClick
          END CREATE
          CREATE miAbout2 AS QMENUITEM
              Caption = "&About..."
              OnClick = miAbout2Click
          END CREATE
          CREATE miBreak2 AS QMENUITEM
              Caption = "-"
          END CREATE
      END CREATE
END CREATE
    CREATE Label1 AS QLABEL
        Caption = "RunTime "+VERSION$+" by RapidBlue, based on the code of CodeBox, Eduardo, Compile1.0, Rapidq2 and MenuDesigner"
        Left = 0
        Top = 0
        Width = 725
        Align = 1
        Transparent = 1
    END CREATE
    KeyPreview = 1
    CREATE RichEdit1 AS QRICHEDIT
        Align = 5
        Font.Name = "OCR A Extended"
        Font.Size = 12
        WordWrap = 0
        OnKeyUp = OKD
        HideScrollBars = 0
        ScrollBars = 3
        WantTabs = 1
        AddStrings "'Type or copy code here", _
                   "'or use the Auto-Insert functions", _
                   "'or the FormWizard (Tools->Form Wizard)"
    END CREATE
    CREATE RichEdit2 AS QRICHEDIT
        Height = 145
        Align = 2
        '\Font.Name = "courier new"
                ReadOnly = 1
        ScrollBars = 2
        AddStrings "(Not Compiled)"
    END CREATE
END CREATE
DOEVENTS

SUB RunTool(Sender AS QMENUITEM)
RUN Sender.Hint
END SUB

DIM fsTools AS QFILESTREAM
fsTools.Open(RemExt$(COmmand$(0))+"Tools.txt",0)
DIM miToolsList(fsTools.LineCount) AS QMENUITEM
DIM iList AS INTEGER
DIM sTemp AS STRING
FOR iList = 0 TO fsTools.LineCOunt
sTemp = fsTools.ReadLine
miToolsList(iList).Caption = FIELD$(sTemp, "::", 1)
miToolsList(iList).Hint = FIELD$(sTemp, "::", 2)
miToolsList(iList).OnClick = RunTool
miToolsList(iList).ShortCut = "Ctrl+Alt+"+CHR$(iList+65)
miToolsList(iList).Enabled = FileExists(miToolsList(iList).Hint)
miTools.AddItems(miToolsList(iList))
NEXT iList
fsTools.Close
DOEVENTS

DECLARE SUB CloseOpts
CREATE fOpts AS QFORM
    Caption = "Options"
    ClientWidth = 208
    ClientHeight = 200
    BorderStyle = 3
    Left = Screen.Width \ 2
    Top = Screen.Height \ 2 - 200
    CREATE lPar AS QLABEL
        Caption = "Parameters (eg -g + iconname...):"
        Left = 8
        Top = 8
        Width = 192
        Font.AddStyles (0)
        Transparent = 1
    END CREATE
    CREATE ePar AS QEDIT
        Text = ""
        TabOrder = 0
        Left = 8
        Top = 24
        Width = 193
    END CREATE
    CREATE ckbMan AS QCHECKBOX
        Caption = "Export .manifest for XP Apps"
        Width = 150
        Left = 8
        Top = 48
        TabOrder = 1
    END CREATE
    CREATE lFont AS QLABEL
        Caption = "Font:"
        Left = 8
        Font.AddStyles (0)
        Top = 72
        Width = 192
                Transparent = 1
    END CREATE
    CREATE cbFont AS QCOMBOBOX
        Style = 2
        Text = "OCR A Extended"
        Left = 8
        'Height = 90
        Top = 89
        Width = 143 '193
        TabOrder = 2
        OnChange = miDelFontClick
    END CREATE
    CREATE cbSize AS QCOMBOBOX
        Style = 2
        Text = "12"
        Left = 159
        'Height = 90
        Top = 89
        Width = 50
        TabOrder = 3
        OnChange = miDelFontClick
    END CREATE
    CREATE lRunPar AS QLABEL
        Caption = "Parameters for your APP:"
        Left = 8
        Top = 118
        Width = 192
        Font.AddStyles (0)
        Transparent = 1
    END CREATE
    CREATE eRunPar AS QEDIT
        Text = ""
        TabOrder = 4
        Left = 8
        Top = 134
        Width = 193
    END CREATE
    CREATE btnOpts AS QBUTTON
        Caption = "&Close"
        Left = 8
        Top = 167
        TabOrder = 5
        Cancel = 1
        Default = 1
        OnClick = CloseOpts
    END CREATE
END CREATE    
DOEVENTS
DIM I AS INTEGER
cbFont.AddItems "OCR A Extended"
FOR I = 0 TO Font.FontCount-1
 cbFont.AddItems Font.FontName(I)
NEXT I
cbFont.ItemIndex = 0
FOR I = 8 TO 20
 cbSize.AddItems STR$(I)
NEXT I 
cbSize.ItemIndex = 4
SUB CloseOpts
fOpts.Close
END SUB
DOEVENTS
FixIt(btnOpts.Handle)

DIM ObjectType(0 TO 127) AS STRING
DIM ObjectName(0 TO 127) AS STRING
DIM ObjectProp(0 TO 127) AS STRING
DIM fwI AS BYTE
FOR fwI = 0 TO 127
    ObjectType(fwI) = "QBUTTON"
    ObjectName(fwI) = "Button"+STR$(fwI+1)
    ObjectProp(fwI) = "Left = 0"
NEXT fwI


CREATE FWForm AS QFORM
    BOrderStyle = 3
    Caption = "FormWizard (Based on the code of MenuDesigner)"
    ClientWidth = 410
    ClientHeight = 275
    Center
    CREATE FWCoolBtn1 AS QCOOLBTN
        Left = 328
        Top = 8
        Width = 23
        Caption = "+"
        Height = 22
        OnClick = FWCoolBtn1Click
    END CREATE
    CREATE FWCoolBtn2 AS QCOOLBTN
        Left = 328
        Top = 32
        Caption = "-"
        Width = 23
        Height = 22
        OnClick = FWCoolBtn2Click
    END CREATE
    CREATE FWCoolBtn3 AS QCOOLBTN
        Left = 328
        Top = 56
        Width = 23
        Height = 22
        Caption = "->"
        OnClick = FWCoolBtn3Click
    END CREATE
    CREATE FWCoolBtn4 AS QCOOLBTN
        Left = 328
        Top = 80
        Width = 23
        Caption = "<-"
        Height = 22
        OnClick = FWCoolBtn4Click
    END CREATE
    CREATE FWCoolBtn5 AS QCOOLBTN
        Left = 328
        Top = 104
        Width = 23
        Height = 22
        Caption = "^"
        OnClick = FWCoolBtn5Click
    END CREATE
    CREATE FWCoolBtn6 AS QCOOLBTN
        Left = 328
        Top = 128
        Width = 23
        Caption = "V"
        Height = 22
        OnClick = FWCoolBtn6Click
    END CREATE
    CREATE FWListBox1 AS QLISTBOX
        Left = 200
        Top = 8
        OnClick = FWListBox1Click
    END CREATE
    CREATE FWEdit1 AS QEDIT
        Text = "QBUTTON"
        Left = 200
        Top = 112
        TabOrder = 1
        OnChange = FWEdit1Change
    END CREATE
    CREATE FWEdit2 AS QEDIT
        Text = "Button1"
        Left = 200
        Top = 136
        TabOrder = 2
        OnChange = FWEdit2Change
    END CREATE
    CREATE FWRichEdit1 AS QRICHEDIT
        Left = 8
        Top = 8
        Height = 257
        PlainText = 1
        ScrollBars = 3
        HideSelection = 0
        TabOrder = 3
        WordWrap=0
        AddStrings "Center", _
                   "Caption="+CHR$(34)+"MainForm"+CHR$(34)
    END CREATE
    CREATE FWRichEdit2 AS QRICHEDIT
        Left = 200
        Top = 160
        Width = 121
        Height = 105
        ScrollBars = 3
        TabOrder = 4
        AddStrings "Left = 0"
        WordWrap=0
        OnChange = FWRichEdit2Change
    END CREATE
    CREATE FWButton1 AS QBUTTON
        Caption = "Build ->"
        Left = 328
        Top = 240
        TabOrder = 5
        OnClick = FWButton1Click
    END CREATE
END CREATE

DOEVENTS
FixIt(Button1.Handle)
FixIt(ButtonA1.Handle)
FixIt(FWButton1.Handle)

Sub FlashImClick
Flash.Close
END SUB

Flash.OnClose = 0
FlashIm.OnCLick = FlashImClick
Flash.OnKeyDown = FlashImClick
Flash.Close
Form.ShowModal

SUB OKD(Key AS WORD)
  'Tab
  IF Key = 9 THEN 
    RichEdit1.SelStart = RichEdit1.SelStart - 1
    RichEdit1.SelLength = 1
    RichEdit1.SelText = STRING$(2, " ")
      END IF
END SUB

SUB miFileNew_Click (Sender as QMENUITEM)
RichEdit1.Clear
RichEdit2.Clear
RichEdit2.AddStrings "(Not Compiled)"
END SUB

SUB miFileOpen_Click (Sender as QMENUITEM)
CREATE odOpen AS QOPENDIALOG
  Caption = "Open rapidq file"
  Filter = "Rapidq files (*.bas; *.rq; *.rqb; *.inc)|*.bas; *.rq; *.rqb; *.inc"
END CREATE
IF odOpen.Execute THEN
  RichEdit1.PlainText = 1
  RichEdit1.LoadFromFile odOpen.FileName
  RichEdit2.Clear
  RichEdit2.AddStrings "(Not Compiled)"
END IF
END SUB

SUB miFileSave_Click (Sender as QMENUITEM)
CREATE sdSave AS QSAVEDIALOG
  Caption = "Save rapidq file"
  Filter = "Rapidq files (*.bas; *.rq; *.rqb; *.inc)|*.bas; *.rq; *.rqb; *.inc"
END CREATE
IF sdSave.Execute THEN
  RichEdit1.PlainText = 1
  RichEdit1.SaveToFile sdSave.FileName
END IF  
END SUB

SUB miFileExit_Click (Sender as QMENUITEM)
Form.Close
END SUB

SUB miInsInc_Click (Sender as QMENUITEM)
DIM odInsInc AS QOPENDIALOG
    odInsInc.InitialDir = Application.Path()
    odInsInc.Filter = "Include-files (*.inc)|*.inc"
    odInsInc.Caption = "Insert Include-file..."
IF  odInsInc.Execute THEN
DIM iDummy AS INTEGER
    iDummy = RichEdit1.SelStart
DIM iLen AS INTEGER
    iLen = LEN("$INCLUDE " + CHR$(34) + odInsInc.FileName + CHR$(34) + CHR$(13) + CHR$(10))
RichEdit1.Text = "$INCLUDE " + CHR$(34) + odInsInc.FileName + CHR$(34) + CHR$(13) + CHR$(10) + RichEdit1.Text
RichEdit1.SelStart = iDummy + iLen
END IF
END SUB

SUB miInsIns_Click (Sender as QMENUITEM)
DIM odInsIns AS QOPENDIALOG
    odInsIns.InitialDir = Application.Path()
    odInsIns.Filter = "Rapidq files (*.bas; *.rq; *.rqb; *.inc; *.txt)|*.bas; *.rq; *.rqb; *.inc"
    odInsIns.Caption = "Insert File..."
IF  odInsIns.Execute THEN
DIM fsInsIns AS QFILESTREAM
    fsInsIns.Open(odInsIns.FileName,)
RichEdit1.SelText= fsInsIns.ReadStr(fsInsIns.Size) + CHR$(10)
    fsInsIns.Close
END IF
END SUB

SUB Button1Click (Sender AS QBUTTON)
DIM fsStream AS QFILESTREAM
    fsStream.Open(FileListBox1.FileName,)
RichEdit1.SelText = fsStream.ReadStr(fsStream.Size)
    fsStream.Close
END SUB

SUB miAboutClick
LabelA2.Top = 135
TimerA.Enabled = 1
FormA.ShowMOdal
TimerA.Enabled = 0
END SUB

SUB ButtonA1Click (Sender AS QBUTTON)
FormA.Close
END SUB


SUB miSourceOptsClick
fOpts.ShowModal
END SUB

SUB miSourceCompClick
dim fnamepath$ as string
dim filename as string
DIM fsStream AS QFILESTREAM
    fsStream.Open(Command$(0)+"ExampleFile.bas",65535)
    fsStream.WriteStr(RichEdit1.Text, LEN(RichEdit1.Text))
    fsStream.Close
DIM lengthFilename AS WORD

DIM dir AS STRING
    fnamepath$ = STRING$(165,0)
    lengthFilename = GetShortPathName(Application.Path,VARPTR(fnamepath$),164)
    dir = LEFT$(fnamepath$,lengthFilename)
SHELL(Application.FullPath()+"RC.EXE -l"+dir+" -i"+dir+" -gui -r "+ePar.text+ " "+CHR$(34)+COmmand$(0)+"ExampleFile.bas"+cHR$(34))
if ckbMan.Checked = 1 THEN ExtractResource(Resource(0),Command$(0)+"ExampleFile.exe.manifest") ELSE KILL(Command$(0)+"ExampleFile.exe.manifest")
RUN Command$(0)+"ExampleFile.exe "+eRunPar.Text
RichEdit2.LoadFromFile Application.FullPath()+"DUMP.$$$"
KILL Application.FullPath()+"DUMP.$$$"
END SUB

SUB miDelCommClick
DIM CommIndex AS INTEGER
DIM EnterIndex AS INTEGER
DO
IF INSTR(RichEdit1.Text, "'") > 0 THEN
 CommIndex = INSTR(RichEdit1.Text, "'")
  EnterIndex = INSTR(CommIndex, RichEdit1.Text, CHR$(13))
 IF EnterIndex = 0 THEN EnterIndex = LEN(RichEdit1.Text)
 RichEdit1.Text = DELETE$(RichEdit1.Text, CommIndex, EnterIndex-CommIndex)
END IF
IF INSTR(RichEdit1.Text, CHR$(10)+"REM ") > 0 THEN
 CommIndex = INSTR(RichEdit1.Text, CHR$(10)+"REM ")
 EnterIndex = INSTR(CommIndex, RichEdit1.Text, CHR$(13))
 IF EnterIndex = 0 THEN EnterIndex = LEN(RichEdit1.Text)
 RichEdit1.Text = DELETE$(RichEdit1.Text, CommIndex, EnterIndex-CommIndex)
END IF 
LOOP UNTIL (INSTR(RichEdit1.Text, "'") = 0) AND (INSTR(UCASE$(RichEdit1.Text), CHR$(10)+"REM ") = 0)
END SUB

SUB miDelFontClick
Font.Name = cbFont.Text
Font.Size = VAL(cbSize.Text)
DIM DummyInt AS INTEGER
DummyInt=RichEdit1.SelStart
RichEdit1.SelectAll
RichEdit1.SelAttributes.Name = Font.Name
RichEdit1.SelAttributes.Size = Font.Size
RichEdit1.SelAttributes.Color = Font.Color
RichEdit1.SelAttributes.Bold = 0
RichEdit1.SelAttributes.Italic = 0
RichEdit1.SelAttributes.UnderLine = 0
RichEdit1.SelAttributes.StrikeOut = 0
RichEdit1.SelStart=DummyInt
END SUB

SUB miAbout2Click
ShowMessage "RunTime "+VERSION$+".1 SP0.0 CodeName:BlueBox"
END SUB

SUB FWCoolBtn1Click (Sender AS QCOOLBTN)
FWListBox1.AddItems "Object "+STR$(FWListBox1.ItemCount+1)
END SUB

SUB FWCoolBtn2Click (Sender AS QCOOLBTN)
IF FWListBox1.ItemIndex > -1 THEN 
DIM X AS BYTE
X=FWListBox1.ItemIndex
FWListBox1.DelItems(FWListBox1.ItemIndex)
FOR I = X TO 126
ObjectType(I)=ObjectType(I+1)
ObjectName(I)=ObjectName(I+1)
ObjectProp(I)=ObjectProp(I+1)
NEXT I
END IF
END SUB

SUB FWCoolBtn3Click (Sender AS QCOOLBTN)
IF FWListBox1.ItemIndex > -1 THEN FWListBox1.Item(FWListBox1.ItemIndex) = " " + FWListBox1.Item(FWListBox1.ItemIndex)
END SUB

SUB FWCoolBtn4Click (Sender AS QCOOLBTN)
IF FWListBox1.ItemIndex > -1 THEN
 IF LEFT$(FWListBox1.Item(FWListBox1.ItemIndex), 1) = " " THEN FWListBox1.Item(FWListBox1.ItemIndex) = RIGHT$(FWListBox1.Item(FWListBox1.ItemIndex), LEN(FWListBox1.Item(FWListBox1.ItemIndex))-1)
END IF
END SUB

SUB FWCoolBtn5Click (Sender AS QCOOLBTN)
SWAP FWListBox1.Item(FWListBox1.ItemIndex), FWListBox1.Item(FWListBox1.ItemIndex-1)
SWAP ObjectType(FWListBox1.ItemIndex), ObjectType(FWListBox1.ItemIndex-1)
SWAP ObjectName(FWListBox1.ItemIndex), ObjectName(FWListBox1.ItemIndex-1)
SWAP ObjectProp(FWListBox1.ItemIndex), ObjectProp(FWListBox1.ItemIndex-1)
FWListBox1.ItemIndex=FWListBox1.ItemIndex-1
END SUB

SUB FWCoolBtn6Click (Sender AS QCOOLBTN)
SWAP FWListBox1.Item(FWListBox1.ItemIndex), FWListBox1.Item(FWListBox1.ItemIndex+1)
SWAP ObjectType(FWListBox1.ItemIndex), ObjectType(FWListBox1.ItemIndex+1)
SWAP ObjectName(FWListBox1.ItemIndex), ObjectName(FWListBox1.ItemIndex+1)
SWAP ObjectProp(FWListBox1.ItemIndex), ObjectProp(FWListBox1.ItemIndex+1)
FWListBox1.ItemIndex=FWListBox1.ItemIndex+1
END SUB

SUB FWListBox1Click (Sender AS QLISTBOX)
FWEdit1.Text = ObjectType(FWListBox1.ItemIndex)
FWEdit2.Text = ObjectName(FWListBox1.ItemIndex)
FWRichEdit2.Text = ObjectProp(FWListBox1.ItemIndex)
END SUB

SUB FWEdit1Change (Sender AS QEDIT)
ObjectType(FWListBox1.ItemIndex) = FWEdit1.Text
END SUB

SUB FWEdit2Change (Sender AS QEDIT)
ObjectName(FWListBox1.ItemIndex) = FWEdit2.Text
END SUB

SUB FWRichEdit2Change (Sender AS QRICHEDIT)
ObjectProp(FWListBox1.ItemIndex) = FWRichEdit2.Text
END SUB

SUB FWButton1Click (Sender AS QBUTTON)
FWForm.Close
   dim s as integer , b as integer 'Contadores
   Dim ctab1 as string , ctab2 as string 'Tabuladores
   dim cre as string 'Strings predefinidos
   dim Jtext as string
   DIM oldLevel as single, level as single, nextLevel as single 'el nombre lo dice
   Dim shCut$ as string 
   DIM g as single, SelTemp as long 'Variables de uso general Temporal
   Dim N as Long 
   Dim Tabu as String

   cre = "CREATE " : Jtext = "END CREATE" 
   Tabu = "    "
   RichEdit1.seltext = cre + "Form as QFORM"+CHR$(13)+ CHR$(10)
FOR I = 0 TO FWRichEdit1.LineCount-1
   RichEdit1.seltext = Tabu + FWRichEdit1.Line(I)+CHR$(13)+ CHR$(10)
NEXT I
   oldLevel = -1
   For s = 0 to FWListBox1.ItemCount-1
      Level = val(TALLY(FWListBox1.Item(s), " ")-1)
      IF s < FWListBox1.ItemCount-1 THEN nextLevel = val(TALLY(FWListBox1.Item(s+1), " ")-1) ELSE nextLevel = oldLevel
      ctab1 = string$(Level + 1, "x")
      ctab2 = string$(Level + 2, "x")
      ctab1 = replacesubstr$(ctab1, "x", Tabu)
      ctab2 = replacesubstr$(ctab2, "x", Tabu)
            
      with RichEdit1 
         .SelText = ctab1 + cre + ObjectName(s)+ " AS "+ObjectType(s) + CHR$(13)+CHR$(10)
      for i = 1 to TALLY(ObjectProp(s),CHR$(10))+1
         .SelText = ctab2 + FIELD$(ObjectProp(s), CHR$(10), i)+CHR$(10)
      next i
         if Level = nextLevel then
            .SelText = ctab1 + Jtext+CHR$(13)+CHR$(10)
         end if
         if Level > nextLevel then 
            for b = Level to nextLevel step -1
                ctab1 = string$(b + 1, "x")
                ctab1 = replacesubstr$(ctab1, "x", Tabu)
                .SelText = ctab1 + Jtext+CHR$(13)+CHR$(10)
            next
         end if
      end with
   next      
doevents
sleep 0.1
END SUB

SUB miToolsFormWClick
FWForm.SHowModal
END SUB

SUB miDelEnterClick
RichEdit1.Text =  ReplaceSubStr$(RichEdit1.Text, "_"+CHR$(13)+CHR$(10), "") 
END SUB
