-
Notifications
You must be signed in to change notification settings - Fork 8
/
modAddressing.bas
73 lines (57 loc) · 2.53 KB
/
modAddressing.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
Attribute VB_Name = "modAddressing"
Option Explicit
Public sourcecode_length As Long
Public Function GenerateAddress(ByRef lSourceCodeLine As Long, ByRef lMetaCodeToken As Long, ByRef lMetacodePointer As Long) As String
GenerateAddress = PadZeros(lSourceCodeLine, Len(CStr(sourcecode_length))) & ":" & PadZeros(lMetaCodeToken, Len(CStr(sourcecode_length))) & ":" & PadZeros(lMetacodePointer, Len(CStr(sourcecode_length)))
End Function
Public Function PadZeros(ByRef lValue As Long, ByRef iTotalLength As Integer) As String
Dim iPadLength As Integer
Dim sPadString As String
Dim i As Integer
iPadLength = iTotalLength - Len(CStr(lValue))
For i = 1 To iPadLength
sPadString = sPadString & "0"
Next i
PadZeros = sPadString & lValue
End Function
Public Sub SelectAddressInMetaCode(ByRef sAddress As String)
Dim iListItemCount As Integer
Dim i As Integer
iListItemCount = frmMetaCode.lsvMetaCode.ListItems.Count
For i = 1 To iListItemCount
If sAddress = frmMetaCode.lsvMetaCode.ListItems(i).Text Then
frmMetaCode.lsvMetaCode.SelectedItem = frmMetaCode.lsvMetaCode.ListItems(i)
frmMetaCode.lsvMetaCode.SelectedItem.EnsureVisible
Call SelectPointerInBar(GetAddressPosition(frmMetaCode.lsvMetaCode.SelectedItem.Text))
Exit For
End If
Next i
If (frmMetaCode.Visible = True) Then
frmMetaCode.SetFocus
End If
End Sub
Public Sub SelectAddressInSourceCode(ByRef sAddress As String, ByRef sPositionUpdate As Boolean)
Dim sAddressBlocks() As String
sAddressBlocks = Split(sAddress, ":", , vbBinaryCompare)
frmSourceCode.stbStatus.Panels(4).Text = "Address: " & sAddress
frmSourceCode.txtSourceCode.SelStart = 0
frmSourceCode.txtSourceCode.SelLength = sAddressBlocks(2)
If (frmSourceCode.txtSourceCode.Visible = True) Then
frmSourceCode.txtSourceCode.SetFocus
End If
If (sPositionUpdate = True) Then
frmMain.cboPosition.Text = sAddress
End If
End Sub
Public Function SelectPointerInBar(ByRef sAddress As Long) As Boolean
Dim lLength As Long
lLength = Len(frmSourceCode.txtSourceCode.Text) + 1
If (sAddress < lLength) Then
frmMain.pbrPointer.Value = (sAddress / lLength) * 100
ElseIf (sAddress = lLength) Then
frmMain.pbrPointer.Value = 100
End If
End Function
Public Function GetAddressPosition(ByRef sAddress As String) As Long
GetAddressPosition = Val(Mid$(sAddress, InStrRev(sAddress, ":", , vbBinaryCompare) + 1))
End Function