Attribute VB_Name = "Module1"

' *********************************************************************
' *                                                                   *
' * Copyright (c) eMation Ltd., 1992, 2000                            *
' *                                                                   *
' * Module Name: WIZDEF.BAS                                           *
' *                                                                   *
' * This file includes all the defintions necessary for writing       *
' * WIZPRO add on programs.                                           *
' *                                                                   *
' * The file is divided into the following sections:                  *
' *                                                                   *
' * Defintions                                                        *
' *      VPI   support                                                *
' *      GATE  support                                                *
' *      ALERT support                                                *
' *      ALERT-Generator support                                      *
' *      USER  support                                                *
' *      IPC   support                                                *
' *      MSG   support                                                *
' *      FILE  support                                                *
' *      VFI   support                                                *
' *      PRINT support                                                *
' *      PATH  support                                                *
' *      LGR   support                                                *
' *      ERR   support                                                *
' *                                                                   *
' * API definitions                                                   *
' *      IPC    functions                                             *
' *      Gate   data functions                                        *
' *      VPI    functions                                             *
' *      Alert  functions                                             *
' *      User   related functions                                     *
' *      VFI    related functions                                     *
' *      Misc.  functions                                             *
' *      View   Port support                                          *
' *      Wizpro options                                               *
' *********************************************************************


' -------------------------------------------------------------------
'   VPI support definitions
' -------------------------------------------------------------------

Global Const WIZ_MAX_VPI = 32

Type WIZ_VPI_NUM
    Vpi_Num As Integer
End Type

' -------------------------------------------------------------------
'   NETWORK support definitions
' -------------------------------------------------------------------

Global Const STNPART_NAME_LEN = 16
Global Const INVALID_STN_ID = &HFFFF

Global Const HBMODE_ACTIVE = 0
Global Const HBMODE_PASSIVE = 1

Type WIZ_STN_ID
     StnId As Integer
End Type

Type WIZ_STN_NAME
     Stn_Name As String * STNPART_NAME_LEN
End Type

Type GET_STN_DEF
  StnName   As WIZ_STN_NAME   ' Station Name
  StnId     As WIZ_STN_ID     ' Station ID
  stnAddr   As String * 32    ' Station address
  ulVer     As Long           ' Version of Wizcon in remote
End Type

Type GET_STN_STATUS
  ulAttr        As Long       ' Attributes of station
  ulLastRcvTime As Long       ' Last msg from this stn time
  lastErrTime   As Long       ' Last error time
  Status        As Integer    ' Station Communication Status
  usInBufs      As Integer    ' Number of Incomming buffers
  usOtBufs      As Integer    ' Number of outgoing buffers
  usInMsgs      As Integer    ' Number of messages waiting for process
  usOtMsgs      As Integer    ' Number of messages waiting for send
End Type

' -------------------------------------------------------------------
'   GATE support
' -------------------------------------------------------------------

Global Const DEFINITION_ADDED = 1
Global Const DEFINITION_CHANGED = 2
Global Const DEFINITION_DELETED = 3
Global Const DEFINITION_DELETEALL = 4

' WizFindGateDef Flags
Global Const FF_GATENAME = 1
Global Const FF_GATEADDR = 2
Global Const FF_DESCRIPTION = 8

Global Const WIZ_GT_FLAG_COM As Integer = 1
Global Const WIZ_GT_FLAG_SAMPLE As Integer = 2

' Manipulate the GATE_ATTR.sample field
Global Const WIZ_GT_SAMPLE_ON As Integer = 4        ' enable sample
Global Const WIZ_GT_SAMPLE_PIC As Integer = 8       ' sample when in templete
Global Const WIZ_GT_SAMPLE_OFF As Integer = 16      ' disable sampling

Global Const WIZ_GT_FRMT_UNSIGNED16 = 0
Global Const WIZ_GT_FRMT_SIGNED16 = 1
Global Const WIZ_GT_FRMT_BCD = 2
Global Const WIZ_GT_FRMT_FLOAT = 3
Global Const WIZ_GT_FRMT_SIGNED32 = 4
Global Const WIZ_GT_FRMT_UNSIGNED32 = 5
Global Const WIZ_GT_FRMT_DIGITAL = 6
Global Const WIZ_GT_FRMT_STRING = 7


' WizPutGateVal posible modes ( used by Vpi() as well - same set of WGGV)
' WizPutGateValDirect posible modes ( used by Vpi() as well - same set of WGGV)

Global Const WPGV_WRITE_NOW As Integer = 1  ' sync write to PLC
Global Const WPGV_NO_WRITE  As Integer = 2  ' modify gate's memory image only - use with CARE
Global Const WPGV_WRITE_LOCKED  As Integer = 3  ' write to PLC for locked tags

' WizGetGateValue posible modes (used by Vpi() as well - same set of WPGV)

Global Const WGGV_CURRENT = 11              ' read current memory value + one sampling
Global Const WGGV_ASYNC = 12                ' like current but checks block in memory
Global Const WGGV_SYNC = 13                 ' sync. conditional block or sync gate read
                                            ' conditional block read - if block is out of sample rate freshness
                                            '  if no block associated with gate - same as sync read
Global Const WGGV_SINGLE = 14               ' forced single gate read - ignore blocks
Global Const WGGV_TIME = 15                 ' sync conditional to time block read
Global Const WGGV_CHK_CURRENT = 16          ' like CURRENT, but return WIZERR_ILL_SAMPLE if
                                            '  gate was never sampled or is in COMM_ERROR state.
Global Const WGGV_FORCE_READ = 17           ' Force reading block from hardwere

Global Const WGGV_READ_LOCKED = 18          ' Force reading locked tag from hardwere


'  Length of strings Including terminating zero

Global Const GATE_ADDRESS_LEN_OLD = 32
Global Const GATE_ADDRESS_LEN = (255 + 1)
Global Const GT_NAME_LEN = 48
Global Const GTPART_NAME_LEN = 32
Global Const GATE_DESC_LEN_OLD = 41
Global Const GATE_DESC_LEN = (255 + 1)
Global Const GATE_STRING_LEN_OLD = 81
Global Const GATE_STRING_LEN = 256

Type WIZ_GT_VAL
     GateVal As Double
End Type

Type WIZ_GT_NAME
     GateName  As String * GT_NAME_LEN
End Type

Type WIZ_GT_ADDR
     GateAddr  As String * GATE_ADDRESS_LEN
End Type

Type WIZ_TAG_ADDR
     TagAddr As WIZ_GT_ADDR
End Type

Type WIZ_GT_DESC
     GateDesc  As String * GATE_DESC_LEN
End Type

Type G
     Flags As Byte          ' & 1: 0=No error, 1=Error
                            ' & 2: sample once even if no clients, reset by sampler
                            ' & 4: gate not read yet
                            ' & 8: InMonitor
                            ' ...: not used
End Type

Type WIZ_PLC_DATA
     DataHigh As Integer
     DataLow  As Integer
     sData    As Single
     lData    As Long
End Type


Global Const WIZ_GATE_NONE As Long = 65535 ' equal &HFFFF

Global Const WIZ_TIME_LEN = 21
Type WIZ_TIME_VAL
    Wiz_Time As String * WIZ_TIME_LEN
End Type

'************************************************************************
'   Gate defintion
'************************************************************************

Global Const DDE_DESC_LEN = 20

Type WIZ_GROUP
     Group As Long
End Type

Global Const GATESRC_PLC = 1
Global Const GATESRC_DUMMY = 2
Global Const GATESRC_COMPOUND = 3
Global Const GATESRC_SYSTEM = 4

Global Const GATEREC_UPDATE     As Integer = -2
Global Const GATEREC_CHANGE     As Integer = -1
Global Const GATEREC_NEVER      As Integer = 0

Global Const GATESMP_NEVER = 0
Global Const GATESMP_MONITOR = 1
Global Const GATESMP_ALWAYS = 2

Global Const DDETYPE_NONE   As Integer = 0
Global Const DDETYPE_SINGLE As Integer = 1
Global Const DDETYPE_BLOCK  As Integer = 2

Global Const UPDATEMODE_INMONITOR = 0
Global Const UPDATEMODE_ALWAYS = 1

Type WIZ_GT_DEF
     Name    As String * GT_NAME_LEN    ' Gate name
     Desc    As String * GATE_DESC_LEN_OLD  ' Gate description string
     Groups  As Long                    ' Autorization group
     Record         As Long             ' -1=changes, 0=never, >0=record_rate
     DdeType        As Byte
     DdeUpdateMode  As Byte
     OwnerData      As Integer          ' Used by the adder of the gate
     SourceType     As Byte             ' PLC / DUMMY / COMPOUND
     UpdateMode     As Byte
     FormatType     As Integer          ' WIZ_GT_FRMT_xxxxx
     ' DDE
        ' single
     Application    As String * DDE_DESC_LEN
     Topic          As String * DDE_DESC_LEN
     Item           As String * DDE_DESC_LEN
        ' block
     BlockName      As String * DDE_DESC_LEN
     Row            As Integer
     Column         As Integer
     ' SOURCE
        ' plc
     VPI            As Long                         ' VPI number
     Address        As String * GATE_ADDRESS_LEN_OLD    ' Gate address string
     Sample         As Long                         ' Never / Allways / In monitor
     SampleRate     As Long                         ' Sample rate in mili sec.
        ' compound
     Const1         As Single
     Const2         As Single
     Gate1Name      As String * GT_NAME_LEN
     Gate2Name      As String * GT_NAME_LEN
     Operator       As Byte
     ' FORMAT
        ' analog
     x1             As Double       ' linear conversion
     x2             As Double       '
     y1             As Double       '
     y2             As Double       '
     lolo           As Double       ' limits
     hihi           As Double       '
     Tolerance      As Long         ' Diffrence between old and new before accepting the new
        ' digital
     Filter         As Long         ' Time before realize new value.
        ' string
     Length         As Long         ' Number of chars in string
End Type


' -------------------------------------------------------------------
'   New structure of tag definition for Wizcon version 8.0
' -------------------------------------------------------------------
   
Global Const TagAtt_IsDeleted        As Integer = 1      ' means tag was deleted
Global Const TagAtt_ReadOnly         As Integer = 2      ' means Read-only tag
Global Const TagAtt_WriteToODBC      As Integer = 4      ' means write changes to odbc
Global Const TagAtt_HBLocaltag       As Integer = 8      ' means Local tag on master backup
Global Const TagAtt_IsLocked         As Integer = 16     ' if this attribute is 1 - online tag state is locked
Global Const TagAtt_IsLockDefined    As Integer = 32     ' if this attribute is 1 - lock data was defined, we should try to lock this tag when tag definition will added
Global Const TagAtt_Replay           As Integer = 64     ' 1 means tag for replay module
Global Const TagAtt_TagMapper        As Integer = 128    '1 means tag for tag mapper
Global Const TagAtt_InhibitAlarm     As Integer = 256    '1 means tag is used for inhibit alarm
Global Const TagAtt_InhibitLevel     As Integer = 512    '1 means tag is used for inhibit level

Type WIZ_TAG_ATT
     TagAtt      As Long
End Type

Type WIZ_TAG_ATT_SHORT
     TagAttShort      As Integer
End Type

' lock tag feature
Type WIZ_TAG_LOCK_VAL
   GateValue    As WIZ_GT_VAL               ' value that will be set when tag in the locked state
   StringValue  As String * GATE_STRING_LEN ' value that will be set for string gates
End Type

Type WIZ_TAG_LOCK_DATA
   GateValue    As WIZ_GT_VAL               ' value that will be set when tag in the locked state
   StringValue  As String * GATE_STRING_LEN ' value that will be set for string gates
   StatusGateName   As WIZ_GT_NAME       ' name of digital tag that shows status locked or unlocked
   TimeUnlock       As WIZ_TIME_VAL      ' time value in milliseconds when tag must be unlocked
End Type

' Tag related alarms
Global Const LOW_ALARM = 0
Global Const LOWLOW_ALARM = 1
Global Const HIGH_ALARM = 2
Global Const HIGHHIGH_ALARM = 3
Global Const RATECHANGE_ALARM = 4
Global Const DEVIATION_ALARM = 5

Global Const RELATED_ALARM_COUNT = 6

Type WIZ_ALERT_DEF_ID
     AlertDefID As Long
End Type

Type WIZ_TAG_ALARM
   LowAlarm As WIZ_ALERT_DEF_ID
   LoLoAlarm As WIZ_ALERT_DEF_ID
   HighAlarm As WIZ_ALERT_DEF_ID
   HihiAlarm As WIZ_ALERT_DEF_ID
   RocAlarm As WIZ_ALERT_DEF_ID
   DevAlarm As WIZ_ALERT_DEF_ID
End Type

' -------------------------------------------------------------------
'                 TAG DEFINITION                                  */
' -------------------------------------------------------------------
Type WIZ_TAG_DEF
     Size    As Integer                 ' size of this structure , must be filled with sizeof(WIZ_TAG_DEF) before using in API's
     Name    As String * GT_NAME_LEN    ' Tag name
     Desc    As String * GATE_DESC_LEN  ' Tag description string
     Groups  As Long                    ' Autorization group
     Record         As Long             ' -1=changes, 0=never, >0=record_rate
     DdeType        As Byte
     DdeUpdateMode  As Byte
     OwnerData      As Integer          ' Used by the adder of the gate
     SourceType     As Byte             ' PLC / DUMMY / COMPOUND
     UpdateMode     As Byte
     FormatType     As Integer          ' WIZ_GT_FRMT_xxxxx
     ' DDE
        ' single
     Application    As String * DDE_DESC_LEN
     Topic          As String * DDE_DESC_LEN
     Item           As String * DDE_DESC_LEN
        ' block
     BlockName      As String * DDE_DESC_LEN
     Row            As Integer
     Column         As Integer

     ' SOURCE
        ' plc
     VPI            As Byte                         ' VPI number
     Address        As String * GATE_ADDRESS_LEN    ' Gate address string
     Sample         As Byte                         ' Never / Allways / In monitor
     SampleRate     As Long                         ' Sample rate in mili sec.
        ' compound
     Const1         As Single
     Const2         As Single
     Gate1Name      As String * GT_NAME_LEN
     Gate2Name      As String * GT_NAME_LEN
     Operator       As Byte
     ' FORMAT
        ' analog
     x1             As Double       ' linear conversion
     x2             As Double       '
     y1             As Double       '
     y2             As Double       '
     lolo           As Double       ' limits
     hihi           As Double       '
     Tolerance      As Long         ' Diffrence between old and new before accepting the new
        ' digital
     Filter         As Long         ' Time before realize new value.

        ' string
     Length         As Integer      ' Number of chars in string

     SID            As Long         ' string id
     TagAttribute   As WIZ_TAG_ATT  ' attributes of tag
     LockData       As WIZ_TAG_LOCK_DATA   ' data for locking
     TagAlarms      As WIZ_TAG_ALARM
End Type

Type WIZ_TAG_DEF_SHORT
     Size    As Integer                 ' size of this structure
     Name    As String * GT_NAME_LEN    ' Gate name
     Desc    As String * GATE_DESC_LEN  ' Gate description string
     FormatType     As Integer          ' WIZ_GT_FRMT_xxxxx
     LastValue      As WIZ_TAG_LOCK_VAL
     LockValue      As WIZ_TAG_LOCK_VAL
     TimeUnlock     As WIZ_TIME_VAL
     TagAddress     As WIZ_TAG_ADDR
     VpiNumber      As WIZ_VPI_NUM
     FlagLocked     As Byte
End Type

' -------------------------------------------------------------------
'   FILE support
' -------------------------------------------------------------------

Global Const PATH_LEN   As Integer = 256    ' max length of full path name
Global Const SUFIX_LEN  As Integer = 4      ' max file sufix length
Global Const FILE_LEN   As Integer = 9      ' max file name len

Type WIZ_FILE_NAME
    FileName As String * FILE_LEN
End Type


' -------------------------------------------------------------------
'   ALERT support
' -------------------------------------------------------------------

' Length of strings Including terminating zero
Global Const WIZ_ALERT_IDEN_LEN = 8
Global Const MACRO_NAME_LEN = (255 + 1)
Global Const WIZ_MACRO_CRC_STRING_LEN = 9
Global Const WIZ_ALERT_NAME_LEN = (64 + 1)
Global Const WIZ_ALERT_NAME_LEN_OLD = 16
Global Const WIZ_ALERT_TEXT_LEN = (253 + 1)
Global Const WIZ_ALERT_TEXT_LEN_OLD = 61
Global Const ALERT_INFOFILE_LEN = 12
Global Const ALERT_ACKID_LEN_OLD = 16
Global Const ALERT_ACKID_LEN = 21
Global Const WIZ_ALERT_EXPR_LEN = 255 + 1
Global Const ALARM_STATE_NAME_LEN = 21

' Wiz5FindAlertDef API flags
Global Const FF_ALERTNAME = 2
Global Const FF_TEXT = 4

' flags for advanced search
Global Const FF_ALARMFAMILY = 2
Global Const FF_ALARMTEXT = 4
Global Const FF_ALARMZONE = 8
Global Const FF_ALARMSEVERITY = 16
Global Const FF_ALARMEXPRESSION = 32

Type WIZ_ALERT_ID
     Id     As Long
End Type


' Cause in alert msg and statuses for WizStampAlert()

Global Const WIZ_START_ALERT    As Integer = 1
Global Const WIZ_ACK_ALERT      As Integer = 2
Global Const WIZ_END_ALERT      As Integer = 4
Global Const WIZ_TEXT_ALERT     As Integer = 8
Global Const WIZ_OPEN_ALERT     As Integer = 16     ' after WizRqAlert()
Global Const WIZ_CANCELED_ALERT As Integer = 32     ' Remote alert canceled due to remote node (re)boot
Global Const WIZ_RESTART_ALERT  As Integer = 64     ' Restart collapse alert
Global Const WIZ_ALARM_STATE_0  As Integer = 128
Global Const WIZ_ALARM_STATE_1  As Integer = 256

' Comno values
Global Const INVALID_ALERT_COMNO As Integer = &HFFFF

'  Event types

Global Const ALARM_EVENT    As Integer = 1      ' Produced by WIL or LRM from PRINT$[A-G]
Global Const BATCH_EVENT    As Integer = 2      ' In LIV when using F4-BATCH
Global Const TEXT_EVENT     As Integer = 4      ' info & error messages
Global Const LOGIN_EVENT    As Integer = 8      ' when user logs in F10
Global Const RECIPE_EVENT   As Integer = 16     ' recipe info message
Global Const COMERR_EVENT   As Integer = 32     ' communication errors
Global Const DISKFULL_EVENT As Integer = 64     ' disk full alarm
Global Const PLUG_EVENT     As Integer = 128
Global Const WIZCON2_EVENT  As Integer = &H8000 ' OS/2 extension fields are valid

' Class definitions

Global Const ALERT_USER_CLASS   As Integer = &HFFFF    ' 16 bits for user defined classes
Global Const ALERT_POP_UP_BUZZ  As Long = &H10000       ' popup & buzz alert
Global Const WIZPRO_CLASS       As Long = &H80000       ' Wizpro startup
Global Const WZ2_ALERT_CLASS    As Long = &H100000      ' Wizcon/2 alert processor
Global Const ALERT_PRINTER_BUSY As Long = &H200000      ' wait to send to printer
Global Const ALARM_CLASS        As Long = &H400000      ' produced by WIL or LRM from PRINT$[A-G]
Global Const BATCH_CLASS        As Long = &H800000      ' in LIV when using F4-BATCH
Global Const BACKUP_CLASS       As Long = &H800000      ' backup station switch
Global Const TEXT_CLASS         As Long = &H1000000     ' info & error messages
Global Const LOGIN_CLASS        As Long = &H2000000     ' when user logs in F10
Global Const RECIPE_CLASS       As Long = &H4000000     ' recipe info message
Global Const COMERR_CLASS       As Long = &H8000000     ' communication errors
Global Const DISKFULL_CLASS     As Long = &H10000000    ' disk full alarm
Global Const ALERT_POP_UP       As Long = &H20000000    ' display popup message
Global Const ALERT_ANNUNCIATOR  As Long = &H40000000    ' display in annunciator
Global Const ALERT_PRINTER      As Long = &H80000000    ' send to printer

' communication alert definitions

Type WIZ_ALERT_NAME
    Alert_Name As String * WIZ_ALERT_NAME_LEN
End Type


' WIZ_ALERT_ATT type of the alert attribute

Global Const Att_Discard    As Integer = 1      ' don't restore alert after system restart
Global Const Att_AutoAck    As Integer = 2      ' dosn't require operator acknowlage
Global Const Att_AutoTerm   As Integer = 4      ' terminate on start - only wait ACK
Global Const Att_HelpFile   As Integer = 8      ' InfoFile is for standard help
Global Const Att_History    As Integer = 16     ' write to history file (LRMmm-dd.dat)
Global Const Att_System     As Integer = 32     ' system wide alert - dispatched over network
Global Const Att_AckClass   As Integer = 64     ' Let user define class when acknowlaging
Global Const Att_Remote     As Integer = 128    ' started at a remote node, used only by RCS
Global Const Att_LclChg     As Integer = 256    ' Local alert manipulation
Global Const Att_Acked      As Integer = 512    ' acknolaged alert
Global Const Att_Ended      As Integer = 1024   ' terminated alert
Global Const Att_InUse      As Integer = 2048   ' Alert data is valid
Global Const Att_Canceled   As Integer = 4096   ' Alert was canceled due to remote node (re)boot
Global Const Att_Deleted    As Integer = 8192   '
Global Const Att_ForceEnd   As Long = 16384    ' Alarm was ended by user "force end"
Global Const Att_Inhibit    As Long = 32768      ' 1 = alarm is inhibited

Type WIZ_ALERT_ATT
     Att      As Integer    ' & Att_Discard: 1 = don't restore alert after system restart
End Type
  
Global Const Att2_StartAction    As Integer = 1      ' exists action on start, NameStartMacro in WIZ_ALERT2 not empty
Global Const Att2_AckAction      As Integer = 2      ' 1 = exists action on ack, NameAckMacro in WIZ_ALERT2 not empty
Global Const Att2_EndAction      As Integer = 4      ' 1 = exists action on end, NameEndMacro in WIZ_ALERT2 not empty
Global Const Att2_TagRelated     As Integer = 8      ' 1 = Tag-related alarm defined in tag definition
Global Const Att2_DelayType      As Integer = 16     ' 0 = each time when condition false, 1 = at the end
Global Const Att2_ExcludePrint   As Integer = 32     ' 1 = don't print this alarm
Global Const Att2_PrintHelp      As Integer = 64     ' 1 = print AHP file after alarm
Global Const Att2_State0         As Integer = 128    ' 1 = alarm in state_0
Global Const Att2_State1         As Integer = 256    ' 1 = alarm in state_1

Type WIZ_ALERT_ATT2
     Att      As Long    ' additional alert attribute structure
End Type

' WIZ_ALERT_TIME  type of the alert time
Type WIZ_ALERT_TIME
     SecondsSince1970 As Long    ' seconds since 1970
     MiliSeconds      As Integer ' miliseconds
     Reserved         As Integer
End Type


' WIZ_ALERT  type of the alert

Type WIZ_ALERT
     StnName    As String * STNPART_NAME_LEN
     Start      As WIZ_ALERT_TIME   ' start time
     End        As WIZ_ALERT_TIME   ' End Time
     Ack        As WIZ_ALERT_TIME   ' Ack Time
     Att        As WIZ_ALERT_ATT    ' see WIZ_ALERT_ATT definition above
     Class      As Long             ' (bitmap) type of alert
     ComNo      As Long
     AlertEvent As Integer
     Severity   As Integer          ' (numerator) for filtering and sorting
     Zone       As Integer          ' (numerator) additional sorting and filtering
     Family     As String * WIZ_ALERT_NAME_LEN_OLD
     AlertText  As String * WIZ_ALERT_TEXT_LEN_OLD  ' text for displaying/printing
     AckId      As String * ALERT_ACKID_LEN_OLD     ' some id of the acknowlaging user/program
     InfoFile   As String * ALERT_INFOFILE_LEN  ' where to retrieve additional info

End Type

' ----------------------------------------------------------------
'   Alert defintion
' ----------------------------------------------------------------


Type WIZ_ALERT_LEVEL_ID
     AlertLevelID As Long
End Type


