VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   7170
   ClientLeft      =   165
   ClientTop       =   735
   ClientWidth     =   7980
   Icon            =   "Form1editor.frx":0000
   LinkTopic       =   "Form1"
   ScaleHeight     =   7170
   ScaleWidth      =   7980
   StartUpPosition =   3  'Windows Default
   Begin MSComctlLib.StatusBar StatusBar1 
      Align           =   2  'Align Bottom
      Height          =   375
      Left            =   0
      TabIndex        =   4
      Top             =   6795
      Width           =   7980
      _ExtentX        =   14076
      _ExtentY        =   661
      Style           =   1
      _Version        =   393216
      BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628} 
         NumPanels       =   1
         BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628} 
         EndProperty
      EndProperty
   End
   Begin VB.ListBox labellist 
      Height          =   4935
      Left            =   5520
      TabIndex        =   2
      Top             =   480
      Width           =   2295
   End
   Begin VB.TextBox Text1 
      BeginProperty Font 
         Name            =   "System"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   5535
      Left            =   0
      MultiLine       =   -1  'True
      ScrollBars      =   3  'Both
      TabIndex        =   0
      Top             =   0
      Width           =   5295
   End
   Begin VB.TextBox quickhelp 
      Height          =   4935
      Left            =   5520
      MultiLine       =   -1  'True
      TabIndex        =   3
      Top             =   480
      Visible         =   0   'False
      Width           =   2295
   End
   Begin VB.TextBox debug 
      BeginProperty Font 
         Name            =   "Small Fonts"
         Size            =   6.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   4935
      Left            =   5520
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   5
      Top             =   480
      Visible         =   0   'False
      Width           =   2295
   End
   Begin MSComctlLib.TabStrip TabStrip1 
      Height          =   5535
      Left            =   5400
      TabIndex        =   1
      Top             =   0
      Width           =   2535
      _ExtentX        =   4471
      _ExtentY        =   9763
      _Version        =   393216
      BeginProperty Tabs {1EFB6598-857C-11D1-B16A-00C0F0283628} 
         NumTabs         =   3
         BeginProperty Tab1 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Labels"
            Key             =   "labels"
            Object.ToolTipText     =   "Show shortcuts to lables"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab2 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Quick Help"
            Key             =   "quickhelp"
            Object.ToolTipText     =   "Display the quick help system"
            ImageVarType    =   2
         EndProperty
         BeginProperty Tab3 {1EFB659A-857C-11D1-B16A-00C0F0283628} 
            Caption         =   "Debug"
            Key             =   "debug"
            Object.ToolTipText     =   "View important debugging info"
            ImageVarType    =   2
         EndProperty
      EndProperty
   End
   Begin VB.Menu file 
      Caption         =   "File"
      Begin VB.Menu open 
         Caption         =   "Open Script"
         Shortcut        =   ^O
      End
      Begin VB.Menu save 
         Caption         =   "Save Script"
         Shortcut        =   ^S
      End
      Begin VB.Menu saveas 
         Caption         =   "Save Script As..."
         Shortcut        =   ^A
      End
      Begin VB.Menu exit 
         Caption         =   "Exit"
      End
   End
   Begin VB.Menu edit 
      Caption         =   "Edit"
      Begin VB.Menu cut 
         Caption         =   "Cut"
         Shortcut        =   ^X
      End
      Begin VB.Menu copy 
         Caption         =   "Copy"
         Shortcut        =   ^C
      End
      Begin VB.Menu paste 
         Caption         =   "Paste"
         Shortcut        =   ^Z
      End
      Begin VB.Menu spacer 
         Caption         =   "--"
      End
      Begin VB.Menu find 
         Caption         =   "Find..."
         Shortcut        =   ^F
      End
      Begin VB.Menu gotorow 
         Caption         =   "Goto Row..."
         Shortcut        =   ^G
      End
      Begin VB.Menu goto 
         Caption         =   "Goto label..."
         Shortcut        =   ^L
      End
   End
   Begin VB.Menu view 
      Caption         =   "View"
      Begin VB.Menu viewsyntax 
         Caption         =   "View Syntax"
      End
      Begin VB.Menu viewcurs 
         Caption         =   "View Cursor info"
         Checked         =   -1  'True
      End
   End
   Begin VB.Menu run 
      Caption         =   "Run"
      Begin VB.Menu run_script 
         Caption         =   "Run This Script"
         Shortcut        =   {F5}
      End
      Begin VB.Menu haltscript 
         Caption         =   "Halt Script"
      End
      Begin VB.Menu continuescript 
         Caption         =   "Continue Script"
      End
      Begin VB.Menu realtime 
         Caption         =   "Real Time"
         Shortcut        =   ^R
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Sub continuescript_Click()
berr = 1
End Sub

Private Sub exit_Click()
End
End Sub

