@@ -15,7 +15,7 @@ Begin VB.Form Form1
1515 Begin MSComctlLib.ListView lvVars
1616 Height = 1815
1717 Left = 90
18- TabIndex = 10
18+ TabIndex = 7
1919 Top = 9630
2020 Width = 7530
2121 _ExtentX = 13282
@@ -54,9 +54,9 @@ Begin VB.Form Form1
5454 Begin VB.CommandButton Command1
5555 Caption = "Command1"
5656 Height = 510
57- Left = 9990
58- TabIndex = 9
59- Top = 7335
57+ Left = 12015
58+ TabIndex = 6
59+ Top = 45
6060 Width = 1230
6161 End
6262 Begin VB.TextBox txtDebug
@@ -69,28 +69,13 @@ Begin VB.Form Form1
6969 Italic = 0 'False
7070 Strikethrough = 0 'False
7171 EndProperty
72- Height = 1455
73- Left = 5445
72+ Height = 1725
73+ Left = 8595
7474 MultiLine = -1 'True
7575 ScrollBars = 3 'Both
76- TabIndex = 8
77- Top = 6660
78- Width = 4245
79- End
80- Begin VB.CommandButton cmdManual
81- Caption = "Command1"
82- Height = 375
83- Left = 12825
84- TabIndex = 7
85- Top = 6660
86- Width = 960
87- End
88- Begin VB.TextBox txtCmd
89- Height = 285
90- Left = 10620
91- TabIndex = 6
92- Top = 6705
93- Width = 1995
76+ TabIndex = 5
77+ Top = 6750
78+ Width = 5145
9479 End
9580 Begin VB.TextBox txtOut
9681 BeginProperty Font
@@ -102,13 +87,13 @@ Begin VB.Form Form1
10287 Italic = 0 'False
10388 Strikethrough = 0 'False
10489 EndProperty
105- Height = 2715
90+ Height = 2760
10691 Left = 135
10792 MultiLine = -1 'True
10893 ScrollBars = 3 'Both
10994 TabIndex = 2
11095 Top = 6750
111- Width = 5190
96+ Width = 8340
11297 End
11398 Begin SCIVB_LITE.SciSimple scivb
11499 Height = 5865
@@ -222,8 +207,8 @@ Begin VB.Form Form1
222207 Left = 180
223208 TabIndex = 3
224209 Top = 225
225- Width = 9540
226- _ExtentX = 16828
210+ Width = 3870
211+ _ExtentX = 6826
227212 _ExtentY = 556
228213 ButtonWidth = 582
229214 ButtonHeight = 556
@@ -339,7 +324,7 @@ Begin VB.Form Form1
339324 Begin MSComctlLib.ListView lvCallStack
340325 Height = 1815
341326 Left = 7695
342- TabIndex = 11
327+ TabIndex = 8
343328 Top = 9630
344329 Width = 6090
345330 _ExtentX = 10742
@@ -365,13 +350,12 @@ Begin VB.Form Form1
365350 Object .Width = 2540
366351 EndProperty
367352 End
368- Begin VB.Label Label2
369- Caption = "Cmd"
353+ Begin VB.Label lblStatus
370354 Height = 285
371- Left = 9900
372- TabIndex = 5
373- Top = 6750
374- Width = 555
355+ Left = 4230
356+ TabIndex = 9
357+ Top = 270
358+ Width = 6540
375359 End
376360 Begin VB.Label Label1
377361 Caption = "Output"
@@ -395,17 +379,18 @@ Attribute VB_PredeclaredId = True
395379Attribute VB_Exposed = False
396380Private Declare Function LoadLibrary Lib "kernel32 " Alias "LoadLibraryA " (ByVal lpLibFileName As String ) As Long
397381Private Declare Function FreeLibrary Lib "kernel32 " (ByVal hLibModule As Long ) As Long
382+ Private Declare Function GetModuleHandle Lib "kernel32 " Alias "GetModuleHandleA " (ByVal lpModuleName As String ) As Long
398383
399384
400385Private Declare Function run_script Lib "sb_engine " (ByVal lpLibFileName As String , ByVal use_debugger As Long ) As Long
401386Private Declare Sub GetErrorString Lib "sb_engine " (ByVal iErrorCode As Long , ByVal buf As String , ByVal sz As Long )
402387Private Declare Sub SetCallBacks Lib "sb_engine " (ByVal msgProc As Long , ByVal dbgCmdProc As Long )
403388
404389
405-
406390Dim loadedFile As String
407391Dim hsbLib As Long
408392Dim lastEIP As Long
393+ Public hasImports As Boolean
409394
410395Const SC_MARK_CIRCLE = 0
411396Const SC_MARK_ARROW = 2
@@ -421,6 +406,25 @@ Private Sub cmdManual_Click()
421406
422407End Sub
423408
409+ Function isExecutableLine (lineNo As Long ) As Boolean
410+ Dim tmp As String
411+ On Error Resume Next
412+
413+ tmp = LCase(scivb.GetLineText(lineNo))
414+ tmp = Trim(Replace(tmp, vbTab, Empty ))
415+ tmp = Replace(tmp, vbCr, Empty )
416+ tmp = Replace(tmp, vbLf, Empty )
417+
418+ If Len(tmp) = 0 Then GoTo fail
419+ If Left(tmp, 1 ) = "'" Then GoTo fail 'is comment
420+ If Left(tmp, 5 ) = "local" Then GoTo fail
421+ If Left(tmp, 5 ) = "const" Then GoTo fail
422+
423+ isExecutableLine = True
424+ Exit Function
425+ fail: isExecutableLine = False
426+ End Function
427+
424428Private Sub RefreshVariables ()
425429
426430 Dim li As ListItem
@@ -488,7 +492,7 @@ Private Sub scivb_KeyDown(KeyCode As Long, Shift As Long)
488492
489493 'Debug.Print KeyCode & " " & Shift
490494 Select Case KeyCode
491- Case vbKeyF2: ToggleBreakPoint scivb.CurrentLine
495+ Case vbKeyF2: If isExecutableLine(scivb.CurrentLine) Then ToggleBreakPoint scivb.CurrentLine
492496 Case vbKeyF5: If running Then DebuggerCmd "R" Else ExecuteScript True
493497 Case vbKeyF7: DebuggerCmd "s" 'step into
494498 Case vbKeyF8: DebuggerCmd "S" 'step over
@@ -532,44 +536,53 @@ End Sub
532536
533537
534538Private Sub ExecuteScript (Optional withDebugger As Boolean )
539+
535540 Dim rv As Long
536541 Dim buf As String
537-
542+
543+
538544 txtOut.Text = Empty
539545
546+ 'todo set scivb backcolor to grayed..
540547 scivb.ReadOnly = True
541548 If scivb.isDirty Then scivb.SaveFile loadedFile
542549
543550 running = True
544- Form1.sbStatus.Panels( 1 ).Text = " Running"
551+ lblStatus = IIf (withDebugger, "Debugging" , " Running")
545552
546553 rv = run_script(loadedFile, IIf (withDebugger, 1 , 0 ))
547554
548555 If rv <> 0 Then
549556 buf = String (255 , " " )
550557 Call GetErrorString (rv, buf, 255 )
551- sbStatus.Panels(1 ).Text = "Error: " & buf
552- Else
553- sbStatus.Panels(1 ).Text = "Idle"
558+ txtOut = "Error: " & buf
554559 End If
555560
561+ lblStatus = "Idle"
556562 running = False
557563 scivb.ReadOnly = False
558564 scivb.HighLightActiveLine = False
559565 scivb.DeleteMarker lastEIP, 1
566+ If hasImports Then scivb.LoadFile loadedFile
560567
561568End Sub
562569
563570Private Sub Form_Load ()
564571
565572 mnuCallStackPopup.Visible = False
566573
574+ Dim incDir As String , modDir As String
575+
567576 hsbLib = LoadLibrary(App.Path & "\engine\sb_engine.dll" )
568577
569578 If hsbLib = 0 Then
570579 MsgBox "Failed to load sb_engine.dll by explicit path?"
571580 End If
572581
582+ incDir = "D:\desktop\full_scriptbasic\scriptbasic\include\"
583+ modDir = "D:\desktop\full_scriptbasic\scriptbasic\modules\"
584+ SetConfig incDir, modDir
585+
573586 SetCallBacks AddressOf vb_stdout, AddressOf GetDebuggerCommand
574587 scivb.LoadHighlighter App.Path & "\dependancies\vb.bin"
575588
@@ -592,9 +605,9 @@ Private Sub Form_Load()
592605
593606End Sub
594607
595- Sub LoadFile (fpath As String )
608+ Sub LoadFile (fPath As String )
596609
597- loadedFile = fpath
610+ loadedFile = fPath
598611 scivb.DeleteAllMarkers
599612 scivb.LoadFile loadedFile
600613 Set breakpoints = New Collection
@@ -612,7 +625,8 @@ End Sub
612625
613626Private Sub Form_Unload (Cancel As Integer )
614627 FreeLibrary hsbLib
615- End
628+ ' FreeLibrary GetModuleHandle("scivb_lite.ocx")
629+ ' FreeLibrary GetModuleHandle("scilexer.dll")
616630End Sub
617631
618632Public Sub SyncUI ()
0 commit comments