Type WIZ_MACRO_NAME
     Name   As String * MACRO_NAME_LEN
End Type

Global Const IMG_STR_LEN = 64

Type WIZ_ALERT_DEF
     GateName   As String * GT_NAME_LEN
     Family     As String * WIZ_ALERT_NAME_LEN_OLD
     Condition  As Byte         ' one of the IOP_xxx constants above
     Value      As Double       ' the constant value for the condition
     Severity   As Integer      ' of alert to generate
     Class      As Long         ' of alert to generate.
     Zone       As Integer      ' of alert to generate
     Attr       As Integer      ' of alert to generate
     InfoFile   As String * 9   ' ditto
     AlertText       As String * 61  ' ditto.
End Type

Type WIZ_ALERT2
    nLength        As Long                ' Size, in bytes, of this structure
    AttrEx         As Long                ' Additionsl alert attribute
    NameStartMacro As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert start
    NameAckMacro   As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert acknowledge
    NameEndMacro   As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert end
    SID            As Long                ' String Id
End Type

Global Const WIZ_ALERT_DEF_EXP_LEN_OLD = 148

Type WIZ_ALERT_DEF_EXP_OLD
    nLength        As Long                ' Size, in bytes, of this structure
  
    Family     As String * WIZ_ALERT_NAME_LEN_OLD
    Severity   As Integer      ' of alert to generate
    Class      As Long         ' of alert to generate.
    Zone       As Integer      ' of alert to generate
    Attr       As Integer      ' of alert to generate
    InfoFile   As String * 9   ' ditto
    AlertText  As String * WIZ_ALERT_TEXT_LEN_OLD
   

    AttrEx         As WIZ_ALERT_ATT2      ' Additionsl alert attribute
    NameStartMacro As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert start
    NameAckMacro   As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert acknowledge
    NameEndMacro   As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert end
    SID            As Long                ' String Id

    ExpLength As Long                     ' Expression length
    Groups    As WIZ_GROUP                ' Authorization

End Type

Type WIZ_AAM_DATA
    Groups       As WIZ_GROUP
    File         As String * PATH_LEN
    VoiceFile    As String * PATH_LEN
    Synthesized  As Byte
End Type

Global Const WIZ_ALARM_USER_FIELD_LEN = 33
Global Const WIZ_ALARM_USER_FIELD_COUNT = 5

Type WIZ_ALARM_USER_FIELD
     Name   As String * WIZ_ALARM_USER_FIELD_LEN
End Type

Type WIZ_ALARM_USER_FIELD_LIST
     Field0   As String * WIZ_ALARM_USER_FIELD_LEN
     Field1   As String * WIZ_ALARM_USER_FIELD_LEN
     Field2   As String * WIZ_ALARM_USER_FIELD_LEN
     Field3   As String * WIZ_ALARM_USER_FIELD_LEN
     Field4   As String * WIZ_ALARM_USER_FIELD_LEN
End Type


Type WIZ_ALERT_DEF_EXP
    nLength        As Long                ' Size, in bytes, of this structure
  
    Family     As String * WIZ_ALERT_NAME_LEN
    Severity   As Integer      ' of alert to generate
    Class      As Long         ' of alert to generate.
    Zone       As Integer      ' of alert to generate
    Attr       As Integer      ' of alert to generate
    InfoFile   As String * 9   ' ditto
    AlertText  As String * WIZ_ALERT_TEXT_LEN
   

    AttrEx         As WIZ_ALERT_ATT2      ' Additionsl alert attribute
    NameStartMacro As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert start
    NameAckMacro   As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert acknowledge
    NameEndMacro   As String * WIZ_MACRO_CRC_STRING_LEN      ' Macro to run on alert end
    SID            As Long                ' String Id

    ExpLength      As Long                ' Expression length
    Groups         As WIZ_GROUP           ' Authorization
    DelayTime      As Long                ' 0 - no delay
    LevelIndex     As WIZ_ALERT_LEVEL_ID
    RelatedTagId   As Long
    ImageName      As String * IMG_STR_LEN
    ZoneName       As String * IMG_STR_LEN
    AamData        As WIZ_AAM_DATA
    UserFieldList  As WIZ_ALARM_USER_FIELD_LIST

End Type


'  -------------------------------------------------------------------
'  ALERT-Generator support
'  -------------------------------------------------------------------

Global Const IOP_ERR = 0
Global Const IOP_GT = 1         ' gate > value
Global Const IOP_EQ = 2         ' gate = value
Global Const IOP_LT = 3         ' gate < value
Global Const IOP_GE = 4         ' gate >= value
Global Const IOP_LE = 5         ' gate <= value
Global Const IOP_NE = 6         ' gate != value
Global Const IOP_BIT0 = 100     ' gate bit 0 set
Global Const IOP_BIT31 = 131    ' gate bit 31 set

' ------------------------------------------------------------------
'  USER support
' ------------------------------------------------------------------

Global Const MAX_USER_SIZE = 21
Global Const MAX_PASSWORD_SIZE = 21
Global Const MAX_USER_NAME_SIZE = 256
Global Const MAX_GROUP_NAME_SIZE = 256
Global Const MAX_GROUP_BUF = MAX_GROUP_NAME_SIZE * 100

' -------------------------------------------------------------------
'  IPC support
' -------------------------------------------------------------------

Global Const WIZ_MAX_CLIENTS As Integer = 255

' WizRqGateMsg & WizRqAlert Change values

Global Const WIZ_ADD_CLIENT         As Integer = 1
Global Const WIZ_REMOVE_CLIENT      As Integer = 2
Global Const WIZ_ADD_CLIENT_UPDATE  As Integer = 5

' WizRqGateMsg only
Global Const WIZ_ADD_CLIENT_NO_DATA             As Integer = 17
Global Const WIZ_ADD_CLIENT_NO_SAMPLE           As Integer = 9  ' (WIZ_ADD_CLIENT | 0x8)

Global Const WIZ_ADD_CLIENT_NO_SAMPLE_UPDATE    As Integer = 13 ' (WIZ_ADD_CLIENT | 0x8 | 0x04)
Global Const WIZ_ADD_CLIENT_UPDATE_NO_DATA      As Integer = 21 ' (WIZ_ADD_CLIENT | 0x14)
Global Const WIZ_CHANGE_CLIENT                  As Integer = 3  ' (WIZ_ADD_CLIENT | WIZ_REMOVE_CLIENT)
Global Const WIZ_DEFINITION_CLIENT              As Integer = 32 ' 0x20
Global Const WIZ_MONITOR_CLIENT                 As Integer = 64 ' 0x40

Global Const WIZ_CLIENT As Integer = 1      ' &H1
Global Const WIZ_PM_CLIENT As Integer = 2   ' &H2

' *-------------------------------------------------------------------*
' *  Network MSG support                                              *
' *-------------------------------------------------------------------*
' WizNetMsg
Global Const STN_UP = 1
Global Const STN_RESTARTED = 2
Global Const STN_DOWN = 3
Global Const STN_ERROR = 4
Global Const STN_RESTORED = 5

' *-------------------------------------------------------------------*
' *  MSG support                                                      *
' *-------------------------------------------------------------------*

Type WIZ_MSG_TYPE
    MSG_Type As Integer
End Type

'  Message type definitions - return by WizGetMsg

Global Const WIZ_SIGNAL_SHUT    As Integer = 0  ' signals to exit
Global Const WIZ_GATE_VAL       As Integer = 1  ' gate value message
Global Const WIZ_GATE_STR       As Integer = 2  '
Global Const WIZ_GATE_FLAG      As Integer = 3  ' gate flag message
Global Const WIZ_GENERAL        As Integer = 7  ' general purpose message
Global Const WIZ_ALERT_MSG      As Integer = 8  ' Alert notification message
Global Const WIZ_ALERT_LAST_MSG As Integer = 9  ' after this message AlertId is not valid
Global Const WIZ_ALERT_END_OPEN As Integer = 10 ' end of open alert messages after WizRqAlert
Global Const WIZ_LOST_MSG       As Integer = 11 ' memory problem - you lost some messages
Global Const WIZ_NEW_GROUP      As Integer = 13 ' user group changed
Global Const WIZ_ALERT_NEW_OPEN As Integer = 14 ' start of open alert messages after WIZ_CNG_CLIENT
Global Const WIZ_ALERT_UNACK    As Integer = 15 ' new unackcount. used for _WIZ2 message.
Global Const WIZ_NET_MSG        As Integer = 16 ' New station is up or a staion is down
Global Const WIZ_GATE_DEF_MSG   As Integer = 121
Global Const WIZ_ALERT_DEF_MSG  As Integer = 122

                                                  '  100 - 999 are wizcon internal IPC messages
Global Const WIZ_USER_MSG       As Integer = 1000 ' and up are user defined messages

Type WIZ_ARG_GATE_STR
     Id         As Long
     ulSeconds  As Long         ' seconds since 1970
     usMiliseconds As Integer   ' miliseconds
     Att        As WIZ_TAG_ATT_SHORT
End Type


Type WIZ_ARG_GATE_VAL
     Id         As Long
     ulSeconds  As Long         ' seconds since 1970
     usMiliseconds As Integer   ' miliseconds
     GateVal    As Double
     Att        As WIZ_TAG_ATT_SHORT
End Type


Type WIZ_ARG_NET
     StnId      As Integer
     Cause      As Integer
     StnIdx     As Integer
End Type


Type WIZ_ARG_GATE_FLAG
     Id         As Long
     ulSeconds  As Long         ' seconds since 1970
     usMiliseconds As Integer   ' miliseconds
     Flag          As Byte
     Att           As WIZ_TAG_ATT_SHORT
End Type


Type WIZ_ARG_GATE_DEF_MSG
     Id         As Long
     ulSeconds  As Long         ' seconds since 1970
     usMiliseconds As Integer   ' miliseconds
     Cause         As Integer   ' the event that caused the msg
     Att           As WIZ_TAG_ATT_SHORT
End Type

Type WIZ_ARG_ALERT
     AlertId    As Long
     Cause      As Integer
     UnAckedCnt As Integer
     Att        As WIZ_ALERT_ATT
     StnId      As WIZ_STN_ID        ' station id on which alarm was started*/
     AttrEx     As WIZ_ALERT_ATT2
     ClientData As Long              ' data for client of alarm server */
End Type


Type WIZ_ARG_LOST
     cnt As Integer             ' number of lost messages
End Type


Global Const MESSAGE_LENGTH As Integer = 62

Type WIZ_MSG_Internal
     Type As Integer
     Data As String * MESSAGE_LENGTH
End Type

Type WizAlertMsg
     AlertId    As Long
     Cause      As Integer
     UnAckedCnt As Integer
     Att        As Integer
     StnId      As WIZ_STN_ID        ' station id on which alarm was started*/
     AttrEx     As WIZ_ALERT_ATT2
     ClientData As Long              ' data for client of alarm server */
End Type

Type WizGateDefMsg
     GateID       As Long
     Seconds      As Long
     MilliSeconds As Integer
     Cause        As Integer
     Att          As WIZ_TAG_ATT_SHORT
End Type

Type WizGateFlagMsg
     GateID       As Long
     Seconds      As Long
     MilliSeconds As Integer
     Flag         As Byte
     Att          As WIZ_TAG_ATT_SHORT
End Type

Type WizGateValMsg
     GateID       As Long
     Seconds      As Long
     MilliSeconds As Integer
     Value        As Double
     Att          As WIZ_TAG_ATT_SHORT
End Type

Type WizNetMsg
     StnId        As Integer
     Cause        As Integer
     StnIdx       As Integer
End Type

Type WizGateStrMsg
     GateID       As Long
     Seconds      As Long
     MilliSeconds As Integer
     Att          As WIZ_TAG_ATT_SHORT
End Type

Type WizLostMsg
     Count  As Integer
End Type

Type WizNewGroupMsg
     Group  As Long
End Type


' -------------------------------------------------------------------
'   VFI support
' -------------------------------------------------------------------

' WizFileXxxxx* API definitions

' File types
Global Const VFI_TYPE_HIS = 0
Global Const VFI_TYPE_LRM = 1

' Open flags
Global Const VFI_OPEN_READ = 1
Global Const VFI_OPEN_WRITE = 2
Global Const VFI_OPEN_FILTER = 4
Global Const VFI_OPEN_SQL = 8
Global Const VFI_OPEN_LOCAL = 16

' Filter option for alarm
Global Const LF_OR = 1
Global Const LF_AND = 2
Global Const LF_ORCLASS = 4
Global Const LF_ANDCLASS = 8
Global Const LF_ORATTR = 16
Global Const LF_ANDATTR = 32

' Filter option for gates
Global Const LF_PREV = 1
Global Const LF_NEXT = 2

Global Const LF_CHANGE_INDEX_ONLY = 16

' WIZ_VFI_FILE - file information for VFI

Type HVfi
     HVfi As Long
End Type

Type VFI_HIS_OLD
     GateID             As Long
     SecondsSince1970   As Long
     MilliSeconds       As Integer
     Flags              As Integer
     DoubleValue        As Double
     StringValue        As String * GATE_STRING_LEN_OLD
End Type
     
Type VFI_HIS
     GateID             As Long
     SecondsSince1970   As Long
     MilliSeconds       As Integer
     Flags              As Integer
     DoubleValue        As Double
     StringValue        As String * GATE_STRING_LEN
End Type
     
Type VFI_LRM_OLD
     StationId          As Integer
     StartTime          As Long     ' Seconds since 1970
     StartMilli         As Integer  ' Milliseconds
     EndTime            As Long     ' Seconds since 1970
     EndMilli           As Integer  ' Miliseconds
     AckTime            As Long     ' Seconds since 1970
     User               As String * ALERT_ACKID_LEN_OLD ' Who ACK the alert
     ' The following items are taken from the alert def.
     Severity           As Long      'Integer
     Class              As Long
     Zone               As Long      'Integer
     Attr               As Long
     Identity           As String * WIZ_ALERT_IDEN_LEN
     Name               As String * WIZ_ALERT_NAME_LEN_OLD
     AlertText          As String * WIZ_ALERT_TEXT_LEN_OLD
     ComNo              As Long
End Type

Global Const ALARM_FULL_PATH_LEN  As Integer = 254
Global Const UUID_STR_LEN  As Integer = 37

Type UUID_STR
    Str As String * UUID_STR_LEN
End Type

Type VFI_LRM
     Version            As Integer
     StationId          As Integer
     StartTime          As Long     ' Seconds since 1970
     StartMilli         As Integer  ' Milliseconds
     EndTime            As Long     ' Seconds since 1970
     EndMilli           As Integer  ' Miliseconds
     AckTime            As Long     ' Seconds since 1970
     User               As String * ALERT_ACKID_LEN ' Who ACK the alert
     ' The following items are taken from the alert def.
     Severity           As Long
     Class              As Long
     Zone               As Long
     Attr               As Long
     Identity           As String * WIZ_ALERT_IDEN_LEN
     Name               As String * WIZ_ALERT_NAME_LEN
     AlertText          As String * WIZ_ALERT_TEXT_LEN
     ComNo              As Long
     CommentId          As String * UUID_STR_LEN        'Id of comment
     Path               As String * ALARM_FULL_PATH_LEN ' Alarm hierarchy full path
     TimeStampState0    As Long
     UserNameState0     As String * ALERT_ACKID_LEN
     TimeStampState1    As Long
     UserNameState1     As String * ALERT_ACKID_LEN
     UserFieldList      As WIZ_ALARM_USER_FIELD_LIST
End Type

Global Const WIZ_INTEGER_SIZE   As Integer = 6
Global Const WIZ_LONG_SIZE      As Integer = 11
Global Const WIZ_DOUBLE_SIZE    As Integer = 310

Global Const VFI_LRM_LEN_OLD   As Integer = WIZ_INTEGER_SIZE + _
       WIZ_LONG_SIZE + WIZ_INTEGER_SIZE + WIZ_LONG_SIZE + _
       WIZ_INTEGER_SIZE + WIZ_LONG_SIZE + ALERT_ACKID_LEN + _
       WIZ_LONG_SIZE + WIZ_LONG_SIZE + WIZ_LONG_SIZE + _
       WIZ_LONG_SIZE + WIZ_ALERT_IDEN_LEN + WIZ_ALERT_NAME_LEN + _
       WIZ_ALERT_TEXT_LEN + WIZ_LONG_SIZE

Global Const VFI_LRM_LEN   As Integer = WIZ_INTEGER_SIZE + WIZ_INTEGER_SIZE + _
       WIZ_LONG_SIZE + WIZ_INTEGER_SIZE + WIZ_LONG_SIZE + _
       WIZ_INTEGER_SIZE + WIZ_LONG_SIZE + ALERT_ACKID_LEN + _
       WIZ_LONG_SIZE + WIZ_LONG_SIZE + WIZ_LONG_SIZE + _
       WIZ_LONG_SIZE + WIZ_ALERT_IDEN_LEN + WIZ_ALERT_NAME_LEN + _
       WIZ_ALERT_TEXT_LEN + WIZ_LONG_SIZE + _
       UUID_STR_LEN + ALARM_FULL_PATH_LEN + _
       WIZ_LONG_SIZE + ALERT_ACKID_LEN + WIZ_LONG_SIZE + ALERT_ACKID_LEN + _
       WIZ_ALARM_USER_FIELD_LEN * WIZ_ALARM_USER_FIELD_COUNT

Global Const VFI_HIS_LEN_OLD   As Integer = _
       WIZ_LONG_SIZE + WIZ_LONG_SIZE + WIZ_INTEGER_SIZE + _
       WIZ_INTEGER_SIZE + WIZ_DOUBLE_SIZE + GATE_STRING_LEN_OLD

Global Const VFI_HIS_LEN   As Integer = _
       WIZ_LONG_SIZE + WIZ_LONG_SIZE + WIZ_INTEGER_SIZE + _
       WIZ_INTEGER_SIZE + WIZ_DOUBLE_SIZE + GATE_STRING_LEN


Type VFI_RECORD_OLD
     His    As VFI_HIS_OLD
     Lrm    As VFI_LRM_OLD
End Type

Type VFI_RECORD
     His    As VFI_HIS
     Lrm    As VFI_LRM
End Type


' FILTERS
Type HIS_FILTER
    GateID          As Long
    SecondsFrom     As Long
    SecondsTo       As Long
    Flags           As Integer
End Type


Type LRM_FILTER_OLD
     ' Options for the filter:
     ' LF_OR   - filter is ORed between the fileds
     ' LF_AND  - filter is ANDed betwenn the fileds (default)
     ' LF_ORCLASS  -  class field is ORed
     ' LF_ANDCLASS -  class field is ANDed
     ' LF_ORATTR   -  ATTR field is ORed
     ' LF_ANDATTR  -  ATTR field is ANDed
     Options        As Long
     From           As VFI_LRM_OLD  ' Start values
     To             As VFI_LRM_OLD  ' End values
     IndexNumber    As Byte     ' Index number to use explicitly
End Type

Type LRM_FILTER
     ' Options for the filter:
     ' LF_OR   - filter is ORed between the fileds
     ' LF_AND  - filter is ANDed betwenn the fileds (default)
     ' LF_ORCLASS  -  class field is ORed
     ' LF_ANDCLASS -  class field is ANDed
     ' LF_ORATTR   -  ATTR field is ORed
     ' LF_ANDATTR  -  ATTR field is ANDed
     Options        As Long
     From           As VFI_LRM  ' Start values
     To             As VFI_LRM  ' End values
     IndexNumber    As Byte     ' Index number to use explicitly
End Type


Type WIZ_FILTER_OLD
     His    As HIS_FILTER
     Lrm    As LRM_FILTER_OLD
End Type

Type WIZ_FILTER
     His    As HIS_FILTER
     Lrm    As LRM_FILTER
End Type

' -------------------------------------------------------------------
'   PRINT support
' -------------------------------------------------------------------

' Printer definitions

Global Const WIZPRNJOBTYPE_OFFLINE  As Integer = 0
Global Const WIZPRNJOBTYPE_ONLINE   As Integer = 1

Global Const WIZ_ALERT_LPT          As Integer = 0
Global Const WIZ_REP_LPT            As Integer = 1
Global Const WIZ_GRAPHIC_LPT        As Integer = 2
Global Const WIZ_PRINTER_NUM        As Integer = 3

' -------------------------------------------------------------------
'   PATH support - Type definitions - used for path setting as well
' -------------------------------------------------------------------

Global Const PATH_VP                As Integer = 0
Global Const PATH_HIS               As Integer = 1
Global Const PATH_LRM               As Integer = 2
Global Const PATH_ALERT_HELP        As Integer = 3
Global Const PATH_APP               As Integer = 4
Global Const PATH_USERS             As Integer = 5
Global Const PATH_MACROS            As Integer = 6
Global Const PATH_CLASSES           As Integer = 7
Global Const PATH_IMG               As Integer = 8
Global Const PATH_TXT               As Integer = 9
Global Const PATH_RCP               As Integer = 10
Global Const PATH_RCPMODEL          As Integer = 11
Global Const PATH_CLUSTERS          As Integer = 12
Global Const PATH_HOME              As Integer = 13
Global Const LAST_PATH              As Integer = 13

' -------------------------------------------------------------------
'   LGR support
' -------------------------------------------------------------------

' Daily log file "HISmm-dd.DAT" data struct

Global Const LGR_SET_OS2_VAL = 1        ' Value set (first record)
Global Const LGR_OS2_VAL = 2            ' Value change
Global Const LGR_OS2_COMM_ERR = 4       ' Communication errors records
Global Const LGR_STR_VAL = 8            ' String value

' ------------------------------------------------------------------
'   ERR support
' ------------------------------------------------------------------

Global Const WIZ_ERR_MSG_LEN = 256      ' length of buffer send to WizGetErrMsg()

Global Const ERR_NOFLAGS = 0            ' write to file and popup
Global Const ERR_FATAL = 1              ' write to file, popup and exit
Global Const ERR_DOS = 2                ' add doserrno value to message
Global Const ERR_ERRNO = 4              ' add errno value to message
Global Const ERR_INFORM = 8             ' write to file and popup if "wizpro p+"
Global Const ERR_FILE = 16              ' write to file if "wizpro p+"
Global Const ERR_RECORD = 32            ' allways write to file

' ------------------------------------------------------------------
' WIZPRO API for Visual Basic
' ------------------------------------------------------------------

' IPC functions

  Declare Function WizVBMkClient Lib "Wizvbapi.dll" (ByVal Name As String, ByVal Type_Client As Long, ByVal hWnd As Long, ByRef Hook As Byte) As Integer
  Declare Function Wiz5RmClient Lib "Wizpro.dll" (ByVal Hook As Byte) As Integer
  Declare Function Wiz5KillDelay Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Delay As Integer) As Integer
  Declare Function Wiz5ClearMsgQueue Lib "Wizpro.dll" (ByVal Hook As Byte) As Integer

  Declare Function WizVBGetHook Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal OtherClient As String, ByRef OtherHook As Byte) As Integer
  Declare Function Wiz5GetClientPID Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal OtherHook As Byte, ByRef PID As Long, ByRef TID As Long) As Integer
  Declare Function Wiz5PostMsg Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal OtherHook As Byte, ByRef Msg As WIZ_MSG_Internal) As Integer
  Declare Function Wiz5SendMsg Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal OtherHook As Byte, ByRef Msg As WIZ_MSG_Internal, ByVal TimeOut As Long) As Integer
  Declare Function Wiz5SendBuf Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal OtherHook As Byte, ByVal MsgType As Integer, ByVal Buffer As String, ByVal BufLen As Integer) As Integer
  Declare Function Wiz5PostBuf Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal OtherHook As Byte, ByVal MsgType As Integer, ByVal Buffer As String, ByVal BufLen As Integer) As Integer

