CIMScan-VBA is an easy to use scripting language that uses the same syntax as Microsoft’s Visual Basic for Applications, the macro language used by Excel, Access and Word-97. The VBA script capability provides a user with a very powerful tool to perform numerous real-time calculation and control functions within the CIMScan.

Overview

  VBA scripts are called User Functions within CIMScan and are typically very short programs that are triggered periodically or with an Action. The Action may be the result of a database point being updated or the user clicking on an icon. Up to 4,095 scripts can be managed by the system.  Each of these scripts runs independently in its own thread.

Uses

  VBA scripts can be used to perform a wide variety of functions. The following are just a few of the possibilities:
Perform a special linearization on an input or group of inputs.
Set alarm limits based on a test time or on another data point’s value.
Perform a control function.
Make decisions based on the values of a number of database points.
Create customer user entry dialogs.
Implement a special data logging function.

VBA Key Words

 

And

Dialog

Global

Not

Seek

Any

Dim

GoSub

Nothing

Select

App

Dir

GoTo

Object

Set

Append

Do

GroupBox

OkButton

SetAttr

Array

Do Events

If

On

Single

As

Double

Iif

On Error

Static

Base

Each

Imp

Open

Step

Begin

Else

In

Option

Stop

Boolean

ELseIf

Input

Option Base

String

ByRef

Empty

Integer

Option Compare

Sub

Byte

End

Is

Option Explicit

Text

ByVal

EndAction

Let

Or

Then

Call

Eqv

Lib

Output

To

Case

Err

Line

Print

Type

Choose

Error

Loc

Private

Until

Close

Exit

Long

Public

Variant

Const

Explicit

Loop

ReDim

Wend

Currency

FileDateTime

Mod

Rem

While

Date

For

Name

Resume

With

  

  

  

  

Xor


VBA Functions

 

Abs

DatePart

GetObject

Left

SeekStmt

AppActivate

DateSerial

IsArray

Len

SendKeys

Asc

DateValue

IsDate

LineInput

Sgn

Atn

Day

IsEmpty

LOF

Shell

Beep

DDEExecute

IsError

Log

Sin

CBool

DDEInitiate

IsMissing

LSet

Space

CByte

DDETerminate

IsNull

LTrim

Sqr

CCur

Dialog

IsNumeric

Mid

Str

CDate

DlgControlHWND

IsObject

Minute

StrComp

CDbl

DlgControlID

Hex

MkDir

Tan

ChDir

DlgEnable

Hour

Month

Time

ChDrive

DlgHWND

Input

MsgBox

Timer

Chr

DlgText

InputBox

Name

TimeSerial

CInt

DlgVisible

InStr

Now

TimeValue

CLng

EOF

Int

Oct

Trim

Close

Erase

IsArray

Open

TypeName

Cos

Exp

IsDate

Print

UBound

CreateObject

FileAttr

IsEmpty

Randomize

UCase

CSng

FileCopy

IsNull

Raise

Val

CStr

FileLength

IsNumeric

Right

VarType

CVar

FileOpen

IsObject

RmDir

WeekDay

CurDir

Fix

JulianDay

Rnd

Write

Date

Format

Kill

RTrim

Year

DateAdd

FreeFile

LBound

Second

  

DateDiff

GetAttr

LCase

SeekFunc

  


CIMScan Functions

 

GroupIndex

Returns the index of the group for a given tag string

TagIndex

Returns the offset into the group for the DB point whose tag is passed

Members

Returns the number of members in a group

Parent

Returns the index of the parent of a group

Child

Returns the index of the next child in the group

DBIndex

Returns the index of the DB point for a given "Group.Tag" string

DBPoint

Returns the absolute index of a DB point for a group "Index.Offset"

StoreDB

Stored the value passed to the DB point whose index is passed

ReadDB

Reads the value of the DB point whose index is passed

ClearDB

Clears the value of the DB point whose index is passed

GetName

Returns DB point's name if index is known

GetTag

Returns DB point's tag if index is known

GetGroup

Returns group DB point is contained in if its index is known

GetStatus

Returns DB point's I/O status if index is known

GetFlags

Returns DB point's flags if index is known

GetUpdated

Returns time when DB point was last updated if index is known

GetReset

Returns time when DB point was last reset if index is known

GetUser

Gets the "User Tag" for the DB point whose index is passed

SetUser

Stores a "User Tag" in the DB point whose index is passed

CurrentTime

Returns the current time in CIMScan format

TimeString

Converts the current time to a string

Wait

Causes the script to wait for the number of msec. Passed

AlarmLimit

Reads a global alarm limit

SetLimit

Sets a global alarm limit

ClearLimit

Clears a global alarm limit

Alert

Displays a User Alert message to the operator

TrigBy

Returns the absolute index of the DB point who triggered the script

TrigTag

Returns the Tag for the DB point who triggered the script

SendComm

Sends a message to a serial port and returns the response


Typical Script

  Sub Main

Static Array(1 to Elements) as Single
Static Sum as Single

Dim Count as Integer
Dim Index as Integer

If Count < Elements then Count = Count + 1
Index = Index + 1
If Index > Elements then Index = 1

Sum = Sum - Array(Index)
Array(Index) = ReadDB(DBPoint)
Sum = Sum + Array(Index)

StoreDB Avg, Sum/CSng(Count)

End Sub


©2001 CIMTechniques, Inc. All rights reserved. Legal information.
Email our webmaster to report errors on this web site.