Public Sub Form_Load()
Form1.Show

Form1.Caption = "Buzzscript 2.x - " + btch$
Text1.text = ""
For d = 1 To mx
Text1.text = Text1.text + script$(d) + vbCrLf
Next
End Sub

Private Sub Form_Resize()
If Form1.Height > 1650 Then
Text1.Height = Form1.Height - 1100
TabStrip1.Height = Form1.Height - 1100
labellist.Height = Form1.Height - 1650
quickhelp.Height = Form1.Height - 1650
Form1.debug.Height = Form1.Height - 1650
'Frame1.Top = Text1.Height
End If
If Form1.Width > 2700 Then
Text1.Width = Form1.Width - 2700
'Frame1.Width = Form1.Width - 110
TabStrip1.Left = Form1.Width - 2700
quickhelp.Left = Form1.Width - 2600
labellist.Left = Form1.Width - 2600
Form1.debug.Left = Form1.Width - 2600
End If
If Form1.Width < 3000 Then Form1.Width = 3000
End Sub

Private Sub Form_Unload(Cancel As Integer)
End
End Sub

Private Sub goto_Click()
Form6.Show
End Sub

Private Sub gotorow_Click()
Form4.Show
End Sub

Sub haltscript_Click()
pointer = mx
End Sub

Private Sub labellist_DblClick()
Text1.SetFocus

gotoline (variable(labellist.List(labellist.ListIndex)) - 1)
highlightline (variable(labellist.List(labellist.ListIndex)) - 1)
End Sub

Public Sub open_Click()
For d = 1 To mx
script$(d) = ""
Next
mx = 0
mainform.CommonDialog1.Filter = "*.buzzscript"
mainform.CommonDialog1.ShowOpen
If Len(mainform.CommonDialog1.FileName) > 0 Then
btch$ = mainform.CommonDialog1.FileName
readbatch btch$
Text1.text = ""
For d = 1 To mx
Text1.text = Text1.text + script$(d) + vbCrLf
Next
Form1.Caption = "Buzzscript 2.x - " + btch$
End If
End Sub

Private Sub realtime_Click()
Form3.Show

End Sub

Public Sub run_script_Click()
If btch$ = "" Then
MsgBox ("Script must be saved before u can run it!")
Else
pointer = 1
Open btch$ For Output As 9
'For d = 1 To mx
'Print #9, script$(d)
'Next
Print #9, Text1.text
Close 9
For d = 1 To mx
script$(d) = ""
Next
mx = 0
readbatch btch$
'MsgBox (mx)
tp = mx
runscript tp
End If
End Sub

Public Sub save_Click()
Open btch$ For Output As 9
'For d = 1 To mx
'Print #9, script$(d)
'Next
Print #9, Text1.text
Close 9
unsaved = 0
If Left(Form1.Caption, Len("unsaved - ")) = "unsaved - " Then Form1.Caption = Right(Form1.Caption, Len(Form1.Caption) - Len("unsaved - "))
End Sub

Public Sub saveas_Click()
mainform.CommonDialog1.Filter = "*.buzzscript"
mainform.CommonDialog1.ShowOpen
btch$ = mainform.CommonDialog1.FileName
Open btch$ For Output As 9
'For d = 1 To mx
'Print #9, script$(d)
'Next
Print #9, Text1.text

Close 9
Form1.Caption = "Buzzscript 2.x - " + btch$
unsaved = 0
If Left(Form1.Caption, Len("unsaved - ")) = "unsaved - " Then Form1.Caption = Right(Form1.Caption, Len(Form1.Caption) - Len("unsaved - "))
End Sub

Private Sub TabStrip1_Click()
'MsgBox TabStrip1.SelectedItem
si = TabStrip1.SelectedItem

Form1.labellist.Visible = False
Form1.quickhelp.Visible = False
Form1.debug.Visible = False

If si = "Quick Help" Then Form1.quickhelp.Visible = True
If si = "Labels" Then Form1.labellist.Visible = True
If si = "Debug" Then Form1.debug.Visible = True


End Sub

Private Sub Text1_Click()
display_info
End Sub

Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
'display_info
End Sub

Sub Text1_KeyPress(KeyAscii As Integer)
End Sub

Function cursor_x()
tx = Text1.text
cp = Text1.SelStart
d = 1
ct = 0

l$ = Left$(tx, cp)
l$ = Replace(l$, vbCrLf, "§")

For d = 1 To Len(l$)
If Mid$(l$, d, 1) = "§" Then
ct = ct + 1
ld = d
End If
Next

ll = Len(l$)
xps = ll - ld

'Label1.Caption = "X:" + Str$(xps) + " Y:" + Str$(ct) + " Index:" + Str$(d)
cursor_x = xps
End Function
Function cursor_y()
tx = Text1.text
cp = Text1.SelStart
d = 1
ct = 0