' Gate data functions

  Declare Function Wiz5GetGateCount Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef TotalGates As Long, ByRef UnDelGates As Long, ByRef PLCGates As Long, ByRef CompaundGates As Long) As Integer
  Declare Function WizVBGetGateId Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateName As String, ByRef GateID As Long) As Integer
  Declare Function Wiz5GetGateIdByAddress Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal plcAddr As Long, ByVal MemoryType As Long, ByVal GateAddr As Long, ByVal BitNumber As Long, ByRef GateID As Long) As Integer
  Declare Function WizVBGetGateIdByAddressStr Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal AddressStr As String, ByRef GateID As Long) As Integer
  Declare Function Wiz5RqGateMsg Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateAmount As Long, ByRef GateList As Long, ByVal Mode As Long) As Integer
  Declare Function WizVBGetGateByNameIndex Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal NameIndex As Integer, ByVal GateName As String, ByRef GateID As Long) As Integer
  Declare Function WizVBTagValueUnlock Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal TagID As Long, ByVal UserName As String) As Integer
  Declare Function WizVBTagValueLock Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal TagID As Long, ByVal timeToUnlock As String, ByRef TagLockVal As WIZ_TAG_LOCK_VAL, ByVal UserName As String) As Integer
  
  Declare Function WizVBGetGateName Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal GateName As String) As Integer
  Declare Function Wiz5GetGateFormat Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByRef Format As Long) As Integer
  Declare Function WizVBGetGateRawValue Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, RawValue As WIZ_PLC_DATA, ByVal Sample As Integer) As Integer
  Declare Function WizVBPutGateRawValue Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, RawValue As WIZ_PLC_DATA, ByVal CommErr As Integer, ByVal Mode As Integer, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
  Declare Function Wiz5GetGateFlags Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByRef Flags As Byte) As Integer
  Declare Function Wiz5GetGateLimits Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByRef Upper As Double, ByRef Lower As Double) As Integer
  Declare Function Wiz5SetGateFlag Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal FlagId As Integer, ByVal SetFlag As Integer) As Integer
  Declare Function WizVBGetGateStr Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Mode As Integer, ByVal GateID As Long, ByVal GateVal As String, ByRef Seconds As Long, ByRef MiliSec As Integer) As Integer
  Declare Function Wiz5GetGateVal Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Mode As Integer, ByVal GateID As Long, ByRef GateVal As Double, ByRef Seconds As Long, ByRef MiliSec As Integer) As Integer
  Declare Function Wiz5PutGateVal Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As Double, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
  Declare Function Wiz5PutGateValDirect Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As Double, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
  Declare Function WizVBPutGateStr Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As String, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer

  Declare Function Wiz5SetGateSampleRate Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef GateList As Long, ByVal GateQuant As Long, ByVal NewRate As Long) As Integer
  Declare Function WizVBLoadRecipe Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal RcpFileName As String) As Integer
  Declare Function WizVBSaveRecipe Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal RcpFileName As String, ByVal RcpDescription As String) As Integer
  Declare Function Wiz5GateForceLog Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal Value As Double, ByVal Seconds As Long, ByVal Milli As Integer) As Integer
  Declare Function WizVBGateForceLogEx Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, ByVal Value As Double, ByVal GateVal As String, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer

' Gate definition functions

    Declare Function WizVBGetGateDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF) As Integer
    Declare Function WizVBAddGateDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, GateDef As WIZ_GT_DEF) As Integer
    Declare Function Wiz5DeleteGateDef Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal GateID As Long) As Integer
    Declare Function WizVBFindGateDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF, ByVal findflag As Long, ByRef FoundGateId As Long) As Integer
    Declare Function WizVBChangeGateDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF) As Integer

' Tag definition functions

    Declare Function WizVBGetTagDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF) As Integer
    Declare Function WizVBAddTagDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, TagDef As WIZ_TAG_DEF) As Integer
    Declare Function WizDeleteTagDef Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal TagID As Long) As Integer
    Declare Function WizVBFindTagDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF, ByVal findflag As Long, ByRef FoundTagId As Long) As Integer
    Declare Function WizVBChangeTagDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF) As Integer
    Declare Function WizVBGetTagDefShort Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF_SHORT) As Integer

' VPI functions

  Declare Function WizVBParseGate Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal GateAddr As String, ByVal GateType As Integer, ByVal Mode As Integer, ByVal GateFormat As Integer) As Integer
  Declare Function WizVBParseBlock Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockAddr As String, ByVal BlockLen As Integer) As Integer
  Declare Function Wiz5FlagVpi Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal ReadWrite As Integer, ByVal WriteOnly As Integer, ByVal OutBlock As Integer) As Integer
  Declare Function Wiz5VpiFlags Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByRef ReadWrite As Integer, ByRef WriteOnly As Integer, ByRef OutBlock As Integer) As Integer
  Declare Function Wiz5SetSamplerPriority Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal Class As Integer, ByVal Delta As Integer) As Integer
  Declare Function Wiz5GetSamplerPriority Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByRef Class As Integer, ByRef Delta As Integer) As Integer
  Declare Function WizVBSetVpiPort Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal NewPortName As String) As Integer
  Declare Function WizVBGetVpiPort Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal PortName As String) As Integer
  Declare Function WizVBWriteBlock Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal StartAddr As String, ByVal Length As Integer, ByVal BlockData As String) As Integer
  Declare Function WizVBReadBlock Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockAddr As String, ByVal Length As Integer, ByVal BlockData As String, ByVal TimeStamps As String) As Integer
  Declare Function Wiz5ReadBlockUpdate Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockId As Integer) As Integer

' Alert functions
   
  Declare Function WizVBStartAlert Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertId As Long) As Integer
  Declare Function WizVBStampAlert Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertQuant As Long, ByVal alertList As String, ByVal NewStatus As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String) As Integer
  Declare Function WizVBAckClassAlert Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewClass As Long, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String) As Integer
  Declare Function WizVBSetAlertText Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewText As String) As Integer
  Declare Function Wiz5RqUnAckedAlerts Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Operation As Integer) As Integer
  Declare Function Wiz5GetAlert Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal AlertId As Long, Alert As WIZ_ALERT) As Integer
  Declare Function Wiz5GetAlertCount Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef AlertCount As Long) As Integer
    
  Declare Function WizVBStartAlertWithGroup Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, _
    ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertId As Long, ByRef AlertEx As WIZ_ALERT2, ByRef Groups As WIZ_GROUP) As Integer
  Declare Function WizVBStartAlertWithLevel Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, _
    ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertEx As WIZ_ALERT2, ByRef Groups As WIZ_GROUP, _
    ByVal LevelId As Long, ByRef AamData As WIZ_AAM_DATA, ByVal ImageName As String, ByVal ZoneName As String, ByRef AlertId As Long) As Integer
  Declare Function WizVBStartAlarm Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, _
    ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertEx As WIZ_ALERT2, ByRef Groups As WIZ_GROUP, _
    ByVal LevelId As Long, ByRef AamData As WIZ_AAM_DATA, ByVal ImageName As String, ByVal ZoneName As String, ByVal UserFieldCount As Integer, ByRef UserFields As WIZ_ALARM_USER_FIELD_LIST, ByRef AlertId As Long) As Integer
  Declare Function WizVBStampAlertWithAcknowledge Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal NumOfAlerts As Long, ByVal alertList As String, ByVal stat As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String, ByRef Groups As WIZ_GROUP) As Integer
  Declare Function WizVBAckClassAlertWithAcknowledge Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertId As Long, ByVal UserClass As Long, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String, ByRef Groups As WIZ_GROUP) As Integer
 
 ' Alert definition functions

  Declare Function Wiz5GetAlertDef Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal AlertId As Long, AlertDef As WIZ_ALERT_DEF) As Integer
  Declare Function WizVBAddAlertDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, AlertDef As WIZ_ALERT_DEF) As Integer
  Declare Function WizVBChangeAlertDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, AlertDef As WIZ_ALERT_DEF, ByVal AlertId As Long) As Integer
  Declare Function Wiz5DeleteAlertDef Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal AlertId As Long) As Integer
  Declare Function WizVBFindAlertDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertId As Long, AlertDef As WIZ_ALERT_DEF, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer
  Declare Function Wiz5RqAlertDefMsg Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Operation As Long) As Integer
  
  Declare Function WizVBGetAlertDefExp Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertId As Long, Alertdefex As WIZ_ALERT_DEF_EXP, ByRef Exp As String) As Integer
  Declare Function WizVBAddAlertDefExp Lib "Wizvbapi.dll" (ByVal Hook As Byte, Alertdefex As WIZ_ALERT_DEF_EXP, ByRef AlertId As Long, ByRef Exp As String) As Integer
  Declare Function WizVBChangeAlertDefExp Lib "Wizvbapi.dll" (ByVal Hook As Byte, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal AlertId As Long, ByRef Exp As String, ByVal sLength As Long) As Integer
  Declare Function WizVBFindAlertDefExp Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal AlertId As Long, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer
  Declare Function WizVBFindAlarmDefByPattern Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal StnId As Integer, ByVal AlertId As Long, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal Expression As String, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer
  Declare Function WizIsGateExistInAlarmExpression Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal AlertId As Long, ByRef bExist As Integer) As Integer
  
' User related functions

    Declare Function Wiz5RqUserGroup Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Operation As Integer) As Integer
    Declare Function Wiz5VerifyUser Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal UserName As String, ByVal Password As String) As Integer
    Declare Function Wiz5Login Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal UserName As String, ByVal Group As Long) As Integer
    Declare Function Wiz5GetUserGroup Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef UserGroup As Long) As Integer
    Declare Function WizVBGetUserName Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal UserName As String) As Integer
    Declare Function WizVBUMGetUserGroups Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal UserName As String, ByVal GroupBuf As String, ByRef nCount As Long, ByRef nTotal As Long) As Integer
    Declare Function WizVBUMVerifyUser Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal UserName As String, ByVal Passwd As String) As Integer
    Declare Function WizVBUMVerifyWebUser Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal UserName As String, ByVal Passwd As String) As Integer

' VFI related functions

    Declare Function WizVBLocalTimeNowInSec Lib "Wizvbapi.dll" () As Long
    Declare Function WizVBSecToLocalTimeStr Lib "Wizvbapi.dll" (ByVal long_time As Long, ByVal TimeStr As String) As Integer
    Declare Function WizVBVfiReadLrm Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByRef pulRecs As Long, ByVal Buffer As String) As Integer
    Declare Function WizVBVfiReadLrmEx Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByRef pulRecs As Long, ByVal Buffer As String) As Integer
    Declare Function WizVBVfiReadHis Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByRef pulRecs As Long, ByVal Buffer As String) As Integer
    Declare Function WizVBVfiReadHisEx Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByRef pulRecs As Long, ByVal Buffer As String) As Integer
    Declare Function WizVBVfiWriteLrm Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByVal Buffer As String, ByRef pulRecNo As Long) As Integer
    Declare Function WizVBVfiWriteLrmEx Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByVal Buffer As String, ByRef pulRecNo As Long) As Integer
    Declare Function WizVBVfiWriteHis Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByVal Buffer As String, ByRef pulRecNo As Long) As Integer
    Declare Function WizVBVfiWriteHisEx Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByVal Buffer As String, ByRef pulRecNo As Long) As Integer

    Declare Function WizVBVfiOpen Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal FileType As Long, ByVal Mode As Long, ByVal Path As String, Filter_ As WIZ_FILTER_OLD, ByRef HVfi As Long) As Integer
    Declare Function WizVBVfiReopen Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByVal FileType As Long, Filter_ As WIZ_FILTER_OLD) As Integer
    Declare Function WizVBVfiOpenEx Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal FileType As Long, ByVal Mode As Long, ByVal Path As String, Filter_ As WIZ_FILTER, ByRef HVfi As Long) As Integer
    Declare Function WizVBVfiReopenEx Lib "Wizvbapi.dll" (ByVal HVfi As Long, ByVal FileType As Long, Filter_ As WIZ_FILTER) As Integer
    Declare Function Wiz5VfiFlush Lib "Wizpro.dll" (ByVal VFIHandle As Long) As Integer
    Declare Function Wiz5VfiClose Lib "Wizpro.dll" (ByVal VFIHandle As Long) As Integer
    Declare Function Wiz5VfiGetNumOfRecs Lib "Wizpro.dll" (ByVal VFIHandle As Long, ByRef Total As Long) As Integer
    Declare Function Wiz5VfiGetRecLength Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Type_ As Long, ByRef LenWiz As Long, ByRef LenPriv As Long) As Integer
    Declare Function Wiz5VfiGetVersion Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Type_ As Long, ByRef Major As Integer, ByRef Minor As Integer) As Integer

' Other functions

    Declare Function WizVBGetFileName Lib "Wizvbapi.dll" (ByVal FileType As Integer, ByVal FileName As String, ByVal FullPath As String) As Integer
    Declare Function WizVBGetFilePathSuffix Lib "Wizvbapi.dll" (ByVal FileType As Integer, ByVal Path As String, ByVal Suffix As String) As Integer
    Declare Function WizVBSetFilePath Lib "Wizvbapi.dll" (ByVal FileType As Integer, ByVal NewPath As String) As Integer
    Declare Function Wiz5GetBackupMode Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef Mode As Long) As Integer
    Declare Function Wiz5SetBackupMode Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Mode As Long) As Integer
    Declare Function WizVBGetPrinter Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Type_ As Integer, ByVal Printer As String) As Integer
    Declare Function WizVBSetPrinter Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Type_ As Integer, ByVal Printer As String) As Integer
    Declare Function WizVBGetPrinterStatus Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Device As String, ByRef DevStatus As Integer) As Integer
    Declare Function Wiz5StartPrintJob Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal PrinterId As Integer, ByVal JobType As Long, ByRef JobHandle As Long) As Integer
    Declare Function Wiz5EndPrintJob Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal JobHandle As Long) As Integer
    Declare Function Wiz5CancelPrintJob Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal JobHandle As Long) As Integer
    Declare Function WizVBPrintText Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal JobHandle As Long, ByVal PrtText As String) As Integer
    Declare Function WizVBGetWizproVer Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByRef WizproVerNumber As Integer, ByVal Description As String) As Integer

' Network

        Declare Function WizVBSetNetworkActive Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal YesNo As String) As Integer
        Declare Function WizVBSetNetMaxDelay Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Selector As String, ByVal NewString As String) As Integer
        Declare Function WizVBSetNetProtocol Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal NewString As String) As Integer
        Declare Function WizVBSetNetBackup Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Selector As String, ByVal NewString As String) As Integer

    Declare Function WizVBSetLocalStationCfg Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal StnName As String, ByVal StnId As Integer, ByVal Attributes As Long, ByVal ServerName As String, ByVal BackupTime As Long) As Integer
    Declare Function WizVBGetLocalStationCfg Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal StnName As String, ByRef StnId As Integer, ByRef NPIIdx As Integer, ByRef Attributes As Long, ByVal ServerName As String, ByRef BackupTime As Long) As Integer
    Declare Function WizVBGetStationDef Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal StnIdx As Long, ByVal StnName As String, ByRef StnId As Integer, ByRef Attributes As Long) As Integer
    Declare Function Wiz5GetNetInfo Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef LastStnIdx As Long) As Integer
    Declare Function WizVBGetStationNameById Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal StnId As Integer, ByVal StnName As String) As Integer
    Declare Function Wiz5RqNetMsg Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Operation As Long) As Integer
       
       Declare Function WizGetStnIdFromAlert Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal AlertId As Long, ByRef StnId As Integer) As Integer
       Declare Function WizVBGetStnStatus Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal StnIdx As Long, ByRef Def As GET_STN_DEF, ByRef Status As GET_STN_STATUS) As Integer

' View Port support
' Wizpro options
Global Const WIZ_LOGGER = 1
Global Const WIZ_SAMPLER = 2
Global Const WIZ_ALERTGENERATOR = 4
Global Const WIZ_ALERTCOLLAPSE = 8
Global Const WIZ_PACKDEFINITIONS = 16


    Declare Function Wiz5SetWizproOptions Lib "Wizpro.dll" (ByVal Hook As Byte, ByVal Options As Long) As Integer
    Declare Function Wiz5GetWizproOptions Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef Options As Long) As Integer
    Declare Function WizVBSetEnv Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal EnvString As String, ByVal NewEnvString As String) As Integer
    Declare Function WizVBGetEnv Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal EnvString As String, ByVal NewEnvString As String, ByVal MaxLength As Integer) As Integer
    Declare Function Wiz5GetPlugSerNum Lib "Wizpro.dll" (ByVal Hook As Byte, ByRef Agent As Integer, ByRef SerialNumber As Long) As Integer
    Declare Function WizVBGetModelLimits Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByRef MaxGates As Long, ByRef MaxVpi As Long, ByRef AllowAddons As Integer, ByRef AllowDevelopment As Integer, ByVal ModelName As String) As Integer

' By WizVBAPI.DLL

    Declare Function WizVBGetMsg Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByRef MsgType As Integer, ByRef Msg As WIZ_MSG_Internal) As Integer ' Wiz5GetMsg()
    Declare Function WizVBWaitMsg Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByRef MsgType As Integer, ByRef Msg As WIZ_MSG_Internal, ByVal TimeOut As Long) As Integer ' Wiz5WaitMsg()
 
    ' CONVERSION
    ' These conversion Sub procedures you can use to convert
    ' values from a specific data types of the WizPro.
    ' To convert a value into WizGateValMsg data type, for example,
    ' you use the WizCGateVal Sub procedure.
    
    Declare Sub WizCAlertDefMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizCAlertEndOpen Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizCAlertLastMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizCAlertMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizCAlertNewOpen Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizCAlertUnAck Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
   
    Declare Sub WizCGateDef Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateDef As WizGateDefMsg)
    Declare Sub WizCGateFlag Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateFlag As WizGateFlagMsg)
    Declare Sub WizCGateVal Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateVal As WizGateValMsg)
    Declare Sub WizCGateStr Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateStr As WizGateStrMsg)
    Declare Sub WizCLost Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, ByRef Count As Integer)
    Declare Sub WizCNewGroup Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, ByRef Group As Long)
    Declare Sub WizCNetMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, NetMsg As WizNetMsg)


    ' These conversion Sub procedures you can use to convert values to
    ' a specific data types of the WizPro.
    ' To convert a value from WizGateDefMsg into WIZ_MSG_Internal data type,
    ' for example, you use the WizSGateDef Sub procedure.

    Declare Sub WizSAlertDefMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizSAlertEndOpen Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizSAlertLastMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizSAlertMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizSAlertNewOpen Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)
    Declare Sub WizSAlertUnAck Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, Alert As WizAlertMsg)

    Declare Sub WizSGateDef Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateDef As WizGateDefMsg)
    Declare Sub WizSGateFlag Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateFlag As WizGateFlagMsg)
    Declare Sub WizSGateVal Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateVal As WizGateValMsg)
    Declare Sub WizSGateStr Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, GateStr As WizGateStrMsg)
    Declare Sub WizSLost Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, ByRef Count As Integer)
    Declare Sub WizSNewGroup Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, ByRef Group As Long)
    Declare Sub WizSNetMsg Lib "Wizvbapi.dll" (Msg As WIZ_MSG_Internal, NetMsg As WizNetMsg)
    Declare Function WizVBRqAlertMsg Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal Operation As Integer, ByVal FamilyCount As Long, ByVal FamilyList As String, ByVal MinSeverity As Long, ByVal MaxSeverity As Long, ByVal Classes As Long, ByVal MinZone As Long, ByVal MaxZone As Long, ByVal StnQuant As Long, ByVal StantionList As String) As Integer
   
' For WizGetMsg loop managment

Global Const WIZ_SHUT_DOWN  As Integer = 0
Global Const WIZ_MESSAGE_OK As Integer = &H8000

' All other functions return WIZ_NO_ERROR on succesfull complition

Global Const WIZ_NO_ERR = 0
Global Const WIZERR_PARSE = 1
Global Const WIZERR_COMM_RECOVER = 2
Global Const WIZERR_NO_VPI = 3
Global Const WIZERR_TIMEOUT = 4
Global Const WIZERR_NOT_FOUND = 5
Global Const WIZERR_NOT_LOCKED = 6
Global Const WIZERR_COMM = 7
Global Const WIZERR_NO_QUEUE = 8
Global Const WIZERR_ILLEGAL = 9
Global Const WIZERR_DUPLICATE = 10
Global Const WIZERR_RSRC_EXHAUSTED = 11
Global Const WIZERR_BAD_HOOK = 12
Global Const WIZERR_ILL_SAMPLE = 13
Global Const WIZERR_VPI_NO_READ = 14
Global Const WIZERR_VPI_NO_WRITE = 15
Global Const WIZERR_OUT_BLOCK = 16
Global Const WIZERR_NO_WIZPRO = 17
Global Const WIZERR_GENERAL = 18
Global Const WIZERR_NETWORK = 19
Global Const WIZERR_ALERT_ILL_OP = 20
Global Const WIZERR_ALERT_RELEASED = 21
Global Const WIZERR_NO_RCS = 22
Global Const WIZERR_WIN_POST_MSG = 23
Global Const WIZERR_PM_CLIENT = 24
Global Const WIZERR_BAD_TYPE = 25
Global Const WIZERR_NO_WIZ2 = 26
Global Const WIZERR_ILL_API = 27
Global Const WIZERR_ILL_VP_ID = 28
Global Const WIZERR_ILL_VP_TYPE = 29
Global Const WIZERR_MAX_VP_REACHED = 30
Global Const WIZERR_NOT_SUPPORTED = 37
Global Const WIZERR_PRINTER_NOT_READY = 38
Global Const WIZERR_NO_PRINTER = 39
Global Const WIZERR_NO_REP_AVAILABLE = 40
Global Const WIZERR_REP_PRT_RETRY = 41
Global Const WIZERR_REP_TOO_LONG = 42
Global Const WIZERR_NO_CHANGE = 43
Global Const WIZERR_SEM_LOCKED = 44
Global Const WIZERR_MACRO = 45
Global Const WIZERR_NOT_READY = 46
Global Const WIZERR_NO_BLOCK = 47
Global Const WIZERR_DELETED = 48
Global Const WIZERR_FILE = 49

' Internal use errors
Global Const WIZERR_DEVICE = 101
Global Const WIZERR_UNSOL_NOCHANGE = 102
Global Const WIZERR_RECOVERY_TIME = 103

' Memory allocation errors.
Global Const WIZERR_MEM = 300
Global Const WIZERR_NOT_ENOUGH_MEM = 301
Global Const WIZERR_BAD_PARAMS = 302
Global Const WIZERR_ACCESS_DENIED = 303
Global Const WIZERR_INVALID_ADDR = 304
Global Const WIZERR_INVALID_PID = 305
Global Const WIZERR_PTR_CHANGED = 306
Global Const WIZERR_TOO_MANY_FEAPS = 307

' Semaphore errors.
Global Const WIZERR_SEM = 400
Global Const WIZERR_ALREADY_OWNED = 401
Global Const WIZERR_OWNER_DIED = 402
Global Const WIZERR_TOO_MANY_REQUESTS = 403

' -------------------------------------------------------------------
'   Error messages
' -------------------------------------------------------------------

Global Const WIZ2ERR_BASE = 500

Global Const WIZERR_MEMERR = WIZ2ERR_BASE + 0
Global Const WIZERR_NO_AUTH = WIZ2ERR_BASE + 1
Global Const WIZERR_NOT_IMP = WIZ2ERR_BASE + 2
Global Const WIZERR_NOTREADY = WIZ2ERR_BASE + 3
Global Const WIZERR_ILL_PLUG = WIZ2ERR_BASE + 4

' Goto Named Zone
Global Const WIZERR_INV_ZONE = WIZ2ERR_BASE + 50

' Layers Show/Hide
Global Const WIZERR_INV_ALL_LAYERS = WIZ2ERR_BASE + 60
Global Const WIZERR_INV_PART_LAYERS = WIZ2ERR_BASE + 61

' Load Image
Global Const WIZERR_LOAD_IMAGE = WIZ2ERR_BASE + 70

' Load Viewport
Global Const WIZERR_VPEXIST = WIZ2ERR_BASE + 80
Global Const WIZERR_VPTHREAD = WIZ2ERR_BASE + 81
Global Const WIZERR_VPPARSE = WIZ2ERR_BASE + 82

' Save Viewport
Global Const WIZERR_VPFILEEXIST = WIZ2ERR_BASE + 90
Global Const WIZERR_VPFILEOPEN = WIZ2ERR_BASE + 91

' Layouts
Global Const WIZERR_LAYFILEEXIST = WIZ2ERR_BASE + 100
Global Const WIZERR_LAYFILEOPEN = WIZ2ERR_BASE + 101
Global Const WIZERR_LAYPARTLOAD = WIZ2ERR_BASE + 102
Global Const WIZERR_LAYSAMELAY = WIZ2ERR_BASE + 103
 
' Chart time.
Global Const WIZERR_ILLLEN = WIZ2ERR_BASE + 120
Global Const WIZERR_ONLINEMODE = WIZ2ERR_BASE + 121

Global Const WIZERR_ILL_USERNAME = WIZ2ERR_BASE + 130
Global Const WIZERR_ILL_PSW = WIZ2ERR_BASE + 131

