Attribute VB_Name = "Mod1"
Option Explicit

Public Declare Sub CopyMemoryX Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal cb&)
Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long

Public Declare Function GetTickCount Lib "kernel32" () As Long

'SocketType property values
Public Const SOCK_TCP = 1  'PF_INET, SOCK_TCP, IPPROTO_TCP)
Public Const SOCK_UDP = 2  'PF_INET, SOCK_UDP, IPPROTO_UDP)
Public Const SOCK_IP = 3   'PF_INET, SOCK_UDP, IPPROTO_IP)

Public BotCount As Integer
Public BotZone() As String
Public BotIP() As String
Public BotPort() As Integer
Public BotNick() As String
Public BotPassword() As String
Public BotArena() As String
Public Bot() As New FormBot

Public NumOps As Integer
Public OpList(1 To 100) As String

Public Function FillZero(RawText As String, DesiredLength As Long) As String
    If DesiredLength <= Len(RawText) Then
        FillZero = Left(RawText, DesiredLength)
    Else
        FillZero = RawText & String(DesiredLength - Len(RawText), Chr(0))
    End If
End Function

Public Function FillX(RawText As String, DesiredLength As Long, CharX As String) As String
    If DesiredLength <= Len(RawText) Then
        FillX = Left(RawText, DesiredLength)
    Else
        FillX = RawText & String(DesiredLength - Len(RawText), CharX)
    End If
End Function

Public Function TrimZero(ByVal RawText As String) As String
    Dim L As Long
    L = InStr(RawText, Chr(0))
    If L > 0 Then
        TrimZero = Left(RawText, L - 1)
    Else
        TrimZero = RawText
    End If
End Function

Public Function StringToInt(RawText As String) As Integer
    Dim I As Integer
    Call CopyMemoryX(I, ByVal RawText, 2)
    StringToInt = I
End Function

Public Function StringToLong(RawText As String) As Long
    Dim L As Long
    Call CopyMemoryX(L, ByVal RawText, 4)
    StringToLong = L
End Function

Public Function LongToString(L As Long) As String
    Dim S4 As String
    S4 = Space(4)
    Call CopyMemoryX(ByVal S4, L, 4)
    LongToString = S4
End Function

Public Function IntToString(I As Integer) As String
    Dim S2 As String
    S2 = Space(2)
    Call CopyMemoryX(ByVal S2, I, 2)
    IntToString = S2
End Function

Public Function GetProfileString(Section As String, Key As String) As String
    Dim S As String * 255
    Dim L As Long
    L = GetPrivateProfileString(Section, Key, "", S, 255, App.Path + "\bot.ini")
    GetProfileString = Left(S, L)
End Function

Public Sub WriteProfileString(Section As String, Key As String, Value As String)
    WritePrivateProfileString Section, Key, Value, App.Path + "\bot.ini"
End Sub

