2006-12-10 16:13:50 +00:00
|
|
|
VERSION 5.00
|
|
|
|
Begin VB.Form AwkForm
|
|
|
|
Caption = "ASE COM AWK"
|
2006-12-11 08:44:52 +00:00
|
|
|
ClientHeight = 7770
|
2006-12-10 16:13:50 +00:00
|
|
|
ClientLeft = 60
|
|
|
|
ClientTop = 345
|
2006-12-11 08:44:52 +00:00
|
|
|
ClientWidth = 10335
|
2006-12-10 16:13:50 +00:00
|
|
|
LinkTopic = "AwkForm"
|
2006-12-11 08:44:52 +00:00
|
|
|
ScaleHeight = 7770
|
|
|
|
ScaleWidth = 10335
|
2006-12-10 16:13:50 +00:00
|
|
|
StartUpPosition = 3 'Windows Default
|
|
|
|
Begin VB.TextBox ConsoleIn
|
|
|
|
BeginProperty Font
|
|
|
|
Name = "Courier New"
|
|
|
|
Size = 8.25
|
|
|
|
Charset = 0
|
|
|
|
Weight = 400
|
|
|
|
Underline = 0 'False
|
|
|
|
Italic = 0 'False
|
|
|
|
Strikethrough = 0 'False
|
|
|
|
EndProperty
|
|
|
|
Height = 2895
|
2006-12-11 08:44:52 +00:00
|
|
|
Left = 120
|
2006-12-10 16:13:50 +00:00
|
|
|
MultiLine = -1 'True
|
|
|
|
TabIndex = 4
|
|
|
|
Top = 3600
|
2006-12-11 08:44:52 +00:00
|
|
|
Width = 5055
|
2006-12-10 16:13:50 +00:00
|
|
|
End
|
|
|
|
Begin VB.TextBox SourceIn
|
|
|
|
BeginProperty Font
|
|
|
|
Name = "Courier New"
|
|
|
|
Size = 8.25
|
|
|
|
Charset = 0
|
|
|
|
Weight = 400
|
|
|
|
Underline = 0 'False
|
|
|
|
Italic = 0 'False
|
|
|
|
Strikethrough = 0 'False
|
|
|
|
EndProperty
|
|
|
|
Height = 2775
|
2006-12-11 08:44:52 +00:00
|
|
|
Left = 120
|
2006-12-10 16:13:50 +00:00
|
|
|
MultiLine = -1 'True
|
|
|
|
TabIndex = 3
|
|
|
|
Top = 480
|
2006-12-11 08:44:52 +00:00
|
|
|
Width = 5055
|
2006-12-10 16:13:50 +00:00
|
|
|
End
|
|
|
|
Begin VB.TextBox SourceOut
|
|
|
|
BeginProperty Font
|
|
|
|
Name = "Courier New"
|
|
|
|
Size = 8.25
|
|
|
|
Charset = 0
|
|
|
|
Weight = 400
|
|
|
|
Underline = 0 'False
|
|
|
|
Italic = 0 'False
|
|
|
|
Strikethrough = 0 'False
|
|
|
|
EndProperty
|
|
|
|
Height = 2775
|
2006-12-11 08:44:52 +00:00
|
|
|
Left = 5280
|
2006-12-10 16:13:50 +00:00
|
|
|
MultiLine = -1 'True
|
|
|
|
TabIndex = 2
|
|
|
|
Top = 480
|
2006-12-11 08:44:52 +00:00
|
|
|
Width = 4935
|
2006-12-10 16:13:50 +00:00
|
|
|
End
|
|
|
|
Begin VB.CommandButton Execute
|
|
|
|
Caption = "Execute"
|
|
|
|
Height = 375
|
|
|
|
Left = 7080
|
|
|
|
TabIndex = 1
|
|
|
|
Top = 6840
|
|
|
|
Width = 1215
|
|
|
|
End
|
|
|
|
Begin VB.TextBox ConsoleOut
|
|
|
|
BeginProperty Font
|
|
|
|
Name = "Courier New"
|
|
|
|
Size = 8.25
|
|
|
|
Charset = 0
|
|
|
|
Weight = 400
|
|
|
|
Underline = 0 'False
|
|
|
|
Italic = 0 'False
|
|
|
|
Strikethrough = 0 'False
|
|
|
|
EndProperty
|
|
|
|
Height = 2895
|
2006-12-11 08:44:52 +00:00
|
|
|
Left = 5280
|
2006-12-10 16:13:50 +00:00
|
|
|
MultiLine = -1 'True
|
|
|
|
TabIndex = 0
|
|
|
|
Top = 3600
|
2006-12-11 08:44:52 +00:00
|
|
|
Width = 4935
|
2006-12-10 16:13:50 +00:00
|
|
|
End
|
|
|
|
End
|
|
|
|
Attribute VB_Name = "AwkForm"
|
|
|
|
Attribute VB_GlobalNameSpace = False
|
|
|
|
Attribute VB_Creatable = False
|
|
|
|
Attribute VB_PredeclaredId = True
|
|
|
|
Attribute VB_Exposed = False
|
|
|
|
Option Explicit
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Public WithEvents Awk As ASELib.Awk
|
|
|
|
Attribute Awk.VB_VarHelpID = -1
|
2006-12-10 16:13:50 +00:00
|
|
|
Private first As Boolean
|
|
|
|
|
2006-12-11 06:29:19 +00:00
|
|
|
Private extio_first As Boolean
|
|
|
|
|
2006-12-10 16:13:50 +00:00
|
|
|
Private Sub Execute_Click()
|
|
|
|
first = True
|
|
|
|
|
|
|
|
ConsoleOut.Text = ""
|
|
|
|
SourceOut.Text = ""
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Set Awk = New ASELib.Awk
|
|
|
|
Awk.Option = Awk.Option Or ASELib.AWK_SHADING Or ASELib.AWK_IDIV
|
|
|
|
|
|
|
|
If Awk.Parse() = -1 Then
|
2006-12-11 08:44:52 +00:00
|
|
|
MsgBox "PARSE ERROR OCCURRED!!!"
|
|
|
|
End If
|
2006-12-11 14:58:25 +00:00
|
|
|
If Awk.Run() = -1 Then
|
2006-12-11 08:44:52 +00:00
|
|
|
MsgBox "RUN ERROR OCCURRED!!!"
|
|
|
|
End If
|
2006-12-11 14:58:25 +00:00
|
|
|
Set Awk = Nothing
|
|
|
|
|
2006-12-10 16:13:50 +00:00
|
|
|
End Sub
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_OpenSource(ByVal mode As Long) As Long
|
|
|
|
Awk_OpenSource = 1
|
2006-12-10 16:13:50 +00:00
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_CloseSource(ByVal mode As Long) As Long
|
|
|
|
Awk_CloseSource = 0
|
2006-12-10 16:13:50 +00:00
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_ReadSource(ByVal buf As ASELib.Buffer) As Long
|
2006-12-10 16:13:50 +00:00
|
|
|
If first Then
|
|
|
|
buf.value = SourceIn.Text
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_ReadSource = Len(buf.value)
|
2006-12-10 16:13:50 +00:00
|
|
|
first = False
|
|
|
|
Else
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_ReadSource = 0
|
2006-12-10 16:13:50 +00:00
|
|
|
End If
|
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_WriteSource(ByVal buf As ASELib.Buffer) As Long
|
2006-12-10 16:13:50 +00:00
|
|
|
Dim value As String, value2 As String, c As String
|
|
|
|
Dim i As Integer, l As Integer
|
|
|
|
|
|
|
|
value = buf.value
|
|
|
|
If value = vbLf Then
|
|
|
|
SourceOut.Text = SourceOut.Text + vbCrLf
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_WriteSource = 1
|
2006-12-10 16:13:50 +00:00
|
|
|
Else
|
|
|
|
l = Len(value)
|
|
|
|
For i = 1 To l
|
|
|
|
c = Mid(value, i, 1)
|
|
|
|
If c = vbLf Then
|
|
|
|
value2 = value2 + vbCrLf
|
|
|
|
Else
|
|
|
|
value2 = value2 + c
|
|
|
|
End If
|
|
|
|
Next i
|
|
|
|
|
|
|
|
SourceOut.Text = SourceOut.Text + value2
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_WriteSource = l
|
2006-12-10 16:13:50 +00:00
|
|
|
End If
|
|
|
|
|
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_OpenExtio(ByVal extio As ASELib.AwkExtio) As Long
|
|
|
|
|
|
|
|
Dim console As AwkExtioConsole
|
|
|
|
Awk_OpenExtio = -1
|
|
|
|
|
|
|
|
Select Case extio.Type
|
|
|
|
Case ASELib.AWK_EXTIO_CONSOLE
|
|
|
|
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then
|
|
|
|
extio_first = True
|
|
|
|
extio.Handle = 1234
|
|
|
|
Awk_OpenExtio = 1
|
|
|
|
ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
|
|
|
|
extio_first = True
|
|
|
|
Set console = New AwkExtioConsole
|
|
|
|
console.Active = True
|
|
|
|
console.Count = 0
|
|
|
|
extio.Handle = console
|
|
|
|
Awk_OpenExtio = 1
|
|
|
|
End If
|
|
|
|
Case ASELib.AWK_EXTIO_FILE
|
|
|
|
Case ASELib.AWK_EXTIO_PIPE
|
|
|
|
Case ASELib.AWK_EXTIO_COPROC
|
|
|
|
End Select
|
2006-12-11 08:44:52 +00:00
|
|
|
|
2006-12-10 16:13:50 +00:00
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_CloseExtio(ByVal extio As ASELib.AwkExtio) As Long
|
|
|
|
|
|
|
|
Awk_CloseExtio = -1
|
|
|
|
|
|
|
|
Select Case extio.Type
|
|
|
|
Case ASELib.AWK_EXTIO_CONSOLE
|
|
|
|
If extio.mode = ASELib.AWK_EXTIO_CONSOLE_READ Then
|
|
|
|
Awk_CloseExtio = 0
|
|
|
|
ElseIf extio.mode = ASELib.AWK_EXTIO_CONSOLE_WRITE Then
|
|
|
|
Awk_CloseExtio = 0
|
|
|
|
End If
|
|
|
|
Case ASELib.AWK_EXTIO_FILE
|
|
|
|
Case ASELib.AWK_EXTIO_PIPE
|
|
|
|
Case ASELib.AWK_EXTIO_COPROC
|
|
|
|
End Select
|
|
|
|
|
2006-12-10 16:13:50 +00:00
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_ReadExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
|
|
|
|
Dim console As AwkExtioConsole
|
2006-12-11 08:44:52 +00:00
|
|
|
Dim value As String, value2 As String
|
|
|
|
Dim l As Integer, i As Integer
|
2006-12-11 06:29:19 +00:00
|
|
|
|
2006-12-11 08:44:52 +00:00
|
|
|
If extio.mode <> 0 Then
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_ReadExtio = -1
|
2006-12-11 08:44:52 +00:00
|
|
|
Exit Function
|
|
|
|
End If
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Let console = extio.Handle
|
|
|
|
If console.Count = 0 Then
|
2006-12-11 06:29:19 +00:00
|
|
|
value = ConsoleIn.Text
|
2006-12-11 08:44:52 +00:00
|
|
|
l = Len(value)
|
|
|
|
|
|
|
|
For i = 1 To l - 1
|
|
|
|
If Mid(value, i, 2) = vbCrLf Then
|
|
|
|
value2 = value2 + vbLf
|
|
|
|
i = i + 1
|
|
|
|
Else
|
|
|
|
value2 = value2 + Mid(value, i, 1)
|
|
|
|
End If
|
|
|
|
Next
|
|
|
|
If i = l Then
|
|
|
|
value2 = value2 + Mid(value, i, 1)
|
|
|
|
End If
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
console.Count = console.Count + 1
|
2006-12-11 08:44:52 +00:00
|
|
|
buf.value = value2
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_ReadExtio = Len(value2)
|
2006-12-11 06:29:19 +00:00
|
|
|
Else
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_ReadExtio = 0
|
2006-12-11 06:29:19 +00:00
|
|
|
End If
|
2006-12-10 16:13:50 +00:00
|
|
|
End Function
|
|
|
|
|
2006-12-11 14:58:25 +00:00
|
|
|
Function Awk_WriteExtio(ByVal extio As ASELib.AwkExtio, ByVal buf As ASELib.Buffer) As Long
|
2006-12-10 16:13:50 +00:00
|
|
|
Dim value As String, i As Long, value2 As String
|
|
|
|
|
2006-12-11 08:44:52 +00:00
|
|
|
If extio.mode <> 1 Then
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_WriteExtio = -1
|
2006-12-11 08:44:52 +00:00
|
|
|
Exit Function
|
|
|
|
End If
|
|
|
|
|
2006-12-10 16:13:50 +00:00
|
|
|
value = buf.value
|
|
|
|
|
|
|
|
'For i = 0 To 5000000
|
|
|
|
' value2 = "abc"
|
|
|
|
' buf.value = "abdkjsdfsafas"
|
|
|
|
'Next i
|
|
|
|
|
|
|
|
If value = vbLf Then
|
|
|
|
ConsoleOut.Text = ConsoleOut.Text + vbCrLf
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_WriteExtio = 1
|
2006-12-10 16:13:50 +00:00
|
|
|
Else
|
|
|
|
ConsoleOut.Text = ConsoleOut.Text + value
|
2006-12-11 14:58:25 +00:00
|
|
|
Awk_WriteExtio = Len(value)
|
2006-12-10 16:13:50 +00:00
|
|
|
End If
|
|
|
|
End Function
|
|
|
|
|
|
|
|
Private Sub Form_Load()
|
|
|
|
SourceIn.Text = "BEGIN { print 123.12; print 995; print 5432.1; }"
|
|
|
|
SourceOut.Text = ""
|
|
|
|
ConsoleIn.Text = ""
|
|
|
|
ConsoleOut.Text = ""
|
|
|
|
End Sub
|
|
|
|
|