Global Const WIZ_MAX_VPS = 50
Global Const VP_LAYOUT = 0
Global Const VP_ANN = 1
Global Const VP_IMG = 2
Global Const VP_CHR = 3
Global Const VP_ANL = 4
Global Const VP_TYPES = 5


Global Const ReservLen = 128 - 73 - FILE_LEN

Type WIZ_VP
     X          As Integer              ' VP position
     Y          As Integer
     cx         As Integer              ' VP size
     cy         As Integer
     Params     As Long                 ' Parameters of VP appearance : MinMax etc.
     Id         As Integer              ' view port number
     Type       As Byte                 ' VP type: annunciator, image, chart or analize
     Name       As WIZ_FILE_NAME
     Title      As String * 60          ' additional title bar info
     Reserved   As String * ReservLen
End Type


Type WIZ_VP_ID
     VpiId As Integer
End Type

Type WIZ_VP_ENTRY
     VpID       As Integer              ' ID defining the VP
     Type       As Byte                 ' the ViewPort type (ANN, IMG, ... )
     VpName     As String * FILE_LEN    ' ViewPort name
End Type

Global Const WIZ_VP_ENTRY_VPID_SIZE     As Integer = 6
Global Const WIZ_VP_ENTRY_TYPE_SIZE     As Integer = 3
Global Const WIZ_VP_ENTRY_NAME_SIZE     As Integer = FILE_LEN


' Values for Wait parameter in LoadVp and LoadLayout

Global Const WIZ2_NO_SYNC   As Integer = 0
Global Const WIZ2_SYNC      As Integer = &HFFFF

' Values for options in SetVpSizePos

Global Const SVP_SIZE           As Long = 1
Global Const SVP_MOVE           As Long = 2
Global Const SVP_SIZEMOVE       As Long = SVP_SIZE Or SVP_MOVE

Global Const SVP_SHOW           As Long = 4
Global Const SVP_HIDE           As Long = 8
Global Const SVP_MINIMIZE       As Long = &H10&
Global Const SVP_MAXIMIZE       As Long = &H20&
Global Const SVP_RESTORE        As Long = &H40&

' Values for viewport params

Global Const PVP_MINMAX         As Long = &H1&
Global Const PVP_TITLEBAR       As Long = &H2&
Global Const PVP_SYSMENU        As Long = &H4&
Global Const PVP_SIZING         As Long = &H8&
Global Const PVP_MENU           As Long = &H10&
Global Const PVP_NAMEINTITLE    As Long = &H20&

' General Viewports Apis

    Declare Function WizVBGetVpId Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpType As Integer, ByVal VpName As String, ByRef VpID As Integer) As Integer
    Declare Function WizVBLoadVp Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpType As Integer, ByVal VpName As String, ByVal Wait As Integer, ByRef VpID As Integer) As Integer
    Declare Function WizVBSaveVp Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal VpName As String) As Integer
    Declare Function Wiz5CloseVp Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpiId As Integer) As Integer
    Declare Function Wiz5QueryVp Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpiId As Integer, VpAtt As WIZ_VP) As Integer
    Declare Function Wiz5SwitchToVp Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpiId As Integer) As Integer
    Declare Function Wiz5SetVpPosSize Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpiId As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal Options As Long) As Integer
    Declare Function Wiz5SetVpParams Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpiId As Integer, ByVal NewParams As Long) As Integer
    Declare Function WizVBSetVpTitle Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpiId As Integer, ByVal Title As String) As Integer
    Declare Function Wiz5SetVpGroups Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpiId As Integer, ByVal Groups As Long) As Integer  ' *

' General Layout Apis

    Declare Function WizVBLoadLayout Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal LayName As String, ByVal Wait As Integer, ByVal VpList As String, ByRef VpCount As Integer) As Integer
    Declare Function WizVBQueryLayout Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal LayName As String, ByVal VpList As String, ByRef VpCount As Integer) As Integer
    Declare Function WizVBCloseLayout Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal PromptToSave As Long) As Integer
    Declare Function WizVBSaveLayout Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal LayName As String) As Integer
    Declare Function WizVBLoginUser Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal UserName As String, ByVal Password As String) As Integer



    Declare Function WizVBRunMacroByName Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal MacroName As String) As Integer
    Declare Function Wiz5RunMacroById Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal MacroId As Integer) As Integer
    Declare Function WizVBReloadMacros Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal MacroFileName As String) As Integer


Global Const LAYER_SHOW = 1
Global Const LAYER_HIDE = 2
Global Const LAYER_DEFAULT = 3

Type LAYER_STAT
     Att  As Integer
     Name As String * IMG_STR_LEN
End Type

Global Const WIZ_LAYER_STAT_ATT_SIZE    As Integer = 6
Global Const WIZ_LAYER_STAT_NAME_SIZE   As Integer = IMG_STR_LEN


' Image Apis

    Declare Function WizVBGotoNamedZone Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal ZoneName As String) As Integer
    Declare Function WizVBLoadImage Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal ImageName As String, ByVal ZoneName As String) As Integer
    Declare Function WizVBQueryImage Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal ImageName As String, ByVal ZoneName As String) As Integer
    Declare Function WizVBSetLayersStatus Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal LayersQuant As Integer, ByVal LayersList As String) As Integer
    Declare Function WizVBSetAnnFilter Lib "Wizvbapi.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal MinSeverity As Integer, ByVal MaxSeverity As Integer, ByVal FamilyList As String, ByVal MinZone As Integer, ByVal MaxZone As Integer, ByVal Class As Long, ByVal StantionList As String, ByVal StnQuant As Long) As Integer

Global Const ER_ABS = 0
Global Const ER_REL = 1
Global Const ER_RELDATE = 2

Type WIZ2DATETIME
     Year    As Integer
     Month   As Integer
     Day     As Integer
     Hours   As Integer
     Minutes As Integer
     Seconds As Integer
End Type


Type WIZ2TIMEPERIOD
     Days    As Integer
     Hours   As Integer
     Minutes As Integer
     Seconds As Integer
End Type

Type TM
     Sec    As Long     ' seconds after the minute - [0,59]
     Min    As Long     ' minutes after the hour - [0,59]
     Hour   As Long     ' hours since midnight - [0,23]
     Mday   As Long     ' day of the month - [1,31]
     Mon    As Long     ' months since January - [0,11]
     Year   As Long     ' years since 1900
     Wday   As Long     ' days since Sunday - [0,6]
     Yday   As Long     ' days since January 1 - [0,365]
     Isdst  As Long     ' daylight savings time flag
End Type

    Declare Function Wiz5SetChrTime Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByVal StartType As Integer, NewStart As WIZ2DATETIME, NewChrLen As WIZ2TIMEPERIOD, NewWinLen As WIZ2TIMEPERIOD) As Integer
    Declare Function Wiz5GetChrTime Lib "wiz5api.dll" (ByVal Hook As Byte, ByVal VpID As Integer, ByRef StartType As Integer, Start As WIZ2DATETIME, ChrLen As WIZ2TIMEPERIOD, WinLen As WIZ2TIMEPERIOD) As Integer


Global Const BUFFER_SIZE = 128
Global Const DEVICE_BUFFER = 256
Global Const WIZ_ALERT_ID_SIZE = 12

    Declare Function WizVBLocalTime Lib "Wizvbapi.dll" (ByVal Seconds As Long, LocalTime As TM) As Integer
    Declare Function WizVBMkTime Lib "Wizvbapi.dll" (ByRef Seconds As Long, LocalTime As TM) As Integer


'
Public Function WizGetAlertDefExp(ByVal Hook As Byte, ByVal AlertId As Long, ByRef Alertdefex As WIZ_ALERT_DEF_EXP, ByRef Exp As String) As Integer
    
    Dim TempName As String * WIZ_ALERT_EXPR_LEN
    TempName = Trim(Exp) & Chr(0)
    Dim Rc As Integer
    Dim AlertDefinition As WIZ_ALERT_DEF_EXP
   
    AlertDefinition = Alertdefex
   
    Rc = WizVBGetAlertDefExp(Hook, AlertId, AlertDefinition, TempName)
    If Rc = WIZ_NO_ERR Then
        Alertdefex = AlertDefinition
        Exp = TempName
    End If
    WizGetAlertDefExp = Rc
   
End Function