l$ = Left$(tx, cp)
l$ = Replace(l$, vbCrLf, "§")

For d = 1 To Len(l$)
If Mid$(l$, d, 1) = "§" Then
ct = ct + 1
ld = d
End If
Next

ll = Len(l$)
xps = ll - ld

'Label1.Caption = "X:" + Str$(xps) + " Y:" + Str$(ct) + " Index:" + Str$(d)
cursor_y = ct
End Function

Sub display_info()
'tx = Text1.text
'cp = Text1.SelStart
'd = 1
'ct = 0
'
'l$ = Left$(tx, cp)
'l$ = Replace(l$, vbCrLf, "§")

'For d = 1 To Len(l$)
'If Mid$(l$, d, 1) = "§" Then
'ct = ct + 1
'ld = d
'End If
'Next

'll = Len(l$)
'xps = ll - ld
If viewcurs.Checked = False Then
displayline (cursor_y)
Else
StatusBar1.SimpleText = "X:" + Str$(cursor_x) + " Y:" + Str$(cursor_y)
End If
'If Check1.value = 1 Then displayline (ct)

End Sub

Sub gotoline(lookfor_line)

tx = Text1.text
cp = Text1.SelStart
d = 1
ct = 0
'MsgBox Text1.SelStart
l$ = tx
l$ = Replace(l$, vbCrLf, "§")


For d = 1 To Len(l$)
If Mid$(l$, d, 1) = "§" Then
ct = ct + 1
'MsgBox Str$(ct)
'MsgBox lookfor_line
If ct + 0 = lookfor_line + 0 Then
'MsgBox "got it at:" & Str$(d)

Text1.SelStart = d + ct
Text1.SelLength = 0

display_info
Exit Sub

End If
ld = d
End If
Next

'll = Len(l$)
'xps = ll - ld
'Label1.Caption = "X:" + Str$(xps) + " Y:" + Str$(ct)


End Sub

Sub displayline(lookfor_line)

tx = Text1.text

d = 1
ct = 0

l$ = tx
l$ = Replace(l$, vbCrLf, "§")

For d = 1 To Len(l$)
If Mid$(l$, d, 1) = "§" Then
ct = ct + 1
If ct + 0 = lookfor_line + 0 Then
start = d
End If
ld = d
End If
Next
r$ = Right$(l$, Len(l$) - start)
nd = InStr(r$, "§")
If nd = 0 Then nd = Len(r$)
If nd > 0 Then r$ = Left$(r$, nd - 1)
If Len(r$) > 0 Then parse "?" + r$, "editor"


End Sub

Sub highlightline(lookfor_line)

tx = Text1.text

d = 1
ct = 0

l$ = tx
l$ = Replace(l$, vbCrLf, "§")

For d = 1 To Len(l$)
If Mid$(l$, d, 1) = "§" Then
ct = ct + 1
If ct + 0 = lookfor_line + 0 Then
start = d + ct
dstart = d
End If
ld = d
End If
Next
r$ = Right$(l$, Len(l$) - dstart)
nd = InStr(r$, "§")
If nd = 0 Then nd = Len(r$)
If nd > 0 Then r$ = Left$(r$, nd - 1)
If Len(r$) > 0 Then
Text1.SelStart = start
Text1.SelLength = nd
End If


End Sub

Sub popuphelp(lookfor_line)

tx = Text1.text

d = 1
ct = 0

l$ = tx
l$ = Replace(l$, vbCrLf, "§")

For d = 1 To Len(l$)
If Mid$(l$, d, 1) = "§" Then
ct = ct + 1
If ct + 0 = lookfor_line + 0 Then
start = d
End If
ld = d
End If
Next
r$ = Right$(l$, Len(l$) - start)
nd = InStr(r$, "§")
If nd = 0 Then nd = Len(r$)
If nd > 0 Then r$ = Left$(r$, nd - 1)
'Form5.Show
Form1.quickhelp.text = ""
If Len(r$) > 0 Then parse "?" + r$, "popup"
If Len(r$) > 0 Then dbug "popup", "---------"
If Len(r$) > 0 Then parse "??" + r$, "popup"


End Sub

Private Sub Text1_KeyUp(KeyCode As Integer, Shift As Integer)
display_info
oldunsaved = unsaved
unsaved = 1
If oldunsaved <> unsaved Then Form1.Caption = "unsaved - " + Form1.Caption
'If Check1.value = 1 Then MsgBox KeyCode
'help was called
If KeyCode = 112 Then popuphelp (cursor_y)
End Sub

Private Sub Text1_Validate(Cancel As Boolean)
'display_info
End Sub

Private Sub viewcurs_Click()
viewsyntax.Checked = False
viewcurs.Checked = True
End Sub

Private Sub viewsyntax_Click()
viewcurs.Checked = False
viewsyntax.Checked = True

End Sub
