Skip to content

Commit bae7aff

Browse files
committed
built as dll, added vbStdOut handler, added vb test project
1 parent 41b907a commit bae7aff

File tree

19 files changed

+1018
-21
lines changed

19 files changed

+1018
-21
lines changed

Form1.frm

Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
VERSION 5.00
2+
Object = "{FBE17B58-A1F0-4B91-BDBD-C9AB263AC8B0}#78.0#0"; "scivb_lite.ocx"
3+
Begin VB.Form Form1
4+
Caption = "Form1"
5+
ClientHeight = 9825
6+
ClientLeft = 60
7+
ClientTop = 345
8+
ClientWidth = 11010
9+
LinkTopic = "Form1"
10+
ScaleHeight = 9825
11+
ScaleWidth = 11010
12+
StartUpPosition = 3 'Windows Default
13+
Begin VB.TextBox txtOut
14+
BeginProperty Font
15+
Name = "Courier"
16+
Size = 9.75
17+
Charset = 0
18+
Weight = 400
19+
Underline = 0 'False
20+
Italic = 0 'False
21+
Strikethrough = 0 'False
22+
EndProperty
23+
Height = 2715
24+
Left = 135
25+
MultiLine = -1 'True
26+
ScrollBars = 3 'Both
27+
TabIndex = 4
28+
Top = 6975
29+
Width = 10590
30+
End
31+
Begin VB.CheckBox chkDebug
32+
Caption = "use debugger"
33+
Height = 285
34+
Left = 9315
35+
TabIndex = 2
36+
Top = 135
37+
Width = 1455
38+
End
39+
Begin VB.CommandButton cmdRun
40+
Caption = "Run Script"
41+
Height = 330
42+
Left = 7965
43+
TabIndex = 1
44+
Top = 135
45+
Width = 1185
46+
End
47+
Begin SCIVB_LITE.SciSimple scivb
48+
Height = 5865
49+
Left = 135
50+
TabIndex = 0
51+
Top = 585
52+
Width = 10725
53+
_ExtentX = 18918
54+
_ExtentY = 10345
55+
End
56+
Begin VB.Label Label1
57+
Caption = "Output"
58+
Height = 240
59+
Left = 90
60+
TabIndex = 3
61+
Top = 6615
62+
Width = 1860
63+
End
64+
End
65+
Attribute VB_Name = "Form1"
66+
Attribute VB_GlobalNameSpace = False
67+
Attribute VB_Creatable = False
68+
Attribute VB_PredeclaredId = True
69+
Attribute VB_Exposed = False
70+
Private Declare Function LoadLibrary Lib "kernel32" Alias "LoadLibraryA" (ByVal lpLibFileName As String) As Long
71+
Private Declare Function FreeLibrary Lib "kernel32" (ByVal hLibModule As Long) As Long
72+
73+
74+
Private Declare Function run_script Lib "sb_engine" (ByVal lpLibFileName As String, ByVal use_debugger As Long) As Long
75+
Private Declare Sub GetErrorString Lib "sb_engine" (ByVal iErrorCode As Long, ByVal buf As String, ByVal sz As Long)
76+
Private Declare Sub SetVBStdout Lib "sb_engine" (ByVal callback As Long)
77+
78+
Dim loadedFile As String
79+
Dim hsbLib As Long
80+
81+
82+
Private Sub cmdRun_Click()
83+
Dim rv As Long
84+
Dim buf As String
85+
86+
txtOut.Text = Empty
87+
SetVBStdout AddressOf vb_stdout
88+
rv = run_script(loadedFile, chkDebug.Value)
89+
90+
Me.Caption = "run_script() = " & rv & " - " & Format(Now, "m:s:ss AM/PM")
91+
92+
If rv <> 0 Then
93+
buf = String(255, " ")
94+
Call GetErrorString(rv, buf, 255)
95+
MsgBox buf
96+
End If
97+
98+
End Sub
99+
100+
Private Sub Form_Load()
101+
102+
hsbLib = LoadLibrary(App.Path & "\engine\sb_engine.dll")
103+
104+
If hsbLib = 0 Then
105+
MsgBox "Failed to load sb_engine.dll by explicit path?"
106+
End If
107+
108+
loadedFile = App.Path & "\scripts\com_voice_test.sb"
109+
scivb.LoadHighlighter App.Path & "\dependancies\vb.bin"
110+
scivb.LoadFile loadedFile
111+
112+
113+
End Sub
114+
115+
Private Sub Form_Resize()
116+
On Error Resume Next
117+
With scivb
118+
.Width = Me.Width - .Left - 200
119+
'.Height = Me.Height - .Top - 500
120+
End With
121+
End Sub
122+
123+
Private Sub Form_Unload(Cancel As Integer)
124+
FreeLibrary hsbLib
125+
End Sub

Module1.bas

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Attribute VB_Name = "Module1"
2+
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (ByRef Destination As Any, Source As Any, ByVal Length As Long)
3+
4+
5+
6+
Public Sub vb_stdout(ByVal lpMsg As Long, ByVal sz As Long)
7+
Dim b() As Byte
8+
Dim msg As String
9+
ReDim b(sz)
10+
CopyMemory b(0), ByVal lpMsg, sz
11+
msg = StrConv(b, vbUnicode)
12+
With Form1.txtOut
13+
.Text = .Text & Replace(msg, vbLf, vbCrLf)
14+
End With
15+
End Sub

dependancies/SciLexer.dll

455 KB
Binary file not shown.

dependancies/VB.bin

7.74 KB
Binary file not shown.

dependancies/scivb_lite.ocx

408 KB
Binary file not shown.

engine/dll.sln

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 10.00
3+
# Visual Studio 2008
4+
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sb_engine", "dll.vcproj", "{902EA36A-0D3C-4BED-9AEC-FB509B48AA3F}"
5+
EndProject
6+
Global
7+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8+
Debug|Win32 = Debug|Win32
9+
Release|Win32 = Release|Win32
10+
EndGlobalSection
11+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
12+
{902EA36A-0D3C-4BED-9AEC-FB509B48AA3F}.Debug|Win32.ActiveCfg = Debug|Win32
13+
{902EA36A-0D3C-4BED-9AEC-FB509B48AA3F}.Debug|Win32.Build.0 = Debug|Win32
14+
{902EA36A-0D3C-4BED-9AEC-FB509B48AA3F}.Release|Win32.ActiveCfg = Release|Win32
15+
{902EA36A-0D3C-4BED-9AEC-FB509B48AA3F}.Release|Win32.Build.0 = Release|Win32
16+
EndGlobalSection
17+
GlobalSection(SolutionProperties) = preSolution
18+
HideSolutionNode = FALSE
19+
EndGlobalSection
20+
EndGlobal

0 commit comments

Comments
 (0)