'
Function Wiz5AddAlertDef(ByVal Hook As Byte, AlertDef As WIZ_ALERT_DEF) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF

    If ((AlertDef.Attr And Att_AutoAck) <> 0) And ((AlertDef.Attr And Att_AckClass) <> 0) Then
        Wiz5AddAlertDef = WIZERR_ILLEGAL
        Exit Function
    End If

    AlertDefinition = AlertDef

    AlertDefinition.GateName = Mid(Trim(AlertDef.GateName) & Chr(0), 1, GT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.Family = Mid(Trim(AlertDef.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(AlertDef.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(AlertDef.AlertText) & Chr(0), 1, 60) & Chr(0)

    Wiz5AddAlertDef = WizVBAddAlertDef(Hook, AlertDefinition)

End Function


'
Function WizAddAlertDefExp(ByVal Hook As Byte, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal AlertId As Long, ByRef Exp As String) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF_EXP
    Dim TempName As String
        TempName = Trim(Exp) & Chr(0)

    If ((Alertdefex.Attr And Att_AutoAck) <> 0) And ((Alertdefex.Attr And Att_AckClass) <> 0) Then
        WizAddAlertDefExp = WIZERR_ILLEGAL
        Exit Function
    End If
    
    AlertDefinition = Alertdefex
    
    AlertDefinition.Family = Mid(Trim(Alertdefex.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(Alertdefex.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(Alertdefex.AlertText) & Chr(0), 1, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
    AlertDefinition.ImageName = Mid(RTrim(Alertdefex.ImageName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.ZoneName = Mid(RTrim(Alertdefex.ZoneName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.AamData.File = Mid(RTrim(Alertdefex.AamData.File) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.AamData.VoiceFile = Mid(RTrim(Alertdefex.AamData.VoiceFile) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field0 = Mid(RTrim(Alertdefex.UserFieldList.Field0) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field1 = Mid(RTrim(Alertdefex.UserFieldList.Field1) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field2 = Mid(RTrim(Alertdefex.UserFieldList.Field2) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field3 = Mid(RTrim(Alertdefex.UserFieldList.Field3) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field4 = Mid(RTrim(Alertdefex.UserFieldList.Field4) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
     
    WizAddAlertDefExp = WizVBAddAlertDefExp(Hook, AlertDefinition, AlertId, Exp)

End Function
 


'
Public Function Wiz5ChangeAlertDef(ByVal Hook As Byte, AlertDef As WIZ_ALERT_DEF, ByVal AlertId As Long) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF
    AlertDefinition = AlertDef

    AlertDefinition.GateName = Mid(Trim(AlertDef.GateName) & Chr(0), 1, GT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.Family = Mid(Trim(AlertDef.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(AlertDef.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(AlertDef.AlertText) & Chr(0), 1, 60) & Chr(0)
   
    Wiz5ChangeAlertDef = WizVBChangeAlertDef(Hook, AlertDefinition, AlertId)

End Function



'
Public Function WizChangeAlertDefExp(ByVal Hook As Byte, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal AlertId As Long, ByVal Exp As String) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF_EXP
    Dim TempName As String
        TempName = Trim(Exp) & Chr(0)
        
    AlertDefinition = Alertdefex
    AlertDefinition.Family = Mid(Trim(Alertdefex.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(Alertdefex.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(Alertdefex.AlertText) & Chr(0), 1, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
    AlertDefinition.ImageName = Mid(RTrim(Alertdefex.ImageName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.ZoneName = Mid(RTrim(Alertdefex.ZoneName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.AamData.File = Mid(RTrim(Alertdefex.AamData.File) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.AamData.VoiceFile = Mid(RTrim(Alertdefex.AamData.VoiceFile) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field0 = Mid(RTrim(Alertdefex.UserFieldList.Field0) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field1 = Mid(RTrim(Alertdefex.UserFieldList.Field1) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field2 = Mid(RTrim(Alertdefex.UserFieldList.Field2) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field3 = Mid(RTrim(Alertdefex.UserFieldList.Field3) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field4 = Mid(RTrim(Alertdefex.UserFieldList.Field4) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)

    WizChangeAlertDefExp = WizVBChangeAlertDefExp(Hook, AlertDefinition, AlertId, TempName, Len(TempName) - 1)

End Function


'
Public Function Wiz5FindAlertDef(ByVal Hook As Byte, ByVal AlertId As Long, AlertDef As WIZ_ALERT_DEF, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF
    AlertDefinition = AlertDef

    AlertDefinition.GateName = Mid(Trim(AlertDef.GateName) & Chr(0), 1, GT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.Family = Mid(Trim(AlertDef.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(AlertDef.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(AlertDef.AlertText) & Chr(0), 1, 60) & Chr(0)
   
    Wiz5FindAlertDef = WizVBFindAlertDef(Hook, AlertId, AlertDefinition, findflag, FoundAlertid)

End Function


'
Public Function WizFindAlertDefExp(ByVal Hook As Byte, ByVal AlertId As Long, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF_EXP

        
    AlertDefinition = Alertdefex

    AlertDefinition.Family = Mid(Trim(Alertdefex.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(Alertdefex.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(Alertdefex.AlertText) & Chr(0), 1, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
    AlertDefinition.ImageName = Mid(RTrim(Alertdefex.ImageName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.ZoneName = Mid(RTrim(Alertdefex.ZoneName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.AamData.File = Mid(RTrim(Alertdefex.AamData.File) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.AamData.VoiceFile = Mid(RTrim(Alertdefex.AamData.VoiceFile) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field0 = Mid(RTrim(Alertdefex.UserFieldList.Field0) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field1 = Mid(RTrim(Alertdefex.UserFieldList.Field1) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field2 = Mid(RTrim(Alertdefex.UserFieldList.Field2) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field3 = Mid(RTrim(Alertdefex.UserFieldList.Field3) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field4 = Mid(RTrim(Alertdefex.UserFieldList.Field4) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    
    WizFindAlertDefExp = WizVBFindAlertDefExp(Hook, AlertId, AlertDefinition, findflag, FoundAlertid)

End Function



'
Public Function WizFindAlarmDefByPattern(ByVal Hook As Byte, ByVal StnId As Integer, ByVal AlertId As Long, Alertdefex As WIZ_ALERT_DEF_EXP, ByVal Expression As String, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer

    Dim AlertDefinition As WIZ_ALERT_DEF_EXP
    Dim Expr As String * WIZ_ALERT_EXPR_LEN
    Expr = Trim(Expression) & Chr(0)
        
    AlertDefinition = Alertdefex

    AlertDefinition.Family = Mid(Trim(Alertdefex.Family) & Chr(0), 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
    AlertDefinition.InfoFile = Mid(Trim(Alertdefex.InfoFile) & Chr(0), 1, 8) & Chr(0)
    AlertDefinition.AlertText = Mid(RTrim(Alertdefex.AlertText) & Chr(0), 1, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
    AlertDefinition.ImageName = Mid(RTrim(Alertdefex.ImageName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.ZoneName = Mid(RTrim(Alertdefex.ZoneName) & Chr(0), 1, IMG_STR_LEN - 1) & Chr(0)
    AlertDefinition.AamData.File = Mid(RTrim(Alertdefex.AamData.File) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.AamData.VoiceFile = Mid(RTrim(Alertdefex.AamData.VoiceFile) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field0 = Mid(RTrim(Alertdefex.UserFieldList.Field0) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field1 = Mid(RTrim(Alertdefex.UserFieldList.Field1) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field2 = Mid(RTrim(Alertdefex.UserFieldList.Field2) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field3 = Mid(RTrim(Alertdefex.UserFieldList.Field3) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    AlertDefinition.UserFieldList.Field4 = Mid(RTrim(Alertdefex.UserFieldList.Field4) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    
    WizFindAlarmDefByPattern = WizVBFindAlarmDefByPattern(Hook, StnId, AlertId, AlertDefinition, Expr, findflag, FoundAlertid)

End Function


'
'   Converts a time value and corrects for the local time zone.
'
'   Return Value:
'       Writes a result in the TM structure. If the value in "Seconds"
'       represents a date before midnight, January 1, 1970, WizLocalTime()
'       returns 'False', else 'True'.
'
Public Function Wiz5LocalTime(ByVal Seconds As Long, LocalTime As TM) As Integer

    Wiz5LocalTime = WizVBLocalTime(Seconds, LocalTime)

End Function


'
'  Converts the local time to a calendar value.
'
'  Parameters:
'      Time    [in] Is pointer to time structure
'      Seconds [out] The specified calendar time encoded as a value of type Long.
'              If 'Time' references a date before midnight, January 1, 1970,
'              or if the calendar time cannot be represented, the function
'              returns in 'Seconds' -1.
'  Return value:
'              WIZ_NO_ERR  if 'Time' references a date before midnight, January 1, 1970
'              -1          if the calendar time cannot be represented
'
Public Function Wiz5MkTime(ByRef Seconds As Long, Time As TM) As Integer
    
    Dim Temp As Long
    Wiz5MkTime = WizVBMkTime(Temp, Time)
    Seconds = Temp

End Function


'
Public Function Wiz5AddGateDef(ByVal Hook As Byte, GateDef As WIZ_GT_DEF) As Integer

    Dim Temp As WIZ_GT_DEF
    Temp = GateDef

    Temp.Name = Trim(GateDef.Name) & Chr(0)
    Temp.Desc = Trim(GateDef.Desc) & Chr(0)
    Temp.Application = Trim(GateDef.Application) & Chr(0)
    Temp.Topic = Trim(GateDef.Topic) & Chr(0)
    Temp.Item = Trim(GateDef.Item) & Chr(0)
    Temp.BlockName = Trim(GateDef.BlockName) & Chr(0)
    Temp.Address = Trim(GateDef.Address) & Chr(0)
    Temp.Gate1Name = Trim(GateDef.Gate1Name) & Chr(0)
    Temp.Gate2Name = Trim(GateDef.Gate2Name) & Chr(0)
    
    Wiz5AddGateDef = WizVBAddGateDef(Hook, Temp)
End Function


'
Public Function Wiz5ChangeGateDef(ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF) As Integer

    Dim Temp As WIZ_GT_DEF
    Temp = GateDef

    Temp.Name = Trim(GateDef.Name) & Chr(0)
    Temp.Desc = Trim(GateDef.Desc) & Chr(0)
    Temp.Application = Trim(GateDef.Application) & Chr(0)
    Temp.Topic = Trim(GateDef.Topic) & Chr(0)
    Temp.Item = Trim(GateDef.Item) & Chr(0)
    Temp.BlockName = Trim(GateDef.BlockName) & Chr(0)
    Temp.Address = Trim(GateDef.Address) & Chr(0)
    Temp.Gate1Name = Trim(GateDef.Gate1Name) & Chr(0)
    Temp.Gate2Name = Trim(GateDef.Gate2Name) & Chr(0)
    
    Wiz5ChangeGateDef = WizVBChangeGateDef(Hook, GateID, Temp)

End Function


'
Public Function Wiz5FindGateDef(ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF, ByVal findflag As Long, ByRef FoundGateId As Long) As Integer

    Dim Temp As WIZ_GT_DEF
    Temp = GateDef

    Temp.Name = Trim(GateDef.Name) & Chr(0)
    Temp.Desc = Trim(GateDef.Desc) & Chr(0)
    Temp.Application = Trim(GateDef.Application) & Chr(0)
    Temp.Topic = Trim(GateDef.Topic) & Chr(0)
    Temp.Item = Trim(GateDef.Item) & Chr(0)
    Temp.BlockName = Trim(GateDef.BlockName) & Chr(0)
    Temp.Address = Trim(GateDef.Address) & Chr(0)
    Temp.Gate1Name = Trim(GateDef.Gate1Name) & Chr(0)
    Temp.Gate2Name = Trim(GateDef.Gate2Name) & Chr(0)
    
    Wiz5FindGateDef = WizVBFindGateDef(Hook, GateID, Temp, findflag, FoundGateId)

End Function


'
Public Function WizAddTagDef(ByVal Hook As Byte, TagDef As WIZ_TAG_DEF) As Integer

    Dim Temp As WIZ_TAG_DEF
    Temp = TagDef

    Temp.Name = Trim(TagDef.Name) & Chr(0)
    Temp.Desc = Trim(TagDef.Desc) & Chr(0)
    Temp.Application = Trim(TagDef.Application) & Chr(0)
    Temp.Topic = Trim(TagDef.Topic) & Chr(0)
    Temp.Item = Trim(TagDef.Item) & Chr(0)
    Temp.BlockName = Trim(TagDef.BlockName) & Chr(0)
    Temp.Address = Trim(TagDef.Address) & Chr(0)
    Temp.Gate1Name = Trim(TagDef.Gate1Name) & Chr(0)
    Temp.Gate2Name = Trim(TagDef.Gate2Name) & Chr(0)
    Temp.LockData.StringValue = Trim(TagDef.LockData.StringValue) & Chr(0)
    Temp.LockData.StatusGateName.GateName = Trim(TagDef.LockData.StatusGateName.GateName) & Chr(0)
    
    WizAddTagDef = WizVBAddTagDef(Hook, Temp)

End Function


'
Public Function WizChangeTagDef(ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF) As Integer

    Dim Temp As WIZ_TAG_DEF
    Temp = TagDef

    Temp.Name = Trim(TagDef.Name) & Chr(0)
    Temp.Desc = Trim(TagDef.Desc) & Chr(0)
    Temp.Application = Trim(TagDef.Application) & Chr(0)
    Temp.Topic = Trim(TagDef.Topic) & Chr(0)
    Temp.Item = Trim(TagDef.Item) & Chr(0)
    Temp.BlockName = Trim(TagDef.BlockName) & Chr(0)
    Temp.Address = Trim(TagDef.Address) & Chr(0)
    Temp.Gate1Name = Trim(TagDef.Gate1Name) & Chr(0)
    Temp.Gate2Name = Trim(TagDef.Gate2Name) & Chr(0)
    Temp.LockData.StringValue = Trim(TagDef.LockData.StringValue) & Chr(0)
    Temp.LockData.StatusGateName.GateName = Trim(TagDef.LockData.StatusGateName.GateName) & Chr(0)
    
    WizChangeTagDef = WizVBChangeTagDef(Hook, TagID, Temp)

End Function


'
Public Function WizFindTagDef(ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF, ByVal findflag As Long, ByRef FoundTagId As Long) As Integer

    Dim Temp As WIZ_TAG_DEF
    Temp = TagDef

    Temp.Name = Trim(TagDef.Name) & Chr(0)
    Temp.Desc = Trim(TagDef.Desc) & Chr(0)
    Temp.Application = Trim(TagDef.Application) & Chr(0)
    Temp.Topic = Trim(TagDef.Topic) & Chr(0)
    Temp.Item = Trim(TagDef.Item) & Chr(0)
    Temp.BlockName = Trim(TagDef.BlockName) & Chr(0)
    Temp.Address = Trim(TagDef.Address) & Chr(0)
    Temp.Gate1Name = Trim(TagDef.Gate1Name) & Chr(0)
    Temp.Gate2Name = Trim(TagDef.Gate2Name) & Chr(0)
    Temp.LockData.StringValue = Trim(TagDef.LockData.StringValue) & Chr(0)
    Temp.LockData.StatusGateName.GateName = Trim(TagDef.LockData.StatusGateName.GateName) & Chr(0)
    
    WizFindTagDef = WizVBFindTagDef(Hook, TagID, Temp, findflag, FoundTagId)

End Function


'
Public Function Wiz5GetEnv(ByVal Hook As Byte, ByVal EnvString As String, ByRef NewEnvString As String, ByVal MaxLength As Integer) As Integer

    Dim Rc      As Integer
    Dim EnvStr  As String
    Dim NewStr  As String

    EnvStr = Trim(EnvString) & Chr(0)
    NewStr = String(MaxLength + 1, " ")

    Rc = WizVBGetEnv(Hook, EnvStr, NewStr, MaxLength)
    
    If Rc = WIZ_NO_ERR Then
        NewEnvString = NewStr
    End If

    Wiz5GetEnv = Rc

End Function




'
' The API Set network to active/not active
'
Public Function WizSetNetworkActive(ByVal Hook As Byte, ByVal YesNo As String) As Integer

    Dim vbYesNo As String
    vbYesNo = Trim(YesNo) & Chr(0)
    WizSetNetworkActive = WizVBSetNetworkActive(Hook, vbYesNo)

End Function

'
' The API Sets maximum time or maximum change delay.
'
Public Function WizSetNetMaxDelay(ByVal Hook As Byte, ByVal Selector As String, ByVal NewString As String) As Integer

    Dim vbSelector As String, vbNewString As String
    vbSelector = Trim(Selector) & Chr(0)
    vbNewString = Trim(NewString) & Chr(0)
    WizSetNetMaxDelay = WizVBSetNetMaxDelay(Hook, vbSelector, vbNewString)

End Function

'
' The API choooses NPINTBS / NPITCP protocol
'
Public Function WizSetNetProtocol(ByVal Hook As Byte, ByVal NewString As String) As Integer

    Dim vbNewString As String
    vbNewString = Trim(NewString) & Chr(0)
    WizSetNetProtocol = WizVBSetNetProtocol(Hook, vbNewString)

End Function

'
' The API Sets network backup mode or network backup address.
'
Public Function WizSetNetBackup(ByVal Hook As Byte, ByVal Selector As String, ByVal NewString As String) As Integer

    Dim vbSelector As String, vbNewString As String
    vbSelector = Trim(Selector) & Chr(0)
    vbNewString = Trim(NewString) & Chr(0)
    WizSetNetBackup = WizVBSetNetBackup(Hook, vbSelector, vbNewString)

End Function

'
Public Function WizSetLocalStationCfg(ByVal Hook As Byte, ByVal StnName As String, ByVal StnId As Integer, ByVal Attributes As Long, ByVal ServerName As String, ByVal BackupTime As Long) As Integer

    Dim vbStnName As String, vbServerName As String
    vbStnName = Trim(StnName) & Chr(0)
    vbServerName = Trim(ServerName) & Chr(0)
    WizSetLocalStationCfg = WizVBSetLocalStationCfg(Hook, vbStnName, StnId, Attributes, vbServerName, BackupTime)

End Function


'
Public Function Wiz5GetLocalStationCfg(ByVal Hook As Byte, ByRef StnName As String, ByRef StnId As Integer, ByRef NPIIdx As Integer, ByRef Attributes As Long, ByRef ServerName As String, ByRef BackupTime As Long) As Integer
    
    Dim Rc              As Integer
    Dim Stn_Name        As String
    Dim Server_Name     As String
    
    Stn_Name = String(STNPART_NAME_LEN, " ")
    Server_Name = String(STNPART_NAME_LEN, " ")

    Rc = WizVBGetLocalStationCfg(Hook, Stn_Name, StnId, NPIIdx, Attributes, Server_Name, BackupTime)
    
    If Rc = WIZ_NO_ERR Then
        StnName = Stn_Name
        ServerName = Server_Name
    End If
    
    Wiz5GetLocalStationCfg = Rc

End Function


'
Public Function Wiz5GetModelLimits(ByVal Hook As Byte, ByRef MaxGates As Long, ByRef MaxVpi As Long, ByRef AllowAddons As Integer, ByRef AllowDevelopment As Integer, ByRef ModelName As String) As Integer
    
    Dim Rc      As Integer
    Dim Buffer  As String * BUFFER_SIZE
    Buffer = ""
    
    Rc = WizVBGetModelLimits(Hook, MaxGates, MaxVpi, AllowAddons, AllowDevelopment, Buffer)
    
    If Rc = WIZ_NO_ERR Then
        ModelName = Buffer
    End If
    
    Wiz5GetModelLimits = Rc

End Function

'
Public Function Wiz5GetStationDef(ByVal Hook As Byte, ByVal StnIdx As Long, ByRef StnName As String, ByRef StnId As Integer, ByRef Attributes As Long) As Integer

    Dim Rc      As Integer
    Dim Buffer  As String * STNPART_NAME_LEN
    Buffer = ""
    
    Rc = WizVBGetStationDef(Hook, StnIdx, Buffer, StnId, Attributes)
    
    If Rc = WIZ_NO_ERR Then
        StnName = Buffer
    End If
    
    Wiz5GetStationDef = Rc

End Function

'
Public Function Wiz5GetStationNameById(ByVal Hook As Byte, ByVal StnId As Integer, ByRef StnName As String) As Integer

    Dim Rc      As Integer
    Dim Buffer  As String * STNPART_NAME_LEN
    Buffer = ""
    
    Rc = WizVBGetStationNameById(Hook, StnId, Buffer)
    
    If Rc = WIZ_NO_ERR Then
        StnName = Buffer
    End If
    
    Wiz5GetStationNameById = Rc

End Function

'
Public Function WizGetStnStatus(ByVal Hook As Byte, ByVal StnIdx As Long, ByRef Def As GET_STN_DEF, ByRef Status As GET_STN_STATUS) As Integer
     
    WizGetStnStatus = WizVBGetStnStatus(Hook, StnIdx, Def, Status)
    
End Function



'
Public Function Wiz5GetUserName(ByVal Hook As Byte, ByRef UserName As String) As Integer

    Dim Rc      As Integer
    Dim Buffer  As String * BUFFER_SIZE
    Buffer = ""
    
    Rc = WizVBGetUserName(Hook, Buffer)
    
    If Rc = WIZ_NO_ERR Then
        UserName = Buffer
    End If
    
    Wiz5GetUserName = Rc

End Function

'
Public Function Wiz5GetVpId(ByVal Hook As Byte, ByVal VpType As Integer, ByVal VpName As String, ByRef VpID As Integer) As Integer

    Dim Name As String

    Name = Trim(VpName) & Chr(0)
    Wiz5GetVpId = WizVBGetVpId(Hook, VpType, Name, VpID)

End Function


'
Public Function Wiz5GetWizproVer(ByVal Hook As Byte, ByRef WizproVerNumber As Integer, ByRef Description As String) As Integer

    Dim Rc      As Integer
    Dim Buffer  As String * BUFFER_SIZE
    Buffer = ""
    
    Rc = WizVBGetWizproVer(Hook, WizproVerNumber, Buffer)
    
    If Rc = WIZ_NO_ERR Then
        Description = Buffer
    End If
    
    Wiz5GetWizproVer = Rc

End Function

'
Public Function Wiz5GotoNamedZone(ByVal Hook As Byte, ByVal VpID As Integer, ByVal ZoneName As String) As Integer

    Dim TempName As String
        TempName = Trim(ZoneName) & Chr(0)

    Wiz5GotoNamedZone = WizVBGotoNamedZone(Hook, VpID, TempName)

End Function

'
Public Function Wiz5LoadImage(ByVal Hook As Byte, ByVal VpID As Integer, ByVal ImageName As String, ByVal ZoneName As String) As Integer

    Dim Zone_Name  As String
    Dim Image_Name As String

    Image_Name = Trim(ImageName) & Chr(0)

    If ZoneName = vbNullString Then
        Wiz5LoadImage = WizVBLoadImage(Hook, VpID, Image_Name, vbNullString)
    Else
        Zone_Name = Trim(ZoneName) & Chr(0)
        Wiz5LoadImage = WizVBLoadImage(Hook, VpID, Image_Name, Zone_Name)
    End If

End Function

'
Public Function Wiz5LoadRecipe(ByVal Hook As Byte, ByVal RcpFileName As String) As Integer

    Dim Buffer As String * PATH_LEN
    Buffer = Trim(RcpFileName) & Chr(0)
    
    Wiz5LoadRecipe = WizVBLoadRecipe(Hook, Buffer)

End Function

'
Public Function Wiz5LoadVp(ByVal Hook As Byte, ByVal VpType As Integer, ByVal VpName As String, ByVal Wait As Integer, ByRef VpID As Integer) As Integer

    Dim Name As String

    Name = Trim(VpName) & Chr(0)
    Wiz5LoadVp = WizVBLoadVp(Hook, VpType, Name, Wait, VpID)

End Function


'
Public Function Wiz5QueryImage(ByVal Hook As Byte, ByVal VpID As Integer, ByRef ImageName As String, ByRef ZoneName As String) As Integer

    Dim Rc         As Integer
    Dim Image_Name As String * PATH_LEN
    Dim Zone_Name  As String * PATH_LEN
    
    Image_Name = String(PATH_LEN, " ")
    Zone_Name = String(PATH_LEN, " ")

    Rc = WizVBQueryImage(Hook, VpID, Image_Name, Zone_Name)
   
    If Rc = WIZ_NO_ERR Then
        ImageName = Image_Name
        ZoneName = Zone_Name
    End If
    
    Wiz5QueryImage = Rc

End Function

'
Public Function Wiz5ReloadMacros(ByVal Hook As Byte, ByVal MacroFileName As String) As Integer

    Dim TempName As String
        TempName = Trim(MacroFileName) & Chr(0)

    Wiz5ReloadMacros = WizVBReloadMacros(Hook, TempName)

End Function

'
Public Function Wiz5RunMacroByName(ByVal Hook As Byte, ByVal MacroName As String) As Integer

    Dim TempName As String
        TempName = Trim(MacroName) & Chr(0)

    Wiz5RunMacroByName = WizVBRunMacroByName(Hook, TempName)

End Function

'
Public Function Wiz5SaveLayout(ByVal Hook As Byte, ByVal LayName As String) As Integer
    
    Dim TempName As String
        TempName = Trim(LayName) & Chr(0)
    Wiz5SaveLayout = WizVBSaveLayout(Hook, TempName)

End Function

'
Public Function Wiz5SaveVp(ByVal Hook As Byte, ByVal VpID As Integer, ByVal VpName As String) As Integer

    Dim Name As String
    
    Name = Trim(VpName) & Chr(0)
    Wiz5SaveVp = WizVBSaveVp(Hook, VpID, Name)

End Function

'
Public Function Wiz5SetEnv(ByVal Hook As Byte, ByVal EnvString As String, ByVal NewEnvString As String) As Integer

    Dim EnvStr  As String
    Dim NewVal  As String

    EnvStr = Trim(EnvString) & Chr(0)
    NewVal = Trim(NewEnvString) & Chr(0)

    Wiz5SetEnv = WizVBSetEnv(Hook, EnvStr, NewVal)
    
End Function

'
Public Function Wiz5SetVpTitle(ByVal Hook As Byte, ByVal VpiId As Integer, ByVal Title As String) As Integer

    Dim Name As String

    Name = Trim(Title) & Chr(0)
    Wiz5SetVpTitle = WizVBSetVpTitle(Hook, VpiId, Name)

End Function
'
Public Function Wiz5LocalTimeNowInSec() As Long
    Wiz5LocalTimeNowInSec = WizVBLocalTimeNowInSec()
End Function
'
Public Function Wiz5SecToLocalTimeStr(ByVal long_time As Long, ByVal TimeStr As String) As Integer
    Wiz5SecToLocalTimeStr = WizVBSecToLocalTimeStr(long_time, TimeStr)
End Function

'
Public Function Wiz5VfiReopen(ByVal HVfi As Long, ByVal FileType As Long, Filter_ As WIZ_FILTER_OLD) As Integer

    Wiz5VfiReopen = WizVBVfiReopen(HVfi, FileType, Filter_)

End Function

'
Public Function WizVfiReopenEx(ByVal HVfi As Long, ByVal FileType As Long, Filter_ As WIZ_FILTER) As Integer

    WizVfiReopenEx = WizVBVfiReopenEx(HVfi, FileType, Filter_)

End Function

'
Public Function Wiz5VfiOpen(ByVal Hook As Byte, ByVal FileType As Long, ByVal Mode As Long, ByVal Path As String, Filter As WIZ_FILTER_OLD, ByRef HVfi As Long) As Integer

    Dim TempPath As String
    
    If Path = vbNullString Then
        TempPath = vbNullString
    Else
        TempPath = Trim(Path) & Chr(0)
    End If
    
    Wiz5VfiOpen = WizVBVfiOpen(Hook, FileType, Mode, TempPath, Filter, HVfi)

End Function

'
Public Function WizVfiOpenEx(ByVal Hook As Byte, ByVal FileType As Long, ByVal Mode As Long, ByVal Path As String, Filter As WIZ_FILTER, ByRef HVfi As Long) As Integer

    Dim TempPath As String
    
    If Path = vbNullString Then
        TempPath = vbNullString
    Else
        TempPath = Trim(Path) & Chr(0)
    End If
    
    WizVfiOpenEx = WizVBVfiOpenEx(Hook, FileType, Mode, TempPath, Filter, HVfi)

End Function

'
Public Function Wiz5VfiRead(ByVal HVfi As Long, ByVal FileType As Long, ByRef pulRecs As Long, ByRef LrmBuffer() As VFI_LRM_OLD, ByRef HisBuffer() As VFI_HIS_OLD) As Integer

    If FileType = VFI_TYPE_HIS Then
       Wiz5VfiRead = Wiz5VfiReadHis(HVfi, pulRecs, HisBuffer())
    ElseIf FileType = VFI_TYPE_LRM Then
       Wiz5VfiRead = Wiz5VfiReadLrm(HVfi, pulRecs, LrmBuffer())
    Else: Wiz5VfiRead = WIZERR_BAD_TYPE
    End If
    
End Function

'
Public Function WizVfiReadEx(ByVal HVfi As Long, ByVal FileType As Long, ByRef pulRecs As Long, ByRef LrmBuffer() As VFI_LRM, ByRef HisBuffer() As VFI_HIS) As Integer

    If FileType = VFI_TYPE_HIS Then
       WizVfiReadEx = WizVfiReadHisEx(HVfi, pulRecs, HisBuffer())
    ElseIf FileType = VFI_TYPE_LRM Then
       WizVfiReadEx = WizVfiReadLrmEx(HVfi, pulRecs, LrmBuffer())
    Else: WizVfiReadEx = WIZERR_BAD_TYPE
    End If
    
End Function
'
Public Function Wiz5VfiReadLrm(ByVal HVfi As Long, ByRef pulRecs As Long, ByRef LrmBuffer() As VFI_LRM_OLD) As Integer
    Dim i           As Integer
    Dim CurrBuffPos As Long
  
    Dim Buffer  As String
    Buffer = String(pulRecs * VFI_LRM_LEN_OLD, " ")
    Buffer = Buffer & Chr(0)
    
    Wiz5VfiReadLrm = WizVBVfiReadLrm(HVfi, pulRecs, Buffer)
    
    '----------- copying info from Buffer to LrmBuffer ----------------
    CurrBuffPos = 1
    For i = 0 To pulRecs - 1
        
        LrmBuffer(i).StationId = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        LrmBuffer(i).StartTime = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).StartMilli = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        LrmBuffer(i).EndTime = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).EndMilli = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        LrmBuffer(i).AckTime = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).User = Mid(Buffer, CurrBuffPos, ALERT_ACKID_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + ALERT_ACKID_LEN
        
        LrmBuffer(i).Severity = CInt(CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE)))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).Class = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).Zone = CInt(CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE)))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
         
        LrmBuffer(i).Attr = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).Identity = Mid(Buffer, CurrBuffPos, WIZ_ALERT_IDEN_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALERT_IDEN_LEN
        
        LrmBuffer(i).Name = Mid(Buffer, CurrBuffPos, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALERT_NAME_LEN
        
        LrmBuffer(i).AlertText = Mid(Buffer, CurrBuffPos, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALERT_TEXT_LEN
        
        LrmBuffer(i).ComNo = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

    Next i
    
End Function
'
Public Function WizVfiReadLrmEx(ByVal HVfi As Long, ByRef pulRecs As Long, ByRef LrmBuffer() As VFI_LRM) As Integer
    Dim i           As Integer
    Dim CurrBuffPos As Long
  
    Dim Buffer  As String
    Buffer = String(pulRecs * VFI_LRM_LEN, " ")
    Buffer = Buffer & Chr(0)
    
    WizVfiReadLrmEx = WizVBVfiReadLrmEx(HVfi, pulRecs, Buffer)
    
    '----------- copying info from Buffer to LrmBuffer ----------------
    CurrBuffPos = 1
    For i = 0 To pulRecs - 1
        
        LrmBuffer(i).StationId = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        LrmBuffer(i).StartTime = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).StartMilli = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        LrmBuffer(i).EndTime = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).EndMilli = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        LrmBuffer(i).AckTime = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).User = Mid(Buffer, CurrBuffPos, ALERT_ACKID_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + ALERT_ACKID_LEN
        
        LrmBuffer(i).Severity = CInt(CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE)))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).Class = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        LrmBuffer(i).Zone = CInt(CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE)))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
         
        LrmBuffer(i).Attr = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).Identity = Mid(Buffer, CurrBuffPos, WIZ_ALERT_IDEN_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALERT_IDEN_LEN
        
        LrmBuffer(i).Name = Mid(Buffer, CurrBuffPos, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALERT_NAME_LEN
        
        LrmBuffer(i).AlertText = Mid(Buffer, CurrBuffPos, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALERT_TEXT_LEN
        
        LrmBuffer(i).ComNo = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).CommentId = Mid(Buffer, CurrBuffPos, UUID_STR_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + UUID_STR_LEN
        
        LrmBuffer(i).Path = Mid(Buffer, CurrBuffPos, ALARM_FULL_PATH_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + ALARM_FULL_PATH_LEN
        
        LrmBuffer(i).TimeStampState0 = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).UserNameState0 = Mid(Buffer, CurrBuffPos, ALERT_ACKID_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + ALERT_ACKID_LEN
        
        LrmBuffer(i).TimeStampState1 = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        LrmBuffer(i).UserNameState1 = Mid(Buffer, CurrBuffPos, ALERT_ACKID_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + ALERT_ACKID_LEN
        
        LrmBuffer(i).UserFieldList.Field0 = Mid(Buffer, CurrBuffPos, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALARM_USER_FIELD_LEN
        
        LrmBuffer(i).UserFieldList.Field1 = Mid(Buffer, CurrBuffPos, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALARM_USER_FIELD_LEN
        
        LrmBuffer(i).UserFieldList.Field2 = Mid(Buffer, CurrBuffPos, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALARM_USER_FIELD_LEN
        
        LrmBuffer(i).UserFieldList.Field3 = Mid(Buffer, CurrBuffPos, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALARM_USER_FIELD_LEN
        
        LrmBuffer(i).UserFieldList.Field4 = Mid(Buffer, CurrBuffPos, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + WIZ_ALARM_USER_FIELD_LEN
        
    Next i
    
End Function
'
Public Function Wiz5VfiReadHis(ByVal HVfi As Long, ByRef pulRecs As Long, ByRef HisBuffer() As VFI_HIS_OLD) As Integer
    Dim i       As Integer
    Dim CurrBuffPos As Long
  
    Dim Buffer  As String
    Buffer = String(pulRecs * VFI_HIS_LEN_OLD, " ")
    
    Wiz5VfiReadHis = WizVBVfiReadHis(HVfi, pulRecs, Buffer)
    
    '----------- copying info from HisBuffer to Buffer ----------------
    CurrBuffPos = 1
    For i = 0 To pulRecs - 1
        
        HisBuffer(i).GateID = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        HisBuffer(i).SecondsSince1970 = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        HisBuffer(i).MilliSeconds = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        HisBuffer(i).Flags = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        HisBuffer(i).DoubleValue = CDbl(Mid(Buffer, CurrBuffPos, WIZ_DOUBLE_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_DOUBLE_SIZE
        
        HisBuffer(i).StringValue = Mid(Buffer, CurrBuffPos, GATE_STRING_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + GATE_STRING_LEN_OLD

    Next i
    
    
End Function
'
Public Function WizVfiReadHisEx(ByVal HVfi As Long, ByRef pulRecs As Long, ByRef HisBuffer() As VFI_HIS) As Integer
    Dim i       As Integer
    Dim CurrBuffPos As Long
  
    Dim Buffer  As String
    Buffer = String(pulRecs * VFI_HIS_LEN, " ")
    
    WizVfiReadHisEx = WizVBVfiReadHisEx(HVfi, pulRecs, Buffer)
    
    '----------- copying info from HisBuffer to Buffer ----------------
    CurrBuffPos = 1
    For i = 0 To pulRecs - 1
        
        HisBuffer(i).GateID = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        
        HisBuffer(i).SecondsSince1970 = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE

        HisBuffer(i).MilliSeconds = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        HisBuffer(i).Flags = CInt(Mid(Buffer, CurrBuffPos, WIZ_INTEGER_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_INTEGER_SIZE
        
        HisBuffer(i).DoubleValue = CDbl(Mid(Buffer, CurrBuffPos, WIZ_DOUBLE_SIZE))
        CurrBuffPos = CurrBuffPos + WIZ_DOUBLE_SIZE
        
        HisBuffer(i).StringValue = Mid(Buffer, CurrBuffPos, GATE_STRING_LEN - 1) & Chr(0)
        CurrBuffPos = CurrBuffPos + GATE_STRING_LEN

    Next i
    
    
End Function
'
Public Function Wiz5VfiWrite(ByVal HVfi As Long, ByVal FileType As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef LrmBuffer() As VFI_LRM_OLD, ByRef HisBuffer() As VFI_HIS_OLD, ByRef pulRecNo As Long) As Integer

    If FileType = VFI_TYPE_HIS Then
       Wiz5VfiWrite = Wiz5VfiWriteHis(HVfi, StnId, ulRecs, HisBuffer(), pulRecNo)
    ElseIf FileType = VFI_TYPE_LRM Then
       Wiz5VfiWrite = Wiz5VfiWriteLrm(HVfi, StnId, ulRecs, LrmBuffer(), pulRecNo)
    Else: Wiz5VfiWrite = WIZERR_BAD_TYPE
    End If
    
End Function
'
Public Function WizVfiWriteEx(ByVal HVfi As Long, ByVal FileType As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef LrmBuffer() As VFI_LRM, ByRef HisBuffer() As VFI_HIS, ByRef pulRecNo As Long) As Integer

    If FileType = VFI_TYPE_HIS Then
       WizVfiWriteEx = WizVfiWriteHisEx(HVfi, StnId, ulRecs, HisBuffer(), pulRecNo)
    ElseIf FileType = VFI_TYPE_LRM Then
       WizVfiWriteEx = WizVfiWriteLrmEx(HVfi, StnId, ulRecs, LrmBuffer(), pulRecNo)
    Else: WizVfiWriteEx = WIZERR_BAD_TYPE
    End If
    
End Function

'
Public Function Wiz5VfiWriteLrm(ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef LrmBuffer() As VFI_LRM_OLD, ByRef pulRecNo As Long) As Integer
    Dim TempStr As String
    Dim i       As Integer
    
    Dim Buffer  As String
    
    
    Buffer = ""
    '-------------- filling char buffer with LrmBuffer info. -----------
    For i = 0 To ulRecs - 1
        
        TempStr = Trim(CStr(LrmBuffer(i).StationId)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).StartTime)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).StartMilli)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).EndTime)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).EndMilli)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).AckTime)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).User)) & Chr(0) & Space(ALERT_ACKID_LEN)
        Buffer = Buffer & Left(TempStr, ALERT_ACKID_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Severity)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Class)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Zone)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
         
        TempStr = Trim(CStr(LrmBuffer(i).Attr)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)

        TempStr = Trim(CStr(LrmBuffer(i).Identity)) & Chr(0) & Space(WIZ_ALERT_IDEN_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALERT_IDEN_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Name)) & Chr(0) & Space(WIZ_ALERT_NAME_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).AlertText)) & Chr(0) & Space(WIZ_ALERT_TEXT_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).ComNo)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)

    Next i
  
    Wiz5VfiWriteLrm = WizVBVfiWriteLrm(HVfi, StnId, ulRecs, Buffer, pulRecNo)
End Function

'
Public Function WizVfiWriteLrmEx(ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef LrmBuffer() As VFI_LRM, ByRef pulRecNo As Long) As Integer
    Dim TempStr As String
    Dim i       As Integer
    
    Dim Buffer  As String
    
    
    Buffer = ""
    '-------------- filling char buffer with LrmBuffer info. -----------
    For i = 0 To ulRecs - 1
        
        TempStr = Trim(CStr(LrmBuffer(i).StationId)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).StartTime)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).StartMilli)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).EndTime)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).EndMilli)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).AckTime)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).User)) & Chr(0) & Space(ALERT_ACKID_LEN)
        Buffer = Buffer & Left(TempStr, ALERT_ACKID_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Severity)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Class)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Zone)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
         
        TempStr = Trim(CStr(LrmBuffer(i).Attr)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)

        TempStr = Trim(CStr(LrmBuffer(i).Identity)) & Chr(0) & Space(WIZ_ALERT_IDEN_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALERT_IDEN_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Name)) & Chr(0) & Space(WIZ_ALERT_NAME_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).AlertText)) & Chr(0) & Space(WIZ_ALERT_TEXT_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALERT_TEXT_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).ComNo)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)

        TempStr = Trim(CStr(LrmBuffer(i).CommentId)) & Chr(0) & Space(UUID_STR_LEN)
        Buffer = Buffer & Left(TempStr, UUID_STR_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).Path)) & Chr(0) & Space(ALARM_FULL_PATH_LEN)
        Buffer = Buffer & Left(TempStr, ALARM_FULL_PATH_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).TimeStampState0)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)

        TempStr = Trim(CStr(LrmBuffer(i).UserNameState0)) & Chr(0) & Space(ALERT_ACKID_LEN)
        Buffer = Buffer & Left(TempStr, ALERT_ACKID_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).TimeStampState1)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)

        TempStr = Trim(CStr(LrmBuffer(i).UserNameState1)) & Chr(0) & Space(ALERT_ACKID_LEN)
        Buffer = Buffer & Left(TempStr, ALERT_ACKID_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).UserFieldList.Field0)) & Chr(0) & Space(WIZ_ALARM_USER_FIELD_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).UserFieldList.Field1)) & Chr(0) & Space(WIZ_ALARM_USER_FIELD_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).UserFieldList.Field2)) & Chr(0) & Space(WIZ_ALARM_USER_FIELD_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).UserFieldList.Field3)) & Chr(0) & Space(WIZ_ALARM_USER_FIELD_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        
        TempStr = Trim(CStr(LrmBuffer(i).UserFieldList.Field4)) & Chr(0) & Space(WIZ_ALARM_USER_FIELD_LEN)
        Buffer = Buffer & Left(TempStr, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
        
    Next i
  
    WizVfiWriteLrmEx = WizVBVfiWriteLrmEx(HVfi, StnId, ulRecs, Buffer, pulRecNo)
End Function

'
Public Function Wiz5VfiWriteHis(ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef HisBuffer() As VFI_HIS_OLD, ByRef pulRecNo As Long) As Integer
    Dim TempStr As String
    Dim i       As Integer
    
    Dim Buffer  As String
    
    
    Buffer = ""
    '-------------- filling char buffer with HisBuffer info. -----------
    For i = 0 To ulRecs - 1
        
        TempStr = Trim(CStr(HisBuffer(i).GateID)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).SecondsSince1970)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).MilliSeconds)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).Flags)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).DoubleValue)) & Chr(0) & Space(WIZ_DOUBLE_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_DOUBLE_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).StringValue)) & Chr(0) & Space(GATE_STRING_LEN)
        Buffer = Buffer & Left(TempStr, GATE_STRING_LEN_OLD - 1) & Chr(0)
        
    Next i
    
    Wiz5VfiWriteHis = WizVBVfiWriteHis(HVfi, StnId, ulRecs, Buffer, pulRecNo)
End Function

'
Public Function WizVfiWriteHisEx(ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef HisBuffer() As VFI_HIS, ByRef pulRecNo As Long) As Integer
    Dim TempStr As String
    Dim i       As Integer
    
    Dim Buffer  As String
    
    
    Buffer = ""
    '-------------- filling char buffer with HisBuffer info. -----------
    For i = 0 To ulRecs - 1
        
        TempStr = Trim(CStr(HisBuffer(i).GateID)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).SecondsSince1970)) & Chr(0) & Space(WIZ_LONG_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_LONG_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).MilliSeconds)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).Flags)) & Chr(0) & Space(WIZ_INTEGER_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_INTEGER_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).DoubleValue)) & Chr(0) & Space(WIZ_DOUBLE_SIZE)
        Buffer = Buffer & Left(TempStr, WIZ_DOUBLE_SIZE - 1) & Chr(0)
        
        TempStr = Trim(CStr(HisBuffer(i).StringValue)) & Chr(0) & Space(GATE_STRING_LEN)
        Buffer = Buffer & Left(TempStr, GATE_STRING_LEN - 1) & Chr(0)
        
    Next i
    
    WizVfiWriteHisEx = WizVBVfiWriteHisEx(HVfi, StnId, ulRecs, Buffer, pulRecNo)
