VERSION 5.00
Begin VB.Form Form3 
   Caption         =   "Paste"
   ClientHeight    =   2805
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4590
   Icon            =   "paste.frx":0000
   LinkTopic       =   "Form3"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   2805
   ScaleWidth      =   4590
   StartUpPosition =   1  'CenterOwner
   Begin VB.OptionButton Option7 
      Caption         =   "Insert"
      Height          =   255
      Left            =   3240
      TabIndex        =   9
      Top             =   720
      Width           =   1095
   End
   Begin VB.OptionButton Option6 
      Caption         =   "Overwrite"
      Height          =   255
      Left            =   3240
      TabIndex        =   7
      Top             =   360
      Value           =   -1  'True
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Height          =   1860
      Left            =   120
      TabIndex        =   2
      Top             =   120
      Width           =   2895
      Begin VB.OptionButton Option5 
         Caption         =   "Paste to current position in file"
         Height          =   255
         Left            =   120
         TabIndex        =   8
         Top             =   1440
         Width           =   2535
      End
      Begin VB.OptionButton Option4 
         Caption         =   "Paste to beginning of file"
         Height          =   255
         Left            =   120
         TabIndex        =   6
         Top             =   1140
         Width           =   2175
      End
      Begin VB.OptionButton Option1 
         Caption         =   "Paste to current byte position"
         Height          =   255
         Left            =   120
         TabIndex        =   5
         Top             =   240
         Value           =   -1  'True
         Width           =   2535
      End
      Begin VB.OptionButton Option2 
         Caption         =   "Paste to current sector"
         Height          =   255
         Left            =   120
         TabIndex        =   4
         Top             =   540
         Width           =   2055
      End
      Begin VB.OptionButton Option3 
         Caption         =   "Paste to end of file"
         Height          =   255
         Left            =   120
         TabIndex        =   3
         Top             =   840
         Width           =   1815
      End
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Paste"
      Height          =   375
      Left            =   120
      TabIndex        =   1
      Top             =   2200
      Width           =   1335
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Cancel"
      Height          =   375
      Left            =   3120
      TabIndex        =   0
      Top             =   2200
      Width           =   1335
   End
End
Attribute VB_Name = "Form3"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim X As Integer
Dim FileNo As Integer
Dim H1 As Integer
Dim H2 As Integer
Dim Z As Long
Dim Y As Byte
Dim Y0 As Integer
Dim Y1 As Integer
Dim Y2 As Integer
Dim T1 As String * 1
Dim T2 As String * 1
Dim LS As String * 1
Dim RS As String * 1
Dim CurrentString As String

Private Sub Command1_Click()
Beep
If CopyString <> "" Then
   Rem 2-11-2008
   If Option1.Value = True Then
      If LastIndex > 0 Then
         For X = 0 To LastIndex - 1
             If Form1.Text1(X).Text <> "" Then
                CurrentString = CurrentString + Form1.Text1(X).Text
             Else
                CurrentString = CurrentString + "00"
             End If
         Next X
         CurrentString = CurrentString + CopyString
      Else
         CurrentString = CopyString
      End If
      Y0 = Len(CurrentString)
      If Y0 < 1024 Then
          If Option7.Value = True Then
             If LastIndex < 511 Then
                For X = LastIndex To 511
                    CurrentString = CurrentString + Form1.Text1(X).Text
                    Y0 = Y0 + 2
                    If Y0 > 1023 Then Exit For
                Next X
             End If
          End If
      Else
         If Y0 > 1024 Then
            CurrentString = Left$(CurrentString, 1024)
            Y0 = 1024
         End If
      End If
   Else
      If Option2.Value = True Then
         CurrentString = CopyString
         Y0 = Len(CurrentString)
         If Y0 < 1024 Then
            If Option7.Value = True Then
               For X = 0 To 511
                   CurrentString = CurrentString + Form1.Text1(X).Text
                   Y0 = Y0 + 2
                   If Y0 > 1023 Then Exit For
               Next X
            End If
         End If
      Else
         CurrentString = CopyString
      End If
   End If
   If Option1.Value = True Or Option2.Value = True Then
      X = (Len(CurrentString) / 2) - 1
      If X > 511 Then
         X = 511
      End If
      H1 = 1
      For X = 0 To X
          Form1.Text1(X).Text = Mid$(CurrentString, H1, 2)
          Form1.Text1(X).BackColor = &HAAFFFF
          Form1.Text1(X).ForeColor = 0
          Form1.Text1(X).Tag = "T"
          LS = Left$(Form1.Text1(X).Text, 1)
          RS = Right$(Form1.Text1(X).Text, 1)
          Y1 = Val(LS)
          If Y1 = 0 Then
             If LS <> "0" Then
                Y1 = (Asc(LS) - Asc("A")) + 10
             End If
          End If
          Y2 = Val(RS)
          If Y2 = 0 Then
             If RS <> "0" Then
                Y2 = (Asc(RS) - Asc("A")) + 10
             End If
          End If
          Y0 = (Y1 * 16) + Y2
          Form1.Text2(X).Text = Chr$(Y0)
          Form1.Text2(X).BackColor = &HAAFFFF
          Form1.Text2(X).ForeColor = &H808080
          H1 = H1 + 2
      Next X
   End If
   Rem 28-3-2008
   If OpenFileName = "" Then HexStrToBinary (CurrentString)
   Rem Bugs: Copy-paste is not full functional, specially for insert...
End If
Unload Form3
End Sub

Private Sub Command2_Click()
Unload Form3
End Sub

Private Sub HexStrToBinary(Str As String)
MousePointer = 11
FP = 0
FL = Len(Str)
Z = 0
GetZT1:
Z = Z + 1
T1 = Mid$(Str, Z, 1)
Y1 = Asc(T1)
If Val(T1) = 0 And T1 <> "0" Then
   If Y1 < Asc("A") Or Y1 > Asc("F") Then
      If Z < FL - 1 Then
         GoTo GetZT1
      Else
         GoTo CloseExitHFTB
      End If
   Else
      Y1 = 10 + Y1 - Asc("A")
   End If
Else
   Y1 = Y1 - Asc("0")
End If
GetZT2:
Z = Z + 1
T2 = Mid$(Str, Z, 1)
Y2 = Asc(T2)
If Val(T2) = 0 And T2 <> "0" Then
   If Y2 < Asc("A") Or Y2 > Asc("F") Then
      If Z < FL Then
         GoTo GetZT2
      Else
         GoTo CloseExitHFTB
      End If
   Else
      Y2 = 10 + Y2 - Asc("A")
   End If
Else
   Y2 = Y2 - Asc("0")
End If
Y0 = (Y1 * 16) + Y2
FP = FP + 1
Put TmpFileNo, FP, Chr$(Y0)
If Z < FL - 1 Then GoTo GetZT1
CloseExitHFTB:
FL = FP
MousePointer = 0
End Sub

Private Sub Option2_Click()
If Option6.Value = False Then
   Option6.Value = True
End If
End Sub