End Function
'
Public Function Wiz5SetLayersStatus(ByVal Hook As Byte, ByVal VpID As Integer, ByVal LayersQuant As Integer, LayersList() As LAYER_STAT) As Integer

    Dim Layers  As String
    Dim TempStr As String
    Dim i       As Integer
  
    Layers = ""
    
    For i = 0 To LayersQuant - 1
        TempStr = Trim(CStr(LayersList(i).Att)) & Chr(0) & Space(WIZ_LAYER_STAT_ATT_SIZE)
        Layers = Layers & Left(TempStr, WIZ_LAYER_STAT_ATT_SIZE - 1) & Chr(0)
        TempStr = Trim(LayersList(i).Name) & Chr(0) & Space(WIZ_LAYER_STAT_NAME_SIZE)
        Layers = Layers & Left(TempStr, WIZ_LAYER_STAT_NAME_SIZE - 1) & Chr(0)
    Next

    Wiz5SetLayersStatus = WizVBSetLayersStatus(Hook, VpID, LayersQuant, Layers)

End Function

'
Public Function Wiz5LoginUser(ByVal Hook As Byte, ByVal UserName As String, ByVal Password As String) As Integer

    Dim UserName_ As String
    Dim Password_ As String

    UserName_ = Trim(UserName) & Chr(0)
    Password_ = Trim(Password) & Chr(0)
    
    Wiz5LoginUser = WizVBLoginUser(Hook, UserName_, Password_)

End Function



'
Public Function Wiz5RqAlertMsg(ByVal Hook As Byte, ByVal Operation As Integer, ByVal FamilyQuant As Long, FamilyList() As WIZ_ALERT_NAME, ByVal MinSeverity As Long, ByVal MaxSeverity As Long, ByVal Classes As Long, ByVal MinZone As Long, ByVal MaxZone As Long, ByVal StnQuant As Long, StantionList() As WIZ_STN_NAME) As Integer
    
    Dim FamList  As String
    Dim StnList  As String, TempStr As String
    Dim FamCount As Long
    Dim i        As Integer
  
    FamList = ""
    StnList = ""
    
    FamCount = FamilyQuant
      
    If FamilyQuant <> 0 Then
        FamCount = UBound(FamilyList)
        For i = 0 To FamCount - 1
            TempStr = Trim(FamilyList(i).Alert_Name) & Chr(0) & Space(WIZ_ALERT_NAME_LEN)
            FamList = FamList & Mid(TempStr, 1, WIZ_ALERT_NAME_LEN - 1) & Chr(0)
        Next i
    Else
        FamCount = 0
    End If
    
    For i = 0 To StnQuant - 1
        TempStr = Trim(StantionList(i).Stn_Name) & Chr(0) & Space(STNPART_NAME_LEN)
        StnList = StnList & Mid(TempStr, 1, STNPART_NAME_LEN - 1) & Chr(0)
    Next i
    
    Wiz5RqAlertMsg = WizVBRqAlertMsg(Hook, Operation, FamCount, FamList, MinSeverity, MaxSeverity, Classes, MinZone, MaxZone, StnQuant, StnList)
   
End Function

'
Public Function Wiz5GetMsg(ByVal Hook As Byte, ByRef MsgType As Integer, ByRef Msg As WIZ_MSG_Internal) As Integer
     Wiz5GetMsg = WizVBGetMsg(Hook, MsgType, Msg)
End Function

'
Public Function Wiz5SetPrinter(ByVal Hook As Byte, ByVal Type_ As Integer, ByVal Printer As String) As Integer
    
    Dim NewDevice As String * DEVICE_BUFFER
    NewDevice = Trim(Printer) & Chr(0)

    Wiz5SetPrinter = WizVBSetPrinter(Hook, Type_, NewDevice)

End Function
'
Public Function Wiz5SetAnnFilter(ByVal Hook As Byte, ByVal VpID As Integer, ByVal MinSeverity As Integer, ByVal MaxSeverity As Integer, FamilyList As String, ByVal MinZone As Integer, ByVal MaxZone As Integer, ByVal Class As Long, ByVal StnQuant As Long, StantionList() As WIZ_STN_NAME) As Integer
 
    Dim FamList  As String
    Dim StnList  As String, TempStr As String
    Dim i        As Integer
  
    FamList = ""
    StnList = ""
     
    For i = 0 To StnQuant - 1
        TempStr = Trim(StantionList(i).Stn_Name) & Chr(0) & Space(STNPART_NAME_LEN)
        StnList = StnList & Mid(TempStr, 1, STNPART_NAME_LEN - 1) & Chr(0)
    Next i


    If FamilyList = vbNullString Then
        Wiz5SetAnnFilter = WizVBSetAnnFilter(Hook, VpID, MinSeverity, MaxSeverity, vbNullString, MinZone, MaxZone, Class, StnList, StnQuant)
    Else
        FamList = Trim(FamilyList) & Chr(0)
        Wiz5SetAnnFilter = WizVBSetAnnFilter(Hook, VpID, MinSeverity, MaxSeverity, FamList, MinZone, MaxZone, Class, StnList, StnQuant)
    End If
    
End Function

'
Public Function Wiz5QueryLayout(ByVal Hook As Byte, ByRef LayName As String, VpList() As WIZ_VP_ENTRY, ByRef VpCount As Integer) As Integer

    Dim ViewPortList As String
    Dim i  As Integer, Rc As Integer, UnitSize As Integer
    Dim LayoutName As String * FILE_LEN
  
    UnitSize = WIZ_VP_ENTRY_VPID_SIZE + WIZ_VP_ENTRY_TYPE_SIZE + FILE_LEN
    ViewPortList = String(WIZ_MAX_VPS * UnitSize, Chr(32))
    
    Rc = WizVBQueryLayout(Hook, LayoutName, ViewPortList, VpCount)
    
    If Rc = WIZ_NO_ERR Then
        i = 0
        Do While i < VpCount
           VpList(i).VpID = CInt(Mid(ViewPortList, i * UnitSize + 1, WIZ_VP_ENTRY_VPID_SIZE))    '17/1/99 Gilat Tiram changet to "UnitSize + 1" instead of  "UnitSize"
           VpList(i).Type = CByte(Mid(ViewPortList, i * UnitSize + 1 + WIZ_VP_ENTRY_VPID_SIZE, WIZ_VP_ENTRY_TYPE_SIZE))
           VpList(i).VpName = Mid(ViewPortList, i * UnitSize + 1 + WIZ_VP_ENTRY_VPID_SIZE + WIZ_VP_ENTRY_TYPE_SIZE, FILE_LEN)
            i = i + 1
        Loop
        LayName = LayoutName
    End If

    Wiz5QueryLayout = Rc

End Function

'
Public Function Wiz5LoadLayout(ByVal Hook As Byte, ByVal LayName As String, ByVal Wait As Integer, VpList() As WIZ_VP_ENTRY, ByRef VpCount As Integer) As Integer

    Dim ViewPortList As String
    Dim Lay_Name     As String
    Dim i  As Integer, Rc As Integer, UnitSize As Integer
  
    Lay_Name = Trim(LayName) & Chr(0)
  
    UnitSize = 6 + 3 + FILE_LEN
    ViewPortList = String(WIZ_MAX_VPS * UnitSize, Chr(32))
    
    Rc = WizVBLoadLayout(Hook, Lay_Name, Wait, ViewPortList, VpCount)
    
    If Rc = WIZ_NO_ERR Then
        i = 0
        ReDim VpList(VpCount)   ' Resize the array
        Do While i < VpCount
            VpList(i).VpID = CInt(Mid(ViewPortList, i * UnitSize + 1, WIZ_VP_ENTRY_VPID_SIZE))
            VpList(i).Type = CByte(Mid(ViewPortList, i * UnitSize + 1 + WIZ_VP_ENTRY_VPID_SIZE, WIZ_VP_ENTRY_TYPE_SIZE))
            VpList(i).VpName = Mid(ViewPortList, i * UnitSize + 1 + 9, FILE_LEN)
            i = i + 1
        Loop
    End If

    Wiz5LoadLayout = Rc

End Function

'
Public Function Wiz5CloseLayout(ByVal Hook As Byte, ByVal PromptToSave As Boolean) As Integer

    Wiz5CloseLayout = WizVBCloseLayout(Hook, CLng(PromptToSave))

End Function




'
Public Function Wiz5SetFilePath(ByVal FileType As Integer, ByVal NewPath As String) As Integer

    Dim Buffer As String * PATH_LEN
    Buffer = Trim(NewPath) & Chr(0)

    Wiz5SetFilePath = WizVBSetFilePath(FileType, Buffer)

End Function
'
Public Function Wiz5GetFilePathSufix(ByVal FileType As Integer, ByRef Path As String, ByRef Suffix As String) As Integer

    Dim Temp1   As String * PATH_LEN      ' Full path directory location
    Dim Temp2   As String * SUFIX_LEN     ' File extension of the file type
    Dim Rc      As Integer
    
    Temp1 = Temp2 = " "
    
    Rc = WizVBGetFilePathSuffix(FileType, Temp1, Temp2)
    
    If Rc = WIZ_NO_ERR Then
        Path = Temp1
        Suffix = Temp2
    End If
    
    Wiz5GetFilePathSufix = Rc
    
End Function



'
Public Function Wiz5AckClassAlert(ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewClass As Long, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String) As Integer

    Dim Ack As String
    Ack = Trim(AckId) & Chr(0)
    Wiz5AckClassAlert = WizVBAckClassAlert(Hook, AlertId, NewClass, Seconds, MilliSec, Ack)

End Function



'
Public Function WizAckClassAlertWithAcknowledge(ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewClass As Long, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String, ByRef Groups As WIZ_GROUP) As Integer
 
    Dim Ack As String
    Ack = Trim(AckId) & Chr(0)
    WizAckClassAlertWithAcknowledge = WizVBAckClassAlertWithAcknowledge(Hook, AlertId, NewClass, Seconds, MilliSec, Ack, Groups)

End Function


'
' The API prints text through a previously started printing session.
'
Public Function Wiz5PrintText(ByVal Hook As Byte, ByVal JobHandle As Long, ByVal PrtText As String) As Integer

    Dim Buffer As String
    Buffer = RTrim(PrtText) & Chr(0)

    Wiz5PrintText = WizVBPrintText(Hook, JobHandle, Buffer)

End Function

'
Public Function Wiz5GetPrinterStatus(ByVal Hook As Byte, ByVal Device As String, ByRef DevStatus As Integer) As Integer

    Dim Rc      As Integer
    Dim Buffer  As String * DEVICE_BUFFER
    Buffer = Trim(Device) & Chr(0)
    
    Wiz5GetPrinterStatus = WizVBGetPrinterStatus(Hook, Buffer, DevStatus)
    
End Function

'
' The API retrieves the destination device to which a specific WizPro printer is redirected.
'
Public Function Wiz5GetPrinter(ByVal Hook As Byte, ByVal Type_ As Integer, ByRef Printer As String) As Integer
    
    Dim Rc As Integer
    Dim Device As String * DEVICE_BUFFER
    Device = ""
    
    Rc = WizVBSetPrinter(Hook, Type_, Device)
    
    If Rc = WIZ_NO_ERR Then
        Printer = Device
    End If
    
    Wiz5GetPrinter = Rc

End Function

'
' The APIs reads/writes a RAW value
'
Public Function Wiz5GetGateRawValue(ByVal Hook As Byte, ByVal GateID As Long, ByRef RawValue As WIZ_PLC_DATA, ByVal Sample As Integer) As Integer
    Dim Rc As Integer
    Dim RawData As WIZ_PLC_DATA
    
    Rc = WizVBGetGateRawValue(Hook, GateID, RawData, Sample)
    If Rc = WIZ_NO_ERR Then
        RawValue = RawData
    End If

    Wiz5GetGateRawValue = Rc
End Function


Public Function Wiz5PutGateRawValue(ByVal Hook As Byte, ByVal GateID As Long, ByRef RawValue As WIZ_PLC_DATA, ByVal CommErr As Integer, ByVal Mode As Integer, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
   
    Wiz5PutGateRawValue = WizVBPutGateRawValue(Hook, GateID, RawValue, CommErr, Mode, Seconds, MiliSec)

End Function

'
' The API reads a block of data from a specific VPI
'
Public Function Wiz5ReadBlock(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockAddr As String, ByVal Length As Integer, ByRef BlockData As String, ByRef TimeStamps() As Long) As Integer

    Dim i       As Integer
    Dim CurrBuffPos As Long
    Dim Buffer  As String
    Buffer = String(Length * 2 * WIZ_LONG_SIZE, " ")
    Buffer = Buffer & Chr(0)
    
    Dim Address As String * GATE_ADDRESS_LEN
    Address = Mid(Trim(BlockAddr), 1, Len(Address) - 1) & Chr(0)
    Dim Block As String
    
    Block = String(Length * 4, " ")
    Block = Block & Chr(0)
    
    Dim Rc As Integer

    Rc = WizVBReadBlock(Hook, VpiNum, Address, Length, Block, Buffer)
       
    If Rc = WIZ_NO_ERR Then
        BlockData = Block
        CurrBuffPos = 1
        For i = 0 To Length * 2 - 1
            TimeStamps(i) = CLng(Mid(Buffer, CurrBuffPos, WIZ_LONG_SIZE))
            CurrBuffPos = CurrBuffPos + WIZ_LONG_SIZE
        Next i
    End If
    
    Wiz5ReadBlock = Rc

End Function

'
Public Function Wiz5WriteBlock(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal StartAddr As String, ByVal Length As Integer, ByVal BlockData As String) As Integer

    Dim Address As String * GATE_ADDRESS_LEN
    Address = Mid(Trim(StartAddr), 1, Len(Address) - 1) & Chr(0)

    Wiz5WriteBlock = WizVBWriteBlock(Hook, VpiNum, Address, Length, BlockData)

End Function
'
Public Function Wiz5GetVpiPort(ByVal Hook As Byte, ByVal VpiNum As Byte, ByRef PortName As String) As Integer
    
    Dim Rc      As Integer
    Dim Buffer  As String * BUFFER_SIZE
    Buffer = ""
    
    Rc = WizVBGetVpiPort(Hook, VpiNum, Buffer)
    
    If Rc = WIZ_NO_ERR Then
        PortName = Buffer
    End If
    
    Wiz5GetVpiPort = Rc

End Function


'
Public Function Wiz5SetVpiPort(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal NewPortName As String) As Integer
    
    Dim PortName  As String
    PortName = Trim(NewPortName) & Chr(0)
    Wiz5SetVpiPort = WizVBSetVpiPort(Hook, VpiNum, PortName)
    
End Function

'
Public Function Wiz5ParseBlock(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockAddr As String, ByVal BlockLen As Integer) As Integer

    Dim BlockAddress As String * GATE_ADDRESS_LEN
    BlockAddress = Mid(Trim(BlockAddr), 1, Len(BlockAddress) - 1) & Chr(0)

    Wiz5ParseBlock = WizVBParseBlock(Hook, VpiNum, BlockAddress, BlockLen)

End Function


'
Public Function Wiz5ParseGate(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal GateAddr As String, ByVal GateType As Integer, ByVal Mode As Integer, ByVal GateFormat As Integer) As Integer
   
    Dim GateAddress As String * GATE_ADDRESS_LEN
    GateAddress = Mid(Trim(GateAddr), 1, Len(GateAddress) - 1) & Chr(0)
   
    Wiz5ParseGate = WizVBParseGate(Hook, VpiNum, GateAddress, GateType, Mode, GateFormat)

End Function

'
' The API modifies the text which is attached to an alert
'
Public Function Wiz5SetAlertText(ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewText As String) As Integer

    Dim AlertText As String
    AlertText = Trim(NewText) & Chr(0)
    Wiz5SetAlertText = WizVBSetAlertText(Hook, AlertId, AlertText)

End Function

'
' The API modifies an alert's status.
'
Public Function Wiz5StampAlert(ByVal Hook As Byte, ByVal AlertQuant As Long, ByRef alertList() As Long, ByVal NewStatus As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String) As Integer

    Dim Ack         As String
    Dim Alert_List  As String, TempStr As String

    Alert_List = ""
     
    For i = 0 To AlertQuant - 1
        TempStr = Trim(CStr(alertList(i))) & Chr(0) & Space(WIZ_ALERT_ID_SIZE)
        Alert_List = Alert_List & Mid(TempStr, 1, WIZ_ALERT_ID_SIZE - 1) & Chr(0)
    Next i

    If AckId = vbNullString Then
        Wiz5StampAlert = WizVBStampAlert(Hook, AlertQuant, Alert_List, NewStatus, Seconds, MilliSec, vbNullString)
    Else
        Ack = Trim(AckId) & Chr(0)
        Wiz5StampAlert = WizVBStampAlert(Hook, AlertQuant, Alert_List, NewStatus, Seconds, MilliSec, Ack)
    End If

End Function

'
Public Function WizStampAlertWithAcknowledge(ByVal Hook As Byte, ByVal AlertQuant As Long, ByRef alertList() As Long, ByVal NewStatus As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String, ByRef Groups As WIZ_GROUP) As Integer

    Dim Ack         As String
    Dim Alert_List  As String, TempStr As String

    Alert_List = ""
     
    For i = 0 To AlertQuant - 1
        TempStr = Trim(CStr(alertList(i))) & Chr(0) & Space(WIZ_ALERT_ID_SIZE)
        Alert_List = Alert_List & Mid(TempStr, 1, WIZ_ALERT_ID_SIZE - 1) & Chr(0)
    Next i

    If AckId = vbNullString Then
        WizStampAlertWithAcknowledge = WizVBStampAlertWithAcknowledge(Hook, AlertQuant, Alert_List, NewStatus, Seconds, MilliSec, vbNullString, Groups)
    Else
        Ack = Trim(AckId) & Chr(0)
        WizStampAlertWithAcknowledge = WizVBStampAlertWithAcknowledge(Hook, AlertQuant, Alert_List, NewStatus, Seconds, MilliSec, Ack, Groups)
    End If

End Function

 
'
Public Function Wiz5StartAlert(ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertId As Long) As Integer

    Dim Fam       As String * WIZ_ALERT_NAME_LEN
    Dim AlertText As String * WIZ_ALERT_TEXT_LEN
    Dim Info As String
  
    Fam = Mid(Trim(Family), 1, Len(Fam) - 1) & Chr(0)
    AlertText = Mid(Trim(Alert_Text), 1, Len(AlertText) - 1) & Chr(0)

    If InfoFile = vbNullString Then
        Wiz5StartAlert = WizVBStartAlert(Hook, Fam, AlertText, Severity, Class, Zone, vbNullString, Attributes, Seconds, MilliSec, AlertEvent, ComNo, AlertId)
    Else
        Info = Trim(InfoFile) & Chr(0)
        Wiz5StartAlert = WizVBStartAlert(Hook, Fam, AlertText, Severity, Class, Zone, Info, Attributes, Seconds, MilliSec, AlertEvent, ComNo, AlertId)
    End If


End Function

 
'
Public Function WizStartAlertWithGroup(ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertId As Long, ByRef AlertEx As WIZ_ALERT2, ByRef Groups As WIZ_GROUP) As Integer
    
    Dim Fam       As String * WIZ_ALERT_NAME_LEN
    Dim AlertText As String * WIZ_ALERT_TEXT_LEN
    Dim Info As String
  
    Fam = Mid(Trim(Family), 1, Len(Fam) - 1) & Chr(0)
    AlertText = Mid(Trim(Alert_Text), 1, Len(AlertText) - 1) & Chr(0)

    If InfoFile = vbNullString Then
        WizStartAlertWithGroup = WizVBStartAlertWithGroup(Hook, Fam, AlertText, Severity, Class, Zone, vbNullString, Attributes, Seconds, MilliSec, AlertEvent, ComNo, AlertId, AlertEx, Groups)
    Else
        Info = Trim(InfoFile) & Chr(0)
        WizStartAlertWithGroup = WizVBStartAlertWithGroup(Hook, Fam, AlertText, Severity, Class, Zone, Info, Attributes, Seconds, MilliSec, AlertEvent, ComNo, AlertId, AlertEx, Groups)
    End If


End Function

 
'
Public Function WizStartAlertWithLevel(ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertEx As WIZ_ALERT2, ByRef Groups As WIZ_GROUP, ByVal LevelId As Long, ByRef AamData As WIZ_AAM_DATA, ByVal ImageName As String, ByVal ZoneName As String, ByRef AlertId As Long) As Integer
    
    Dim Fam       As String * WIZ_ALERT_NAME_LEN
    Dim AlertText As String * WIZ_ALERT_TEXT_LEN
    Dim Info As String
    Dim ImName As String
    Dim ZonName As String
    Dim AamDataTmp As WIZ_AAM_DATA
  
    Fam = Mid(Trim(Family), 1, Len(Fam) - 1) & Chr(0)
    AlertText = Mid(Trim(Alert_Text), 1, Len(AlertText) - 1) & Chr(0)

    Info = vbNullString
    If InfoFile <> vbNullString Then
        Info = Trim(InfoFile) & Chr(0)
    End If
    ImName = vbNullString
    If ImageName <> vbNullString Then
        ImName = Trim(ImageName) & Chr(0)
    End If
    ZonName = vbNullString
    If ZoneName <> vbNullString Then
        ZonName = Trim(ZoneName) & Chr(0)
    End If
    AamDataTmp.File = vbNullString
    If AamData.File <> vbNullString Then
        AamDataTmp.File = Mid(RTrim(AamData.File) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    End If
    AamDataTmp.VoiceFile = vbNullString
    If AamData.VoiceFile <> vbNullString Then
        AamDataTmp.VoiceFile = Mid(RTrim(AamData.VoiceFile) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    End If
    
    WizStartAlertWithLevel = WizVBStartAlertWithLevel(Hook, Fam, AlertText, Severity, Class, Zone, Info, Attributes, _
        Seconds, MilliSec, AlertEvent, ComNo, AlertEx, Groups, LevelId, AamDataTmp, ImName, ZonName, AlertId)

End Function

 
'
Public Function WizStartAlarm(ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertEx As WIZ_ALERT2, ByRef Groups As WIZ_GROUP, ByVal LevelId As Long, ByRef AamData As WIZ_AAM_DATA, ByVal ImageName As String, ByVal ZoneName As String, ByVal UserFieldCount As Integer, ByRef UserFields As WIZ_ALARM_USER_FIELD_LIST, ByRef AlertId As Long) As Integer
    
    Dim Fam       As String * WIZ_ALERT_NAME_LEN
    Dim AlertText As String * WIZ_ALERT_TEXT_LEN
    Dim Info As String
    Dim ImName As String
    Dim ZonName As String
    Dim AamDataTmp As WIZ_AAM_DATA
    Dim UserFieldsTmp As WIZ_ALARM_USER_FIELD_LIST
  
    Fam = Mid(Trim(Family), 1, Len(Fam) - 1) & Chr(0)
    AlertText = Mid(Trim(Alert_Text), 1, Len(AlertText) - 1) & Chr(0)

    Info = vbNullString
    If InfoFile <> vbNullString Then
        Info = Trim(InfoFile) & Chr(0)
    End If
    ImName = vbNullString
    If ImageName <> vbNullString Then
        ImName = Trim(ImageName) & Chr(0)
    End If
    ZonName = vbNullString
    If ZoneName <> vbNullString Then
        ZonName = Trim(ZoneName) & Chr(0)
    End If
    AamDataTmp.File = vbNullString
    If AamData.File <> vbNullString Then
        AamDataTmp.File = Mid(RTrim(AamData.File) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    End If
    AamDataTmp.VoiceFile = vbNullString
    If AamData.VoiceFile <> vbNullString Then
        AamDataTmp.VoiceFile = Mid(RTrim(AamData.VoiceFile) & Chr(0), 1, PATH_LEN - 1) & Chr(0)
    End If
    UserFieldsTmp.Field0 = vbNullString
    If UserFields.Field0 <> vbNullString Then
        UserFieldsTmp.Field0 = Mid(RTrim(UserFields.Field0) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    End If
    UserFieldsTmp.Field1 = vbNullString
    If UserFields.Field1 <> vbNullString Then
        UserFieldsTmp.Field1 = Mid(RTrim(UserFields.Field1) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    End If
    UserFieldsTmp.Field2 = vbNullString
    If UserFields.Field2 <> vbNullString Then
        UserFieldsTmp.Field2 = Mid(RTrim(UserFields.Field2) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    End If
    UserFieldsTmp.Field3 = vbNullString
    If UserFields.Field3 <> vbNullString Then
        UserFieldsTmp.Field3 = Mid(RTrim(UserFields.Field3) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    End If
    UserFieldsTmp.Field4 = vbNullString
    If UserFields.Field4 <> vbNullString Then
        UserFieldsTmp.Field4 = Mid(RTrim(UserFields.Field4) & Chr(0), 1, WIZ_ALARM_USER_FIELD_LEN - 1) & Chr(0)
    End If
    
    WizStartAlarm = WizVBStartAlarm(Hook, Fam, AlertText, Severity, Class, Zone, Info, Attributes, _
        Seconds, MilliSec, AlertEvent, ComNo, AlertEx, Groups, LevelId, AamDataTmp, ImName, ZonName, UserFieldCount, UserFieldsTmp, AlertId)

End Function

'
Public Function Wiz5GetGateByNameIndex(ByVal Hook As Byte, ByVal NameIndex As Integer, ByRef GateName As String, ByRef GateID As Long) As Integer

    Dim Buffer As String * GT_NAME_LEN
    Dim Rc As Integer
    GateName = String(GT_NAME_LEN, " ")
    Rc = WizVBGetGateByNameIndex(Hook, NameIndex, Buffer, GateID)
    If Rc = WIZ_NO_ERR Then
        GateName = Buffer
    End If
    Wiz5GetGateByNameIndex = Rc
    
End Function

'
Public Function WizTagValueUnlock(ByVal Hook As Byte, ByVal TagID As Long, ByVal UserName As String) As Integer
    Dim User As String
    Dim Rc As Integer

    User = Trim(UserName) & Chr(0)
    
    Rc = WizVBTagValueUnlock(Hook, TagID, User)
    WizTagValueUnlock = Rc
    
End Function

'
Public Function WizTagValueLock(ByVal Hook As Byte, ByVal TagID As Long, ByVal timeToUnlock As String, ByRef TagLockVal As WIZ_TAG_LOCK_VAL, ByVal UserName As String) As Integer
    Dim Temp As WIZ_TAG_LOCK_VAL
    Temp = TagLockVal
    Dim User As String
    Dim Time As String
    Dim Rc As Integer

    Temp.StringValue = Trim(TagLockVal.StringValue) & Chr(0)
    User = Trim(UserName) & Chr(0)
    Time = Trim(timeToUnlock) & Chr(0)
    
    Rc = WizVBTagValueLock(Hook, TagID, Time, Temp, User)
    WizTagValueLock = Rc
    
End Function
'


Public Function WizUMGetUserGroups(ByVal Hook As Byte, ByVal UserName As String, ByRef GroupList As Variant, ByRef nCount As Long, ByRef nTotal As Long) As Integer
    Dim User As String
    Dim GroupBuf As String * MAX_GROUP_BUF
    Dim Rc As Integer

    User = Trim(UserName) & Chr(0)
    
    Rc = WizVBUMGetUserGroups(Hook, User, GroupBuf, nCount, nTotal)

    For i = 0 To 99
      GroupList(i) = Mid(Trim(GroupBuf), 1 + MAX_GROUP_NAME_SIZE * i, MAX_GROUP_NAME_SIZE - 1) & Chr(0)
    Next
    
    WizUMGetUserGroups = Rc
    
End Function
'
Public Function WizUMVerifyUser(ByVal Hook As Byte, ByVal UserName As String, ByVal Passwd As String) As Integer
    Dim User As String
    Dim Password As String
    Dim Rc As Integer

    User = Trim(UserName) & Chr(0)
    Password = Trim(Passwd) & Chr(0)
    
    Rc = WizVBUMVerifyUser(Hook, User, Password)
    WizUMVerifyUser = Rc
    
End Function
'
Public Function WizUMVerifywebUser(ByVal Hook As Byte, ByVal UserName As String, ByVal Passwd As String) As Integer
    Dim User As String
    Dim Password As String
    Dim Rc As Integer

    User = Trim(UserName) & Chr(0)
    Password = Trim(Passwd) & Chr(0)
    
    Rc = WizVBUMVerifyWebUser(Hook, User, Password)
    WizUMVerifywebUser = Rc
    
End Function

'
Public Function Wiz5SaveRecipe(ByVal Hook As Byte, ByVal RcpFileName As String, ByVal RcpDescription As String) As Integer
    
    Dim FileName    As String
    Dim Description As String
    
    FileName = Trim(RcpFileName) & Chr(0)
    Description = Trim(RcpDescription) & Chr(0)
    
    Wiz5SaveRecipe = WizVBSaveRecipe(Hook, FileName, Description)

End Function

'
Public Function Wiz5PutGateStr(ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As String, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer

    Dim New_Gate_Contents As String
    
    New_Gate_Contents = Trim(GateVal) & Chr(0)
    Wiz5PutGateStr = WizVBPutGateStr(Hook, GateID, Mode, New_Gate_Contents, Seconds, MiliSec)

End Function

'
Public Function Wiz5GetGateStr(ByVal Hook As Byte, ByVal Mode As Integer, ByVal GateID As Long, ByRef GateVal As String, ByRef Seconds As Long, ByRef MiliSec As Integer) As Integer

    Dim Buffer As String * GATE_STRING_LEN
    Buffer = ""
    Wiz5GetGateStr = WizVBGetGateStr(Hook, Mode, GateID, Buffer, Seconds, MiliSec)
    
    GateVal = Buffer

End Function


'
Public Function Wiz5GateForceLogEx(ByVal Hook As Byte, ByVal GateID As Long, ByVal Value As Double, ByVal GateVal As String, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer

    Dim New_Gate_Contents As String
    
    New_Gate_Contents = Trim(GateVal) & Chr(0)
    Wiz5GateForceLogEx = WizVBGateForceLogEx(Hook, GateID, Value, New_Gate_Contents, Seconds, MiliSec)

End Function

'


'
Public Function Wiz5GetGateName(ByVal Hook As Byte, ByVal GateID As Long, ByRef GateName As String) As Integer

    Dim Gate_Name As WIZ_GT_NAME

    Wiz5GetGateName = WizVBGetGateName(Hook, GateID, Gate_Name.GateName)
    GateName = Mid(Trim(Gate_Name.GateName), 1, Len(Gate_Name) - 1) & Chr(0)

End Function




'
Public Function Wiz5GetGateIdByAddressStr(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal AddressStr As String, ByRef GateID As Long) As Integer

    Dim Address As WIZ_GT_ADDR
    Address.GateAddr = Mid(Trim(AddressStr), 1, Len(Address) - 1) & Chr(0)
    Wiz5GetGateIdByAddressStr = WizVBGetGateIdByAddressStr(Hook, VpiNum, Address.GateAddr, GateID)

End Function


'
Public Function Wiz5GetGateId(ByVal Hook As Byte, ByVal GateName As String, ByRef GateID As Long) As Integer

    Dim Gate_Name As WIZ_GT_NAME
    Gate_Name.GateName = Mid(Trim(GateName), 1, Len(Gate_Name) - 1) & Chr(0)
    Wiz5GetGateId = WizVBGetGateId(Hook, Gate_Name.GateName, GateID)

End Function


'
Public Function Wiz5GetFileName(ByVal FileType As Integer, ByVal FileName As String, ByRef FullPath As String) As Integer

    Dim Rc   As Integer
    Dim File As WIZ_FILE_NAME
    Dim Path As String * PATH_LEN

    Path = " "
    File.FileName = Mid(Trim(FileName), 1, Len(File) - 1) & Chr(0)
    Rc = WizVBGetFileName(FileType, File.FileName, Path)
    
    If Rc = WIZ_NO_ERR Then
        FullPath = Path
    End If

    Wiz5GetFileName = Rc

End Function



'
Public Function Wiz5GetHook(ByVal Hook As Byte, ByVal OtherClient As String, ByRef OtherHook As Byte) As Integer
 
    Dim OtherClient_ As String
    OtherClient_ = Trim(OtherClient) & Chr(0)

    Wiz5GetHook = WizVBGetHook(Hook, OtherClient_, OtherHook)

End Function



'
Public Function Wiz5MkClient(ByVal Name As String, ByVal Type_Client As Long, ByVal hWnd As Long, ByRef Hook As Byte) As Integer

    Dim ClientName As String

    ClientName = Trim(Name) & Chr(0)
    Wiz5MkClient = WizVBMkClient(ClientName, Type_Client, hWnd, Hook)

End Function
'
Public Function Wiz5GetGateDef(ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF) As Integer

    Wiz5GetGateDef = WizVBGetGateDef(Hook, GateID, GateDef)

End Function
'
Public Function WizGetTagDef(ByVal Hook As Byte, ByVal TagID As Long, TagDef As WIZ_TAG_DEF) As Integer

    WizGetTagDef = WizVBGetTagDef(Hook, TagID, TagDef)

End Function


'=============================================================
' ------------------------------------------------------------------
' Alias names of API functions for Visual Basic.
' All Wiz5 functions can be called with Wiz prefix.
' ------------------------------------------------------------------

' IPC functions

  Public Function WizMkClient(ByVal Name As String, ByVal Type_Client As Long, ByVal hWnd As Long, ByRef Hook As Byte) As Integer
    WizMkClient = Wiz5MkClient(Name, Type_Client, hWnd, Hook)
  End Function
  Public Function WizRmClient(ByVal Hook As Byte) As Integer
    WizRmClient = Wiz5RmClient(Hook)
  End Function
  Public Function WizKillDelay(ByVal Hook As Byte, ByVal Delay As Integer) As Integer
    WizKillDelay = Wiz5KillDelay(Hook, Delay)
  End Function
  Public Function WizClearMsgQueue(ByVal Hook As Byte) As Integer
    WizClearMsgQueue = Wiz5ClearMsgQueue(Hook)
  End Function
  Public Function WizGetHook(ByVal Hook As Byte, ByVal OtherClient As String, ByRef OtherHook As Byte) As Integer
    WizGetHook = Wiz5GetHook(Hook, OtherClient, OtherHook)
  End Function
  Public Function WizGetClientPID(ByVal Hook As Byte, ByVal OtherHook As Byte, ByRef PID As Long, ByRef TID As Long) As Integer
    WizGetClientPID = Wiz5GetClientPID(Hook, OtherHook, PID, TID)
  End Function
  Public Function WizPostMsg(ByVal Hook As Byte, ByVal OtherHook As Byte, ByRef Msg As WIZ_MSG_Internal) As Integer
    WizPostMsg = Wiz5PostMsg(Hook, OtherHook, Msg)
  End Function
  Public Function WizSendMsg(ByVal Hook As Byte, ByVal OtherHook As Byte, ByRef Msg As WIZ_MSG_Internal, ByVal TimeOut As Long) As Integer
    WizSendMsg = Wiz5SendMsg(Hook, OtherHook, Msg, TimeOut)
  End Function
  Public Function WizSendBuf(ByVal Hook As Byte, ByVal OtherHook As Byte, ByVal MsgType As Integer, ByVal Buffer As String, ByVal BufLen As Integer) As Integer
    WizSendBuf = Wiz5SendBuf(Hook, OtherHook, MsgType, Buffer, BufLen)
  End Function
  Public Function WizPostBuf(ByVal Hook As Byte, ByVal OtherHook As Byte, ByVal MsgType As Integer, ByVal Buffer As String, ByVal BufLen As Integer) As Integer
    WizPostBuf = Wiz5PostBuf(Hook, OtherHook, MsgType, Buffer, BufLen)
  End Function

' Gate data functions

  Public Function WizGetGateCount(ByVal Hook As Byte, ByRef TotalGates As Long, ByRef UnDelGates As Long, ByRef PLCGates As Long, ByRef CompaundGates As Long) As Integer
    WizGetGateCount = Wiz5GetGateCount(Hook, TotalGates, UnDelGates, PLCGates, CompaundGates)
  End Function
  Public Function WizGetGateId(ByVal Hook As Byte, ByVal GateName As String, ByRef GateID As Long) As Integer
    WizGetGateId = Wiz5GetGateId(Hook, GateName, GateID)
  End Function
  Public Function WizGetGateIdByAddress(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal plcAddr As Long, ByVal MemoryType As Long, ByVal GateAddr As Long, ByVal BitNumber As Long, ByRef GateID As Long) As Integer
    WizGetGateIdByAddress = Wiz5GetGateIdByAddress(Hook, VpiNum, plcAddr, MemoryType, GateAddr, BitNumber, GateID)
  End Function
  Public Function WizGetGateIdByAddressStr(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal AddressStr As String, ByRef GateID As Long) As Integer
    WizGetGateIdByAddressStr = Wiz5GetGateIdByAddressStr(Hook, VpiNum, AddressStr, GateID)
  End Function
  Public Function WizRqGateMsg(ByVal Hook As Byte, ByVal GateAmount As Long, ByRef GateList As Long, ByVal Mode As Long) As Integer
    WizRqGateMsg = Wiz5RqGateMsg(Hook, GateAmount, GateList, Mode)
  End Function
  Public Function WizGetGateByNameIndex(ByVal Hook As Byte, ByVal NameIndex As Integer, ByRef GateName As String, ByRef GateID As Long) As Integer
    WizGetGateByNameIndex = Wiz5GetGateByNameIndex(Hook, NameIndex, GateName, GateID)
  End Function
  Public Function WizGetGateName(ByVal Hook As Byte, ByVal GateID As Long, ByRef GateName As String) As Integer
    WizGetGateName = Wiz5GetGateName(Hook, GateID, GateName)
  End Function
  Public Function WizGetGateFormat(ByVal Hook As Byte, ByVal GateID As Long, ByRef Format As Long) As Integer
    WizGetGateFormat = Wiz5GetGateFormat(Hook, GateID, Format)
  End Function
  Public Function WizGetGateRawValue(ByVal Hook As Byte, ByVal GateID As Long, ByRef RawValue As WIZ_PLC_DATA, ByVal Sample As Integer) As Integer
    WizGetGateRawValue = Wiz5GetGateRawValue(Hook, GateID, RawValue, Sample)
  End Function
  Public Function WizPutGateRawValue(ByVal Hook As Byte, ByVal GateID As Long, ByRef RawValue As WIZ_PLC_DATA, ByVal CommErr As Integer, ByVal Mode As Integer, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
    WizPutGateRawValue = Wiz5PutGateRawValue(Hook, GateID, RawValue, CommErr, Mode, Seconds, MiliSec)
  End Function
  Public Function WizGetGateFlags(ByVal Hook As Byte, ByVal GateID As Long, ByRef Flags As Byte) As Integer
    WizGetGateFlags = Wiz5GetGateFlags(Hook, GateID, Flags)
  End Function
  Public Function WizGetGateLimits(ByVal Hook As Byte, ByVal GateID As Long, ByRef Upper As Double, ByRef Lower As Double) As Integer
    WizGetGateLimits = Wiz5GetGateLimits(Hook, GateID, Upper, Lower)
  End Function
  Public Function WizSetGateFlag(ByVal Hook As Byte, ByVal GateID As Long, ByVal FlagId As Integer, ByVal SetFlag As Integer) As Integer
    WizSetGateFlag = Wiz5SetGateFlag(Hook, GateID, FlagId, SetFlag)
  End Function
  Public Function WizGetGateStr(ByVal Hook As Byte, ByVal Mode As Integer, ByVal GateID As Long, ByRef GateVal As String, ByRef Seconds As Long, ByRef MiliSec As Integer) As Integer
    WizGetGateStr = Wiz5GetGateStr(Hook, Mode, GateID, GateVal, Seconds, MiliSec)
  End Function
  Public Function WizGetGateVal(ByVal Hook As Byte, ByVal Mode As Integer, ByVal GateID As Long, ByRef GateVal As Double, ByRef Seconds As Long, ByRef MiliSec As Integer) As Integer
    WizGetGateVal = Wiz5GetGateVal(Hook, Mode, GateID, GateVal, Seconds, MiliSec)
  End Function
  Public Function WizPutGateVal(ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As Double, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
    WizPutGateVal = Wiz5PutGateVal(Hook, GateID, Mode, GateVal, Seconds, MiliSec)
  End Function
  Public Function WizPutGateValDirect(ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As Double, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
    WizPutGateValDirect = Wiz5PutGateValDirect(Hook, GateID, Mode, GateVal, Seconds, MiliSec)
  End Function
  Public Function WizPutGateStr(ByVal Hook As Byte, ByVal GateID As Long, ByVal Mode As Integer, ByVal GateVal As String, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
    WizPutGateStr = Wiz5PutGateStr(Hook, GateID, Mode, GateVal, Seconds, MiliSec)
  End Function
  Public Function WizSetGateSampleRate(ByVal Hook As Byte, ByRef GateList As Long, ByVal GateQuant As Long, ByVal NewRate As Long) As Integer
    WizSetGateSampleRate = Wiz5SetGateSampleRate(Hook, GateList, GateQuant, NewRate)
  End Function
  Public Function WizLoadRecipe(ByVal Hook As Byte, ByVal RcpFileName As String) As Integer
    WizLoadRecipe = Wiz5LoadRecipe(Hook, RcpFileName)
  End Function
  Public Function WizSaveRecipe(ByVal Hook As Byte, ByVal RcpFileName As String, ByVal RcpDescription As String) As Integer
    WizSaveRecipe = Wiz5SaveRecipe(Hook, RcpFileName, RcpDescription)
  End Function
  Public Function WizGateForceLog(ByVal Hook As Byte, ByVal GateID As Long, ByVal Value As Double, ByVal Seconds As Long, ByVal Milli As Integer) As Integer
    WizGateForceLog = Wiz5GateForceLog(Hook, GateID, Value, Seconds, Milli)
  End Function
  Public Function WizGateForceLogEx(ByVal Hook As Byte, ByVal GateID As Long, ByVal Value As Double, ByVal GateVal As String, ByVal Seconds As Long, ByVal MiliSec As Integer) As Integer
    WizGateForceLogEx = Wiz5GateForceLogEx(Hook, GateID, Value, GateVal, Seconds, MiliSec)
  End Function

' Gate definition functions
  Public Function WizGetGateDef(ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF) As Integer
    WizGetGateDef = Wiz5GetGateDef(Hook, GateID, GateDef)
  End Function
  Public Function WizAddGateDef(ByVal Hook As Byte, GateDef As WIZ_GT_DEF) As Integer
    WizAddGateDef = Wiz5AddGateDef(Hook, GateDef)
  End Function
  Public Function WizDeleteGateDef(ByVal Hook As Byte, ByVal GateID As Long) As Integer
    WizDeleteGateDef = Wiz5DeleteGateDef(Hook, GateID)
  End Function
  Public Function WizFindGateDef(ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF, ByVal findflag As Long, ByRef FoundGateId As Long) As Integer
    WizFindGateDef = Wiz5FindGateDef(Hook, GateID, GateDef, findflag, FoundGateId)
  End Function
  Public Function WizChangeGateDef(ByVal Hook As Byte, ByVal GateID As Long, GateDef As WIZ_GT_DEF) As Integer
    WizChangeGateDef = Wiz5ChangeGateDef(Hook, GateID, GateDef)
  End Function

' VPI functions

  Public Function WizParseGate(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal GateAddr As String, ByVal GateType As Integer, ByVal Mode As Integer, ByVal GateFormat As Integer) As Integer
    WizParseGate = Wiz5ParseGate(Hook, VpiNum, GateAddr, GateType, Mode, GateFormat)
  End Function
  Public Function WizParseBlock(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockAddr As String, ByVal BlockLen As Integer) As Integer
    WizParseBlock = Wiz5ParseBlock(Hook, VpiNum, BlockAddr, BlockLen)
  End Function
  Public Function WizFlagVpi(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal ReadWrite As Integer, ByVal WriteOnly As Integer, ByVal OutBlock As Integer) As Integer
    WizFlagVpi = Wiz5FlagVpi(Hook, VpiNum, ReadWrite, WriteOnly, OutBlock)
  End Function
  Public Function WizVpiFlags(ByVal Hook As Byte, ByVal VpiNum As Byte, ByRef ReadWrite As Integer, ByRef WriteOnly As Integer, ByRef OutBlock As Integer) As Integer
    WizVpiFlags = Wiz5VpiFlags(Hook, VpiNum, ReadWrite, WriteOnly, OutBlock)
  End Function
  Public Function WizSetSamplerPriority(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal Class As Integer, ByVal Delta As Integer) As Integer
    WizSetSamplerPriority = Wiz5SetSamplerPriority(Hook, VpiNum, Class, Delta)
  End Function
  Public Function WizGetSamplerPriority(ByVal Hook As Byte, ByVal VpiNum As Byte, ByRef Class As Integer, ByRef Delta As Integer) As Integer
    WizGetSamplerPriority = Wiz5GetSamplerPriority(Hook, VpiNum, Class, Delta)
  End Function
  Public Function WizSetVpiPort(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal NewPortName As String) As Integer
    WizSetVpiPort = Wiz5SetVpiPort(Hook, VpiNum, NewPortName)
  End Function
  Public Function WizGetVpiPort(ByVal Hook As Byte, ByVal VpiNum As Byte, ByRef PortName As String) As Integer
    WizGetVpiPort = Wiz5GetVpiPort(Hook, VpiNum, PortName)
  End Function
  Public Function WizWriteBlock(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal StartAddr As String, ByVal Length As Integer, ByVal BlockData As String) As Integer
    WizWriteBlock = Wiz5WriteBlock(Hook, VpiNum, StartAddr, Length, BlockData)
  End Function
  Public Function WizReadBlock(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockAddr As String, ByVal Length As Integer, ByVal BlockData As String, ByRef TimeStamps() As Long) As Integer
    WizReadBlock = Wiz5ReadBlock(Hook, VpiNum, BlockAddr, Length, BlockData, TimeStamps)
  End Function
  Public Function WizReadBlockUpdate(ByVal Hook As Byte, ByVal VpiNum As Byte, ByVal BlockId As Integer) As Integer
    WizReadBlockUpdate = Wiz5ReadBlockUpdate(Hook, VpiNum, BlockId)
  End Function

' Alert functions

  Public Function WizStartAlert(ByVal Hook As Byte, ByVal Family As String, ByVal Alert_Text As String, ByVal Severity As Integer, ByVal Class As Long, ByVal Zone As Integer, ByVal InfoFile As String, ByVal Attributes As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AlertEvent As Integer, ByVal ComNo As Integer, ByRef AlertId As Long) As Integer
    WizStartAlert = Wiz5StartAlert(Hook, Family, Alert_Text, Severity, Class, Zone, InfoFile, Attributes, Seconds, MilliSec, AlertEvent, ComNo, AlertId)
  End Function
  Public Function WizStampAlert(ByVal Hook As Byte, ByVal AlertQuant As Long, ByRef alertList() As Long, ByVal NewStatus As Integer, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String) As Integer
    WizStampAlert = Wiz5StampAlert(Hook, AlertQuant, alertList, NewStatus, Seconds, MilliSec, AckId)
  End Function
  Public Function WizAckClassAlert(ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewClass As Long, ByVal Seconds As Long, ByVal MilliSec As Integer, ByVal AckId As String) As Integer
    WizAckClassAlert = Wiz5AckClassAlert(Hook, AlertId, NewClass, Seconds, MilliSec, AckId)
  End Function
  Public Function WizSetAlertText(ByVal Hook As Byte, ByVal AlertId As Long, ByVal NewText As String) As Integer
    WizSetAlertText = Wiz5SetAlertText(Hook, AlertId, NewText)
  End Function
  Public Function WizRqUnAckedAlerts(ByVal Hook As Byte, ByVal Operation As Integer) As Integer
    WizRqUnAckedAlerts = Wiz5RqUnAckedAlerts(Hook, Operation)
  End Function
  Public Function WizGetAlert(ByVal Hook As Byte, ByVal AlertId As Long, Alert As WIZ_ALERT) As Integer
    WizGetAlert = Wiz5GetAlert(Hook, AlertId, Alert)
  End Function
  Public Function WizGetAlertCount(ByVal Hook As Byte, ByRef AlertCount As Long) As Integer
    WizGetAlertCount = Wiz5GetAlertCount(Hook, AlertCount)
  End Function

' Alert definition functions

  Public Function WizGetAlertDef(ByVal Hook As Byte, ByVal AlertId As Long, AlertDef As WIZ_ALERT_DEF) As Integer
    WizGetAlertDef = Wiz5GetAlertDef(Hook, AlertId, AlertDef)
  End Function
  Public Function WizAddAlertDef(ByVal Hook As Byte, AlertDef As WIZ_ALERT_DEF) As Integer
    WizAddAlertDef = Wiz5AddAlertDef(Hook, AlertDef)
  End Function
  Public Function WizChangeAlertDef(ByVal Hook As Byte, AlertDef As WIZ_ALERT_DEF, ByVal AlertId As Long) As Integer
    WizChangeAlertDef = Wiz5ChangeAlertDef(Hook, AlertDef, AlertId)
  End Function
  Public Function WizDeleteAlertDef(ByVal Hook As Byte, ByVal AlertId As Long) As Integer
    WizDeleteAlertDef = Wiz5DeleteAlertDef(Hook, AlertId)
  End Function
  Public Function WizFindAlertDef(ByVal Hook As Byte, ByVal AlertId As Long, AlertDef As WIZ_ALERT_DEF, ByVal findflag As Long, ByRef FoundAlertid As Long) As Integer
    WizFindAlertDef = Wiz5FindAlertDef(Hook, AlertId, AlertDef, findflag, FoundAlertid)
  End Function
  Public Function WizRqAlertDefMsg(ByVal Hook As Byte, ByVal Operation As Long) As Integer
    WizRqAlertDefMsg = Wiz5RqAlertDefMsg(Hook, Operation)
  End Function

' User related functions

    Public Function WizRqUserGroup(ByVal Hook As Byte, ByVal Operation As Integer) As Integer
        WizRqUserGroup = Wiz5RqUserGroup(Hook, Operation)
    End Function
    Public Function WizVerifyUser(ByVal Hook As Byte, ByVal UserName As String, ByVal Password As String) As Integer
        WizVerifyUser = Wiz5VerifyUser(Hook, UserName, Password)
    End Function
    Public Function WizLogin(ByVal Hook As Byte, ByVal UserName As String, ByVal Group As Long) As Integer
        WizLogin = Wiz5Login(Hook, UserName, Group)
    End Function
    Public Function WizGetUserGroup(ByVal Hook As Byte, ByRef UserGroup As Long) As Integer
        WizGetUserGroup = Wiz5GetUserGroup(Hook, UserGroup)
    End Function
    Public Function WizGetUserName(ByVal Hook As Byte, ByRef UserName As String) As Integer
        WizGetUserName = Wiz5GetUserName(Hook, UserName)
    End Function

' VFI related functions

    Public Function WizLocalTimeNowInSec() As Long
        WizLocalTimeNowInSec = Wiz5LocalTimeNowInSec()
    End Function
    Public Function WizSecToLocalTimeStr(ByVal long_time As Long, ByVal TimeStr As String) As Integer
        WizSecToLocalTimeStr = Wiz5SecToLocalTimeStr(long_time, TimeStr)
    End Function
    Public Function WizVfiReadLrm(ByVal HVfi As Long, ByRef pulRecs As Long, ByRef LrmBuffer() As VFI_LRM_OLD) As Integer
        WizVfiReadLrm = Wiz5VfiReadLrm(HVfi, pulRecs, LrmBuffer)
    End Function
    Public Function WizVfiReadHis(ByVal HVfi As Long, ByRef pulRecs As Long, ByRef HisBuffer() As VFI_HIS_OLD) As Integer
        WizVfiReadHis = Wiz5VfiReadHis(HVfi, pulRecs, HisBuffer)
    End Function
    Public Function WizVfiRead(ByVal HVfi As Long, ByVal FileType As Long, ByRef pulRecs As Long, _
                       ByRef LrmBuffer() As VFI_LRM_OLD, ByRef HisBuffer() As VFI_HIS_OLD) As Integer
        WizVfiRead = Wiz5VfiRead(HVfi, FileType, pulRecs, LrmBuffer(), HisBuffer())
    End Function
    Public Function WizVfiWriteLrm(ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef LrmBuffer() As VFI_LRM_OLD, ByRef pulRecNo As Long) As Integer
        WizVfiWriteLrm = Wiz5VfiWriteLrm(HVfi, StnId, ulRecs, LrmBuffer, pulRecNo)
    End Function
    Public Function WizVfiWriteHis(ByVal HVfi As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                             ByRef HisBuffer() As VFI_HIS_OLD, ByRef pulRecNo As Long) As Integer
    WizVfiWriteHis = Wiz5VfiWriteHis(HVfi, StnId, ulRecs, HisBuffer, pulRecNo)
    End Function
    Public Function WizVfiWrite(ByVal HVfi As Long, ByVal FileType As Long, ByVal StnId As Integer, ByVal ulRecs As Long, _
                        ByRef LrmBuffer() As VFI_LRM_OLD, ByRef HisBuffer() As VFI_HIS_OLD, ByRef pulRecNo As Long) As Integer
        WizVfiWrite = Wiz5VfiWrite(HVfi, FileType, StnId, ulRecs, LrmBuffer(), HisBuffer(), pulRecNo)
    End Function
    Public Function WizVfiOpen(ByVal Hook As Byte, ByVal FileType As Long, ByVal Mode As Long, ByVal Path As String, Filter As WIZ_FILTER_OLD, ByRef HVfi As Long) As Integer
        WizVfiOpen = Wiz5VfiOpen(Hook, FileType, Mode, Path, Filter, HVfi)
    End Function
    Public Function WizVfiReopen(ByVal HVfi As Long, ByVal FileType As Long, Filter_ As WIZ_FILTER_OLD) As Integer
        WizVfiReopen = Wiz5VfiReopen(HVfi, FileType, Filter_)
    End Function
    Public Function WizVfiFlush(ByVal VFIHandle As Long) As Integer
        WizVfiFlush = Wiz5VfiFlush(VFIHandle)
    End Function
    Public Function WizVfiClose(ByVal VFIHandle As Long) As Integer
        WizVfiClose = Wiz5VfiClose(VFIHandle)
    End Function
    Public Function WizVfiGetNumOfRecs(ByVal VFIHandle As Long, ByRef Total As Long) As Integer
        WizVfiGetNumOfRecs = Wiz5VfiGetNumOfRecs(VFIHandle, Total)
    End Function
    Public Function WizVfiGetRecLength(ByVal Hook As Byte, ByVal Type_ As Long, ByRef LenWiz As Long, ByRef LenPriv As Long) As Integer
        WizVfiGetRecLength = Wiz5VfiGetRecLength(Hook, Type_, LenWiz, LenPriv)
    End Function
    Public Function WizVfiGetVersion(ByVal Hook As Byte, ByVal Type_ As Long, ByRef Major As Integer, ByRef Minor As Integer) As Integer
        WizVfiGetVersion = Wiz5VfiGetVersion(Hook, Type_, Major, Minor)
    End Function

' Other functions

    Public Function WizGetFileName(ByVal FileType As Integer, ByVal FileName As String, ByRef FullPath As String) As Integer
        WizGetFileName = Wiz5GetFileName(FileType, FileName, FullPath)
    End Function
    'Gilad tiram 8/4/99
    'The parameters path and suffix in the original was passed ByVal.
    'I changed it to ByRef
    Public Function WizGetFilePathSufix(ByVal FileType As Integer, ByRef Path As String, ByRef Suffix As String) As Integer
        WizGetFilePathSufix = Wiz5GetFilePathSufix(FileType, Path, Suffix)
    End Function
    Public Function WizSetFilePath(ByVal FileType As Integer, ByVal NewPath As String) As Integer
        WizSetFilePath = Wiz5SetFilePath(FileType, NewPath)
    End Function
    Public Function WizGetBackupMode(ByVal Hook As Byte, ByRef Mode As Long) As Integer
        WizGetBackupMode = Wiz5GetBackupMode(Hook, Mode)
    End Function
    Public Function WizSetBackupMode(ByVal Hook As Byte, ByVal Mode As Long) As Integer
        WizSetBackupMode = Wiz5SetBackupMode(Hook, Mode)
    End Function
    Public Function WizGetPrinter(ByVal Hook As Byte, ByVal Type_ As Integer, ByRef Printer As String) As Integer
        WizGetPrinter = Wiz5GetPrinter(Hook, Type_, Printer)
    End Function
    Public Function WizSetPrinter(ByVal Hook As Byte, ByVal Type_ As Integer, ByVal Printer As String) As Integer
        WizSetPrinter = Wiz5SetPrinter(Hook, Type_, Printer)
    End Function
    Public Function WizGetPrinterStatus(ByVal Hook As Byte, ByVal Device As String, ByRef DevStatus As Integer) As Integer
        WizGetPrinterStatus = Wiz5GetPrinterStatus(Hook, Device, DevStatus)
    End Function
    Public Function WizStartPrintJob(ByVal Hook As Byte, ByVal PrinterId As Integer, ByVal JobType As Long, ByRef JobHandle As Long) As Integer
        WizStartPrintJob = Wiz5StartPrintJob(Hook, PrinterId, JobType, JobHandle)
    End Function
    Public Function WizEndPrintJob(ByVal Hook As Byte, ByVal JobHandle As Long) As Integer
        WizEndPrintJob = Wiz5EndPrintJob(Hook, JobHandle)
    End Function
    Public Function WizCancelPrintJob(ByVal Hook As Byte, ByVal JobHandle As Long) As Integer
        WizCancelPrintJob = Wiz5CancelPrintJob(Hook, JobHandle)
    End Function
    Public Function WizPrintText(ByVal Hook As Byte, ByVal JobHandle As Long, ByVal PrtText As String) As Integer
        WizPrintText = Wiz5PrintText(Hook, JobHandle, PrtText)
    End Function
    Public Function WizGetWizproVer(ByVal Hook As Byte, ByRef WizproVerNumber As Integer, ByRef Description As String) As Integer
        WizGetWizproVer = Wiz5GetWizproVer(Hook, WizproVerNumber, Description)
    End Function

' Network

    Public Function WizGetLocalStationCfg(ByVal Hook As Byte, ByRef StnName As String, ByRef StnId As Integer, ByRef NPIIdx As Integer, ByRef Attributes As Long, ByRef ServerName As String, ByRef BackupTime As Long) As Integer
        WizGetLocalStationCfg = Wiz5GetLocalStationCfg(Hook, StnName, StnId, NPIIdx, Attributes, ServerName, BackupTime)
    End Function
    Public Function WizGetStationDef(ByVal Hook As Byte, ByVal StnIdx As Long, ByRef StnName As String, ByRef StnId As Integer, ByRef Attributes As Long) As Integer
        WizGetStationDef = Wiz5GetStationDef(Hook, StnIdx, StnName, StnId, Attributes)
    End Function
    Public Function WizGetNetInfo(ByVal Hook As Byte, ByRef LastStnIdx As Long) As Integer
        WizGetNetInfo = Wiz5GetNetInfo(Hook, LastStnIdx)
    End Function
    Public Function WizGetStationNameById(ByVal Hook As Byte, ByVal StnId As Integer, ByRef StnName As String) As Integer
        WizGetStationNameById = Wiz5GetStationNameById(Hook, StnId, StnName)
    End Function
    Public Function WizRqNetMsg(ByVal Hook As Byte, ByVal Operation As Long) As Integer
        WizRqNetMsg = Wiz5RqNetMsg(Hook, Operation)
    End Function
    Public Function WizSetWizproOptions(ByVal Hook As Byte, ByVal Options As Long) As Integer
        WizSetWizproOptions = Wiz5SetWizproOptions(Hook, Options)
    End Function
    Public Function WizGetWizproOptions(ByVal Hook As Byte, ByRef Options As Long) As Integer
        WizGetWizproOptions = Wiz5GetWizproOptions(Hook, Options)
    End Function
    Public Function WizSetEnv(ByVal Hook As Byte, ByVal EnvString As String, ByVal NewEnvString As String) As Integer
        WizSetEnv = Wiz5SetEnv(Hook, EnvString, NewEnvString)
    End Function
    Public Function WizGetEnv(ByVal Hook As Byte, ByVal EnvString As String, ByRef NewEnvString As String, ByVal MaxLength As Integer) As Integer
        WizGetEnv = Wiz5GetEnv(Hook, EnvString, NewEnvString, MaxLength)
    End Function
    Public Function WizGetPlugSerNum(ByVal Hook As Byte, ByRef Agent As Integer, ByRef SerialNumber As Long) As Integer
        WizGetPlugSerNum = Wiz5GetPlugSerNum(Hook, Agent, SerialNumber)
    End Function
    Public Function WizGetModelLimits(ByVal Hook As Byte, ByRef MaxGates As Long, ByRef MaxVpi As Long, ByRef AllowAddons As Integer, ByRef AllowDevelopment As Integer, ByRef ModelName As String) As Integer
        WizGetModelLimits = Wiz5GetModelLimits(Hook, MaxGates, MaxVpi, AllowAddons, AllowDevelopment, ModelName)
    End Function
    Public Function WizRqAlertMsg(ByVal Hook As Byte, ByVal Operation As Integer, ByVal FamilyQuant As Long, FamilyList() As WIZ_ALERT_NAME, ByVal MinSeverity As Long, ByVal MaxSeverity As Long, ByVal Classes As Long, ByVal MinZone As Long, ByVal MaxZone As Long, ByVal StnQuant As Long, StantionList() As WIZ_STN_NAME) As Integer
        WizRqAlertMsg = Wiz5RqAlertMsg(Hook, Operation, FamilyQuant, FamilyList, MinSeverity, MaxSeverity, Classes, MinZone, MaxZone, StnQuant, StantionList)
    End Function

' General Viewports Apis

    Public Function WizGetVpId(ByVal Hook As Byte, ByVal VpType As Integer, ByVal VpName As String, ByRef VpID As Integer) As Integer
        WizGetVpId = Wiz5GetVpId(Hook, VpType, VpName, VpID)
    End Function
    Public Function WizLoadVp(ByVal Hook As Byte, ByVal VpType As Integer, ByVal VpName As String, ByVal Wait As Integer, ByRef VpID As Integer) As Integer
        WizLoadVp = Wiz5LoadVp(Hook, VpType, VpName, Wait, VpID)
    End Function
    Public Function WizSaveVp(ByVal Hook As Byte, ByVal VpID As Integer, ByVal VpName As String) As Integer
        WizSaveVp = Wiz5SaveVp(Hook, VpID, VpName)
    End Function
    Public Function WizCloseVp(ByVal Hook As Byte, ByVal VpiId As Integer) As Integer
        WizCloseVp = Wiz5CloseVp(Hook, VpiId)
    End Function
    Public Function WizQueryVp(ByVal Hook As Byte, ByVal VpiId As Integer, VpAtt As WIZ_VP) As Integer
        WizQueryVp = Wiz5QueryVp(Hook, VpiId, VpAtt)
    End Function
    Public Function WizSwitchToVp(ByVal Hook As Byte, ByVal VpiId As Integer) As Integer
        WizSwitchToVp = Wiz5SwitchToVp(Hook, VpiId)
    End Function
    Public Function WizSetVpPosSize(ByVal Hook As Byte, ByVal VpiId As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal cx As Integer, ByVal cy As Integer, ByVal Options As Long) As Integer
        WizSetVpPosSize = Wiz5SetVpPosSize(Hook, VpiId, X, Y, cx, cy, Options)
    End Function
    Public Function WizSetVpParams(ByVal Hook As Byte, ByVal VpiId As Integer, ByVal NewParams As Long) As Integer
        WizSetVpParams = Wiz5SetVpParams(Hook, VpiId, NewParams)
    End Function
    Public Function WizSetVpTitle(ByVal Hook As Byte, ByVal VpiId As Integer, ByVal Title As String) As Integer
        WizSetVpTitle = Wiz5SetVpTitle(Hook, VpiId, Title)
    End Function
    Public Function WizSetVpGroups(ByVal Hook As Byte, ByVal VpiId As Integer, ByVal Groups As Long) As Integer
        WizSetVpGroups = Wiz5SetVpGroups(Hook, VpiId, Groups)
    End Function

' General Layout Apis

    Public Function WizLoadLayout(ByVal Hook As Byte, ByVal LayName As String, ByVal Wait As Integer, VpList() As WIZ_VP_ENTRY, ByRef VpCount As Integer) As Integer
        WizLoadLayout = Wiz5LoadLayout(Hook, LayName, Wait, VpList, VpCount)
    End Function
    Public Function WizQueryLayout(ByVal Hook As Byte, ByRef LayName As String, VpList() As WIZ_VP_ENTRY, ByRef VpCount As Integer) As Integer
        WizQueryLayout = Wiz5QueryLayout(Hook, LayName, VpList, VpCount)
    End Function
    Public Function WizCloseLayout(ByVal Hook As Byte, ByVal PromptToSave As Boolean) As Integer
        WizCloseLayout = Wiz5CloseLayout(Hook, PromptToSave)
    End Function
    Public Function WizSaveLayout(ByVal Hook As Byte, ByVal LayName As String) As Integer
        WizSaveLayout = Wiz5SaveLayout(Hook, LayName)
    End Function
    Public Function WizLoginUser(ByVal Hook As Byte, ByVal UserName As String, ByVal Password As String) As Integer
        WizLoginUser = Wiz5LoginUser(Hook, UserName, Password)
    End Function


    Public Function WizRunMacroByName(ByVal Hook As Byte, ByVal MacroName As String) As Integer
        WizRunMacroByName = Wiz5RunMacroByName(Hook, MacroName)
    End Function
    Public Function WizRunMacroById(ByVal Hook As Byte, ByVal MacroId As Integer) As Integer
        WizRunMacroById = Wiz5RunMacroById(Hook, MacroId)
    End Function
    Public Function WizReloadMacros(ByVal Hook As Byte, ByVal MacroFileName As String) As Integer
        WizReloadMacros = Wiz5ReloadMacros(Hook, MacroFileName)
    End Function

' Image Apis

    Public Function WizGotoNamedZone(ByVal Hook As Byte, ByVal VpID As Integer, ByVal ZoneName As String) As Integer
        WizGotoNamedZone = Wiz5GotoNamedZone(Hook, VpID, ZoneName)
    End Function
    Public Function WizLoadImage(ByVal Hook As Byte, ByVal VpID As Integer, ByVal ImageName As String, ByVal ZoneName As String) As Integer
        WizLoadImage = Wiz5LoadImage(Hook, VpID, ImageName, ZoneName)
    End Function
    Public Function WizQueryImage(ByVal Hook As Byte, ByVal VpID As Integer, ByRef ImageName As String, ByRef ZoneName As String) As Integer
        WizQueryImage = Wiz5QueryImage(Hook, VpID, ImageName, ZoneName)
    End Function
    Public Function WizSetLayersStatus(ByVal Hook As Byte, ByVal VpID As Integer, ByVal LayersQuant As Integer, LayersList() As LAYER_STAT) As Integer
        WizSetLayersStatus = Wiz5SetLayersStatus(Hook, VpID, LayersQuant, LayersList)
    End Function
    Public Function WizSetAnnFilter(ByVal Hook As Byte, ByVal VpID As Integer, ByVal MinSeverity As Integer, ByVal MaxSeverity As Integer, FamilyList As String, ByVal MinZone As Integer, ByVal MaxZone As Integer, ByVal Class As Long, ByVal StnQuant As Long, StantionList() As WIZ_STN_NAME) As Integer
        WizSetAnnFilter = Wiz5SetAnnFilter(Hook, VpID, MinSeverity, MaxSeverity, FamilyList, MinZone, MaxZone, Class, StnQuant, StantionList)
    End Function

    Public Function WizLocalTime(ByVal Seconds As Long, LocalTime As TM) As Integer
        WizLocalTime = Wiz5LocalTime(Seconds, LocalTime)
    End Function

    Public Function WizMkTime(ByRef Seconds As Long, Time As TM) As Integer
        WizMkTime = Wiz5MkTime(Seconds, Time)
    End Function
    Public Function WizGetMsg(ByVal Hook As Byte, ByRef MsgType As Integer, ByRef Msg As WIZ_MSG_Internal) As Integer
        WizGetMsg = Wiz5GetMsg(Hook, MsgType, Msg)
    End Function


