Hidden Hidden Hidden Hidden
 
 

SCRIPT COMMANDS AND FUNCTIONS
SOFTWARE > INSTRUNET WORLD PLUS SOFTWARE (iW+) >

Table Of Contents

Overview

Documentation Convention

Mathematical Operators

Keywords

Mathematical Functions

String Functions

Periodic Waveform Generation Functions

Ramp and Pulse Generation Functions

Feedback / Control Functions

Object Management Commands

Programming Commands

User Interface Commands

Button and Page Commands

Data Acquisition Commands

instruNet Hardware Functions

File Commands

 

Introduction

The iW+ script language supports many scripts commands and functions. For the notation used to describe each, click here; for a concise list of each, click here; and for details on each, click here.

Documentation Convention

Functions are described using the following notation:

  • [Bracketed / Parameters] are used to describe a parameter that must be passed as one item from a given list, where the list is encapsulated in brackets [..], and the items within the list are separated with "/" characters (e.g. [item1/item2/...]). For example, the syntax "Debug [On/Off]" refers to a command that is typed as "Debug On" or "Debug Off".
  • Italic parameters are to be defined by the user; whereas parameters shown in non-italics are keywords that are to be typed as shown. For example, the Close command is described as follows:
    Close [fileName /all]
    This command has one parameter that is either fileName, or the keyword all. When one uses this command to close a specific file, they would refer to that file's name; otherwise, they would use the keyword all to close all open files.
  • (OptionalParameters) are shown in parenthesis (...). For example, "Loop numCycles (secsPerLoop)" describes a command with one mandatory parameter, numCycles; and one optional parameter, secsPerLoop. One could express this command as "Loop 3" or "Loop 3 0.1", yet not simply as "Loop". If the secsPerLoop parameter in this example is not included, the loop runs as fast as possible, without a secsPerLoop synchronizer.

 

Mathematical Operators

Basic Operators

Operator Notation Example
Add (arg1 + arg2) (3 + 2.1) = 5.1
Subtract (arg1 - arg2) (4 * 3) = 12
Multiply (arg1 * arg2) (7 * 2.1) = 14.7
Divide (floating point) (arg1 / arg2) (7 / 2) = 3.5
Modulo (remainder of x/y) (x % y) (5 % 3) = 2

Bitwise Operators

Operator Notation Example
Bitwise And (arg1 & arg2) (0b0101 & 0xf) = 5
  (arg1 bAnd arg2) (0b0101 bAnd 0xf) = 5
Bitwise Or (arg1 | arg2) (0b0101 | 0x7) = 5
  (arg1 bOr arg2) (0b0101 bOr 0x7) = 5
Bitwise Eor (arg1 ^ arg2) (0b0101 ^ 0x7) = 2
  (arg1 bEor arg2) (0b0101 bEor 0x7) = 2
Bitwise Shift Left (arg1 << arg2) (0b0101 << 2) = 20
1's Complement comp(arg) comp(0x0f) = 0xf0
Return bitNum (base 0) value GetBit(arg, bitNum) GetBit(8, 3) = 1
Set bitNum (base 0) bit to 1 SetBit(arg, bitNum) SetBit(0, 3) = 8
Set bitNum (base 0) bit to 0 ClrBit(arg, bitNum) ClrBit(0b0100, 3) = 0

Related Topics: Bit Values (i.e. 0 and 1), Bit Operations,
and Working with Digital I/O Bits.

Logical Operators

Operator Notation Example
Logical And (arg1 && arg2) (1 && 1) = 1
  (arg1 And arg2) (true And true) = 1
Logical Or (arg1 || arg2) (0 || 0) = 0
  (arg1 Or arg2) (false Or false) = false
Not not( arg ) not(true) = false

Related Topics: Bit Values (i.e. 0 and 1).

Conditional Operators

Conditional Notation Example
Less than (arg1 < arg2) (4 < 5) = true
Greater than (arg1 > arg2) (4 > 5) = false
Less than or equal to (arg1 <= arg2) (5 <= 5) = true
Greater than or equal to (arg1 >= arg2) ==
Not equal to (arg1 != arg2) (4 != 5) = true
Equal to (arg1 == arg2) (4 == 5) = false

 

Keywords

The math evaluator supports many keywords. For example, "ticks" returns the value of the computer's internal 1000Hz 64bit counter and "MouseB" returns 1 if the mouse button is down and 0 otherwise. Some keywords are simply constants. For example, true, on, hi and one all evaluate to a fixed value of 1. One sometimes needs to enclose a keyword with parenthesis to tell the interpreter to return a number (e.g. print ticks prints "ticks" whereas print (ticks) prints the computer's clock value). These keywords are not case sensitive. For example, "TrUe" and "true" are both read as "1". For more information on keywords, click here. A list of all keywords and their meaning is described below.

Base Keywords
For more information on working with Boolean constants, click here.

Keyword Description
true, on, hi, or one 1, logical true
false, off, low, or zero 0, logical false
end maximum integer value = 2 ^ 31 - 1 = 2147483646
pie 3.14159
e 2.718

Digitize State Keywords
For an example that shows digitize state while digitizing, click here.

Keyword Description
CurrentlyDigitizing 1 if currently digitizing, 0 otherwise.
WaitingForTrigger 1 if currently waiting for trigger, 0 otherwise.
DigitizeState DigitizeState is equal to one of: not digitizing (0), waiting for trigger (1), waiting for the next scan to begin (2), or currently digitizing a scan (3).
ScanCount Number of complete scans digitized thus far, base 1.
PointDigitizeCount If running Strip Chart mode: Number of points digitized thus far for the entire digitization. If running Oscilloscope mode: Number of points digitized thus far within the current scan.
PointScanCount Number of points digitized thus far within the current scan. ControlEventCount Number of control events executed since starting the digitization (e.g. press Record page Start button).
UserEventCount Number of user events executed since program launch.
NumControlEventsMissed Number of control events missed due to computer being too busy, since starting the digitization. This is calculated by dividing the number of actually executed control events by the amount of time that has passed since the start of the digitization, and comparing this with the expected value.
OutputQueueCount Number of items in the output queue, waiting to be output.

Digitize Setup Keywords

Keyword Description
PointsPerScan Points per scan, which is set in the Record Setup dialog.
SecsPerPoint Sample period, in samples-per-second-per-channel units.
NoOfScans Number of scans set up to digitize.
SecsPerControlEvent Control Rate, in executions-per-second units.
SecsPerUserEvent User Rate, in executions-per-second units.

Time Keywords

Keyword Description
Ticks Milliseconds since launching instruNet World, in milliseconds units, accurate to 1ms, based on the comp uter's clock.
SecsSinceLaunch Seconds since launching instruNet World, in seconds units, accurate to 1ms, based on computer's clock.
SecsSinceReset Seconds since instruNet Reset, in seconds units, accurate to 1us (1e-6), based on the instruNet i2x0/i60x Controller clock. One cannot read this value if the controller processor is busy digitizing at a fast rate (e.g. >1Ks/sec/ch).
SecsSinceStart Seconds since starting the current digitization, in units of seconds, accurate to 1ms, based on the computer's clock.
DigitizeSecs This is the number of seconds since the start of the current scan, if running in Oscilloscope mode, or the number of seconds since the start of the digitization if running in Strip Chart mode. If trigger is enabled, DigitizeSecs reflects the seconds since the trigger event. DigitizeSecs time is based on the last digitized point, which is paced by the i2x0/i60x controller clock.
bSecs Seconds since midnight, Jan 1, 1904, based on the computer's clock.
bSecsAtLaunch Number of seconds between midnight, Jan 1, 1904 and the launching of instruNet World.

Date Keywords

Keyword Description
cMonth Current month, 1 to 12 range, e.g. cMonth is 4 in April.
cDay Current day, 1 to 31 range, e.g. cDay is 21 on April 21.
cYear Current year, e.g. cYear is 2003 during that year.
cHour Current hour, 0 to 23 range, e.g. 72 minutes after midnight, cHour is 1.
cMinute Current minute, 0 to 59 range, e.g. 72 minutes after midnight, cMinute is 12.
cSecond Current second, 0 to 59 range, e.g. 72.5 minutes after midnight, cSecond is 30.

User Interface Keywords

Keyword Description
MouseB Returns current mouse button state: 0 if up, 1 if down.
MouseX, MouseY Returns current mouse position. MouseX returns the x coordinate, and MouseY returns the Y coordinate; relative to (0, 0), which is the window upper left corner.
FileOk Set to true (1) if the last file i/o operation completed ok, and set to false (0) otherwise. Pressing cancel in a file dialog is considered not ok. Keyword FileOk is always set after executing the following script routines: Close, Create, Flush, Open, SetMasterDir, SetPointer, SetSize, print to file, copy or append to or from file, and execute file.

 

Mathematical Functions

Basic Functions

Function Notation Example
Absolute Value abs( arg ) abs(-3.1) = +3.1
e to the x'th power exp( x ) exp(3.9) = 49.4
Natural log, base 2 ln( arg ) ln(3) = 1.09
Logarithm, base 10 log( arg ) log(3) = .47
Reciprocal = 1/x recip( x ) recip(10) = 0.1
Square = x * x sqr( x ) sqr(4) = 16
Square Root = x ^ 1/2 sqrt( x ) sqrt(16) = 4
x to y'th power pow(x, y) pow(2, 3) = 8

Round Off Functions

Function Notation Example
Round to closest integer int( arg ) int(3.1) = 3
Round down to integer RndDn( arg ) RndDn(3.1) = 3
Round up to integer RndUp( arg ) RndUp(3.1) = 4
Value to right of decimal fract( arg ) fract(1.2345) = .2345

Statistical Functions

Function Notation Example
Minimum of x and y min(x, y) min(9, 10) = 9
Maximum of x and y max(x, y) max(9, 10) = 10
Average of x and y avg(x, y) avg(9, 10) = 9.5

Trigonometry Functions (radians units)

Function Notation Example
Cosine (radians units) cos( arg ) cos(1) = .54
Sine sin( arg ) sin(13.5) = .8
Tangent tan( arg ) tan(1) = 1.55
Arc Cosine acos( arg ) acos(.25) = 1.31
Arc Sine asin( arg ) asin(.25) = .252
Arc Tangent atan( arg ) atan(.25) = .244
Arc Tan of x/y atant(x, y) atant(3, 4) = .64
Hyperbolic Cosine cosh( arg ) cosh(25) = 3e10
Hyperbolic Sine sinh( arg ) sinh(3) = 10
Hyperbolic Tangent tanh( arg ) tanh(1) = .76

Temperature Conversion Functions

Function Notation Example
Celsius to Fahrenheit CtoF( Celsuis ) CtoF(100) = 212
Fahrenheit to Celsius FtoC( Fahrenheit ) FtoC(32) = 0
Celsius to Kelvin CtoK( Celsuis ) CtoK(0) = 273.16
Kelvin to Celsius KtoC( Kelvin ) KtoC(100) = -173.16
Fahrenheit to Kelvin FtoK( Fahrenheit ) FtoK(32) = 273.16
Kelvin to Fahrenheit KtoF( Kelvin ) KtoF(273.16) = 32

 

String Functions

 

Function Notation Example
length of string sLen( string ) sLen("abc") = 3
string compare sCompare( s1, s2 ) sCompare("ab", "ab") = 1
string search, base 1 sSearch( s1, s2 ) sSearch("abcdef", "cd") = 3
string to ascii value sAscii( string ) sAscii("a") = 97

 

Periodic Waveform Generation Functions

SineWave( amplitude, secsPerCycle )

This function returns another point of a sine wave each time it is executed. The sine wave varies from +amplitude to -amplitude with a cycle time of secsPerCycle. For example, Ch3_Vout! = sinewave(5, 2) in a Control Script with a 100ms execution rate (i.e. Control Rate field in Script Options dialog set to 10 executions-per-second) causes a 0.5Hz sine wave (2 seconds per cycle) that varies between -5V and +5V to continuously output from channel 3 while digitizing. Subsequently, each sine cycle would be defined by 20 points (i.e. 2 seconds per cycle / 0.1 second update rate = 20 points per cycle). Related Topics: Feedback and Waveform Generation Math, Slippage between Computer time and instruNet Controller time, and Working with instruNet Hardware.

TriangleWave( amplitude, secsPerCycle )

This function is similar to the SineWave() function, described above, except the waveform shape is a triangle.

SquareWave( amplitude, secsPerCycle )

This function is similar to the SineWave() function, described above, except the waveform shape is a square.

Ramp and Pulse Generation Functions

gen(

(Flat, value, durationSecs)
(Ramp, newValue, durationSecs)
(Recycle, argNum_base1)
(PauseControl, controlValue)
(WaitTrigger)
(WaitScan)

)

The highly programmable gen() function generates complex waveforms composed of periodic and non-periodic pulses, ramps, and constant outputs. It outputs a value each time it is executed and is often used to drive an analog or digital output channel from within a Control Calculate field or the Control Script, both of which execute at the Control Rate. Arguments are evaluated left to right, and one can place up the 64 arguments in one gen() function. Gen is controlled by a series of instruction keywords, each of which are followed by several parameters. For example, gen(Flat, 2, 3, Flat, -2, 4, Recycle, 1) repeatedly outputs 2 (e.g. Volts) for 3 seconds, followed by -2 for 4 seconds. The first Flat instruction specifies 2 for 3sec, the second Flat instruction specifies -2 for 4 sec, and the Recycle instruction tells the gen function to recycle to the first Flat instruction, to repeat the process indefinitely.

The Flat instructional keyword is followed by two parameters, value and durationSecs, which specify a constant value to be output for durationSecs. For example Ch3_Vout! = gen(Flat, 2, 1, Flat -4, 3) in the Control Script will, after starting the digitize process, output 2V for 1 second followed by -4V for 3 seconds.

The Recycle instruction is followed by one parameter, argNum_base1, which tells the gen() functions to jump to the instruction specified in argNum_base1, where 1 is the 1st argument in the gen() function, 2 the 2nd, etc. For example Ch3_Vout! = gen(Flat, 2, 1, Flat -4, 3, Recycle, 1) in the Control Script will, after starting the digitize process, continuously output 2V for 1 second followed by -4V for 3 seconds, followed by another round of 2V/-4V, until the digitizing stops. The Recycle, 1 instruction tells the gen() function to jump to the 1st argument.

The Ramp instruction is followed by two parameters, newValue and durationSecs, which specify that the output is to ramp from its current value to newValue in durationSecs. For example Ch3_Vout! = gen(Flat, 0, .001, Ramp, 4, 10, Recycle, 1) in the Control Script will, after starting the digitize process, ramp from 0V to 4V over a 10 second period, and then repeats the process until digitizing stops.

The WaitTrigger instruction tells the gen() function to continue outputting its last output value until the digitize trigger occurs; in which case, it should jump to the instruction. For example Ch3_Vout! = gen(WaitTrigger, Flat, 0, .001, Ramp, 4, 10) in the Control Script will, after the digitize trigger is received, ramp from 0V to 4V over a 10 second period, and then stop (i.e. stay at 4V).

The WaitScan instruction is similar to WaitTrigger, except it waits for a scan to begin, instead of a trigger.

The PauseControl instructional keyword is followed by one parameter, controlValue. When the gen() hits this instruction, it will continue to output the same value until controlValue is TRUE (i.e. < -0.5 or > +0.5). One often uses a mathematical expression for controlValue. For example Ch3_Vout! = gen(PauseControl, (Ch1_Vin+! > 2), Flat, 0, .001, Ramp, 4, 10) in the Control Script will wait for channel Ch1 Vin+ to go above 2V before outputting its 10 second 0V to 4V ramp.

One can substitute a mathematical expression that includes variables!, strings$, channel values, and front panel objects (e.g. Edit Fields) for any of the numerical arguments used in the gen() function. For example, Ch3_Vout! = gen(Flat, abs(ch1_vin+! * ch2_vin-!), 0.001) will output from Ch3 V out the absolute value of Ch1 V in multiplied by Ch2 V in.

Related Topics: Feedback and Waveform Generation Math, Slippage between Computer time and instruNet Controller time, and Working with instruNet Hardware.

 

Feedback / Control Functions

Alarm( value, lowerThreshold, upperThreshold )

Returns 1 (e.g. true) if value is between lowerThreshold and upperThreshold; and returns 0 (e.g. false) otherwise.

OnOff( value, lowerThreshold, upperThreshold )

Returns 0 (e.g. false) when value goes above the upperThreshold; and returns 1 (e.g. true) when value falls below the lowerThreshold. If value is above lowerThreshold when we start digitizing, we output 0 until value goes above the upperThreshold.

Limit( value, lowerThreshold, upperThreshold )

Returns upperThreshold if value is greater than upperThreshold ; returns lowerThreshold if value is less than lowerThreshold; and returns value if value resides between the lower and upper thresholds.

PID( value, setPoint, P, I, D )
PIDL( value, setPoint, P, I, D, minOutput, maxOutput )

PID is a common algorithm used to control temperatures, pressures and velocities. The value parameter is the current value of the quantity being controlled, setPoint is the target quantity, P is the proportional term, I is the integration term, and D is the derivative term. The derivative term uses a 3 point filter, described below, to reduce susceptibility to noise. PIDL() contains two additional parameters, minOutput and maxOutput, which limit the output term. PID and PIDL must be placed within a Control Calculate field or Control Script in order to operate correctly. Mathematically, these functions are defined as follows:

output[i] = P * {error[i] + sampleTime * I * sum(error[k]) + (D / sampleTime) * deltaErr[i]}
error[i] = setPoint[i] - value[i]
deltaErr[i] = {error[i] + 3*error[i-1] - 3*error[i-2] - error[i-3]} / 6

 

Object Management Commands

Append pageFileStrVarDefine_source, pageFileStrVar_destination

Appends the text in the specified source object [e.g. string$, variable!, define#, "quotedText", (math expression), or numerical constant] to the destination string$, variable!, page or open file. For example, Append Script Test would append the text in the Script page onto the end of the text in the Test page. Append "abc" str$ would append "abc" onto the end of the existing text in string str$.

Clear [ all / variables / pages / userPages / buttons / files / pageName / fileName ]

Clears the data from the specified object. Clear Variables clears all variables (strings$, vars!, defines#) of their data, Clear userPages clears the text in the pages created with the NewPage command, Clear Buttons deletes the buttons created with the NewButton command, Clear files sets the file size of all open files to 0 and in effect clears them of data, Clear pageName clears the specified text editor (e.g. Test, Script, user-defined-page1), Clear fileName clears the specified open file, and Clear All clears all previously mentioned items.

Copy pageFileStrVarDefine_source, pageFileStrVar_destination

Copies the text in the specified source object [e.g. string$, variable!, define#, "quotedText", (math expression), or numerical constant] to the destination page, string$, or open file. For example, Copy Script Test would copy the text in the Script page into the Test page. Copy "abc" str$ would copy "abc" onto string str$. String Copy is very similar to string Append, yet replaces the destination text with the source text, instead of appending it.

Define name# (=) substitutionText

This command substitutes substitutionText for name# every time name# appears in the program code. Defined names must end in a "#" character. Substitution text can be of any length yet must be enclosed in quotes " " if it contains spaces or capital letters. Also, the substitution text can appear on multiple lines within the text file, in the event it is lengthy. Defines are similar to strings$, except they are typically set once, and possibly read multiple times; whereas strings$ are typically set multiple times. The "=" character after the define name is optional (e.g. define x# = "abc" is identical to define x# "abc"). For details on creating lists of channels with a define statement, and for example uses of Define, click here.

Delete [ all / variables / pages / buttons / files ]

This command deletes the specified set of objects from memory. Delete Variables deletes all variables!, strings$ and defines# from memory; Delete Buttons deletes all user created buttons from memory, Delete pages deletes user created pages, and Delete All deletes all previously mentioned items. Related Topics: Script Engine States.

String$ = ("quoted text") (numbers) (var!) (str$) (def#) (math expression) (time) (date) (variables) (DigitizeList)

This command copies a concatenated list of text items to the specified string. This is the same as the Print command, except the destination string is first cleared before text is concatenated onto it. For example, a! = 9.8, b$ = "abc", Str$ = a! + "--" + b$ + " " (3 + a!) + b$[2, 3] causes Str$ to be loaded with "9.8--abc 12.8bc". For details on the various options, please see the Print command.

Variable! = math expression

A command which loads the specified variable with the result of the math expression. For example, a! = 2, s$ = "3.2", v! = abs(a! + s$) + 3 causes v! to be loaded with 8.2. Related Topics: Math Expressions.

Programming Commands

Debug [ on / off ]

This command toggles debugging on or off. If on, diagnostics are printed to the Test page each time a line of script code is executed, as noted here. This can be useful when debugging code that is not working properly. Also, adding additional Print statements to your code (e.g. Print Script ..., Print Test ...) can aid in debugging as well. Related Topics: Debugging your Scripts.

End

Stops execution of the current script. All variables!, defines#, and strings$ remain alive and well, until one does Delete Variables, Clear Variables, Resets the Script Engine, or exits instruNet World.

Execute fileOrStr$

Executes the text in the specified open file or string$. With files, one must first use the Open command to open an existing file, or the Create command to create a new file, and then close the file with the Close command when done. Related Topics: Scripts That Run Other Scripts.

For variable! = Start To Stop
...body...
Next

This is the traditional For loop, which facilitates a loop with a control variable that increment by 1 each time through the loop, starting at Start, and going until Stop. For example, the code below prints Channel#1 three times.

For c! = 1 to 3
    Print "Cycle=" c! ", Ch1 Vin=" ch1_Vin+! "\r"
Next

Goto ... label:

Labels are unique words by themselves on one line with a ":" suffix (e.g. StageTwo:). They are ignored when executed directly, and are used as targets for a Goto label statement. For example, the code below continuously prints Channel#1.

TakeData:

Print "Ch1 Vin=" (Ch1_Vin+!) "\r"
Goto TakeData

If (mathExpression)
...body...
[elseif (mathExpression)]
...body...
[else]
...body...
[else]
...body...
endif

The If/Elseif/Else/Endif commands facilitate executing specific fragments of code, depending on a mathematical test. The ElseIf components can be repeated many times, providing a means by which one can include many different cases. EndIf must be placed at the end of the decision tree. Below is an example of an "If" based decision tree.

if (x! == 0)
    print "x! is 0"
elseif (x! == 1)
    print "x! is 1"
else
    print "x! is not 0 and not 1"
endif

If (mathExpression) then commandToExecuteIfMathExpressionIsTrue

This is a one line version of the traditional "If (mathExp) ... EndIf", where only one line of code is executed if the math expression is true. There is no body of code and no EndIf command in this one-line version. For example, If (a! < 2) then Beep sounds a beep if variable a! is less than 2.

License yy-ssssss-yyyyy

Registers a 13 digit instruNet World+ license for your computer, in the same manner as that done by selecting Install iW+ License in the Script menu.

Loop numCycles, (secsPerLoop), (mouseStop)
...body...
EndLoop

Executes the code between Loop and EndLoop numCycles times. If the secsPerLoop parameter is
not specified, the loop executes as fast as possible; otherwise, it executes the body of the loop once every secsPerLoop seconds. If keyword mouseStop is included, it falls out of the loop if the mouse button is pressed. One can also stop by pressing the Stop button at the top of the Script page, or pressing CONTROL 'S'.

Synchronize secsPerLoop

When placed inside a loop (e.g. While, For, Loop), the synchronizer causes the loop to execute once every secsPerLoop seconds.

While ( mathExpression )
...body...
EndWhile

This is the traditional While loop, which executes the body for as long as the math expression evaluates as true. For example, the code below prints Channel#1 three times.

c! = 1
while (c! <= 3)
    c! = c! + 1
    Print "Cycle=" c! ", Ch1 Vin=" (Ch1_Vin+!) "\r"
endwhile

User Interface Commands

Alert alertText

Shows an alert with the specified alert text, which could be in the form of "quoted text", a string$, or a define#. For example, Alert "Hello" would show an alert with "Hello" in the body of the dialog.

Beep

Sounds a short beep.

Delay seconds

Implements a delay that is seconds long. For example, Delay (1 + 2) would implement a 3 second delay. One can stop the delay only by pressing the Stop button at the top of the Script page, or by pressing CONTROL 'S'.

Erase pageName, numOfLines

Erases the last numOfLines lines from the specified page. For example, Erase Test 1 would erase the last line of text from the Test text editor page.

Print (pageOrFile), ("quoted text"), (numerical value), (var!), (str$), (def#), (math expression), (time), (date), (variables), (DigitizeList)

Prints a list of items to the specified destination text editor page (e.g. Test), or open file. Recall that pages are specified by their tab name, as shown at the bottom of the window. If the first parameter after Print is not a file or page, the printing is directed to the current page.

The current time is substituted for keyword time, the current date is substituted for keyword date, a list of variables are substituted for keyword variables, and the list of channels enabled for digitizing are substituted for keyword digitizeList (e.g. "1/1/1/4, 1/1/1/7"). Keywords are not case sensitive.

Text in quotes is printed exactly as is. The list of items (i.e. quoted text, time, date, variables!, strings$, defines#) can appear in any order and be of any length. "\r" and "\t" within quoted text is interpreted as a carriage return or tab character, respectively. Items within parenthesis ( ) are first evaluated mathematically (e.g. (3 + abs(a! - 3)) in the item list would be evaluated mathematically and its numerical result would be printed). For many examples of the print command, please see file "...\ program files \ instruNet \ instruNet World+ \ Example Scripts (.iBs) \ Demonstrate Printing Functions.iBs".

To print a range of a string, supply the start and stop indices into the string array, base 0, within square brackets. For example, print str$[3, 5] prints the 3rd, 4th and 5th characters of string str$ (we assume the string beings with its 0th character). One can separate the items in the print list with a space character, or the + plus symbol. For example, Print "ab" "cd" and Print "ab" + "cd" are identical.

To print a value in the floating point format (from a variable!, string$ or define#); prefix %x.yf: to the object name, where x is the number of digits to the left of the decimal, and y is the number of digits to the right of the decimal (e.g. Print %1.3f:var! would print var! in a x.yyy numerical format). To force scientific notation, use %x.ye:. To allow the compiler to decide floating point or scientific notation, use %x.yg:. To force an integer printout, use %xd:. The script language uses the same numerical formatting conventions as ANSI C/C++. To learn more about this, please consult a book on the ANSI C library, and focus on the printf() function and the general topic of "printing numbers". Related Topics: Referencing Segments within a String$ or Define#, and Working with Files and Text Editor Text.

Question messageText, responseStr$, (defaultResponseText), (pressedRightBtnVariable!), (leftBtnText), (rightBtnText)

This command will shows a dialog box that displays messageText, an optional edit field for the user to type a response, and two buttons (e.g. OK and Cancel). The response is placed into string responseStr$ and variable pressedRightBtnVariable! is set to true (1) if the user pressed the right button to exit the dialog; and is set to false (0) otherwise. Optionally, the response field can contain defaultResponseText, which appears when the dialog is first opened. Also one can optionally specify the labeling of the two buttons via the leftBtnText via and rightBtnText arguments. For example, Question "How old are you?", response$, "20", userPressedRightBtn!, "Cancel", "OK" would show an alert with a "How old are you?" message, a default response of 20, and Cancel/OK exit dialog buttons.

 

Button and Page Commands

NewPage pageName

This command will create a new tab at the bottom of the instruNet World window that selects a new text editor region. For example, "NewPage Data" creates a new tab named "Data" and a new text editor region that appears when this Data tab is pressed. Subsequent code can then reference this region with the pageName "Data". For example, Print Data "Hello\r", would print the word "Hello" to the Data page. One can also create a page manually by selecting Create Panel Item > Page in the Setup menu. Related Topics: User Defined Pages, File I/O example, Print Digitized Channels example, and Simple Tutorial Example

NewButton pageName, buttonName
...button body...
EndButton

These commands enable one to create a new button that executes the code between NewButton and EndButton when pressed. pageName specifies the page that the button is to reside in, and buttonName specifies the text that appears inside the button at the top of the window. Button names are typically less than 9 characters in length. Subsequent commands refer to this button by its buttonName. One can also create a button manually by selecting Create Panel Item > Button in the Setup menu. Related Topics: User Defined Buttons.

Press pageName, buttonName

This command automatically presses buttonName in page pageName. For example, Press Network Open causes the Network File Open dialog to appear. If we created a new page called "Data", and placed a new button into this page called "Calibrate", then executing Press Data Calibrate would be the same as if the user had pressed that button themself.

Select pageName

Selects page pageName, and displays its contents. This is similar to pressing a tab at the base of the window. For example, Select Record causes the Record page to appear. For a more complete example, click here.

[ Show / Hide ] [ Menubar / Pages / Buttons ]

Shows or hides the entire menubar, entire tab bar at bottom of window, or entire button bar at top of window. To show hidden menu bar & pages, press keys CONTROL SHIFT 'M'. For an example, click here. Related Topics: Window Options Dialog.

[ Show / Hide ] pageName

Shows or hides a tab at the base of the window, along with its corresponding page. For example, Hide Network hides the Network tab at the base of the window, and prevents the user from selecting it. For a more complete example, click here.

[ Show / Hide ] pageName, buttonName

Shows or hides a button at the top of the window. For example, Hide Script Execute hides the Execute button in the Script page, preventing the user from pressing it. For a more complete example, click here.

 

Data Acquisition Commands

Calibrate Hardware

This will implements a full instruNet hardware calibration. This takes several seconds and is used primarily to correct for minute measurement errors caused by temperature drifts. For more details, see Calibration.

Calibrate Gages

This does a 0.000 µStrain calibration for all channels that are set up as strain gages & load cells by reading the voltage across the bridges, and placing it into the Constants Vinit field, for each strain gage and load cell channel.

Calibrate Bridges

This balances all channels that are set up with a Bridge wiring type (e.g. strain gage, load cell, potentiometer) by reading the voltage across the bridge, and placing it into the Constants Vinit field, for each bridge channel.

Calibrate Vdividers

This balances all channels that are set up with Voltage Divider wiring by reading the voltage across the sense resistor, and placing it into the Constants Vinit field, for each voltage divider channel.

Calibrate chList, Vinit

For each channel in the chList; the Vinit fields are loaded with the measured voltage.

Calibrate chList, [ Int1 / Int2 ]

For each channel in the chList; the Mapping Internal1 or Internal2 fields are loaded with the measured engineering units value, as determined by the last Int1/Int2 parameter. For example, Calibrate Ch1_Vin+ Int1 measures the value at Ch1 Vin+, and places it into its Mapping Internal1 field. This facilitates doing two point calibration via the Mapping Setting area. For details, please see the Working With Calibration, Different Scales, & Mapping.

Calibrate [ BeepOn / BeepOff ]

Calibrate BeepOn (or BeepOff) enables (or disables) a beep sound after calibrating a device.

Calibrate [ CjcBeepOn / CjcBeepOff ]

Calibrate CjcBeepOn (or CjcBeepOff) enables (or disables) a beep sound after calibrating the cold junction compensation for thermocouples.

Calibrate [ CheckOn / CheckOff ]

Calibrate CheckOn (or CheckOff) enables (or disables) additional error checking when the next reset occurs.

Calibrate [ RecoveryOn / RecoveryOff ]

Calibrate RecoveryOn (or RecoveryOff) causes (or not) device simulation to be turned on in the event of a calibration failure.

Calibrate [ ReportOn / ReportOff ]

Calibrate ReportOn (or ReportOff) enables (or disables) the printing of a list of channels when the SEARCH button is pressed, after one has pressed the START (and then STOP) button in the RECORD page. This list includes channels that have been enabled for offset drift error correction while digitizing, as described at in Calibration. The list is printed to the TEST page.

 

instruNet Hardware Functions

ChReadback( channelName )

This function reads an output channel with input measurement hardware. For example, ChReadBack(Ch3_Vout!) reads Ch3 voltage output (i.e. a D/A channel) with the A/D converter. For details, see Reading back Output Channels.

CopySettings sourceChannel, destChanList

CopySettings copies the setup of one channel (e.g. Strain Gage, Thermocouple, etc) to multiple other channels. The first argument is the source channel user name, and the 2nd argument is a list of channels to receive the source channel's settings. The destination is often done with a define# which is set to a potentially long (e.g. 16 to 128) list of channels. For details on defining a long list of channels, click here. For an example of CopySettings, click here.

Digitize chList, sRate, nPts, (PageFileOrStr), (separator), (lastRowChar), (charPerCol), (mouseStop), (time)

The function digitizes the channels in the chList channel list at the specified samples-per-second-per-channel (sRate) and number-of-points-per-channel (nPts). Data is printed to the specified page, open file or string; with each channel in its own column. If keyword mouseStop is included in the command line, a mouse down aborts the data taking (also, pressing Stop in the Script pages stops execution). If keyword time is included in the command line, then the point time is placed in the left-most column of the resulting printed table. For a description of the separator, lastRowChar, and charPerCol parameters, please see the "Table" description, below. For an example of the Digitize command, click here.

SetChannel chList, newValue

This sets the value of each channel in the chList to the specified newValue. This is most applicable with voltage output and digital output channels. For example, SetChannel 1/1/1/3, 2.0 sets Ch3 Vout to 2.0 Volts. Related Topics: Writing to instruNet Analog, Digital, and Clock Output (not Input) Channels, and Referencing Channels in your Script code.

SetChannelBit chList, [ 0 / 1 ], bitNum

This sets the bitNum bit of each channel in the chList to the specified 0 or 1 value. This is most applicable with digital output channels. For example, SetChannelBit 1/1/1/25, 0, 3 sets Ch25 Dout bit #3 to 0. Related Topics: Writing to instruNet Analog, Digital, and Clock Output (not Input) Channels, and Working with Digital I/O Bits.

SetField chList, settingsGroup, fieldName, newFieldValue

Sets field fieldName in settingsGroup to newFieldValue for every channel in the chList channel list. Please see file "...\ program files \ instruNet \ instruNet World+ \ Example Scripts (.iBs) \ Examples of setting up channels.iBs" for examples of SetField (which can be abbreviated "SetF"). Also, for more information, please see the Channel Setup and Calibration example.

SetTrigger triggerSource_chList, threshold, ( rising / falling ), ( off / auto / norm )

This function sets the digitize trigger source channel (e.g. 1/1/1/4), threshold, slope (keywords rising or falling) and mode (keywords off, auto, or norm). For example, SetTrigger 1/1/1/1, 2.0, rising auto would tell the Digitize command to not digitize until the voltage at Channel #1 rises above 2.0.

Simulate [ on / off / engage ]
Simulate devModelNum, netNum, firstDevNum, lastDevNum

Simulate enables the simulation of instruNet hardware, when no instruNet hardware exists on the computer (provided you are working with instruNet iNet32.dll version ≥ 3.6.0.1). This can be used to develop or test software on a computer without instruNet hardware. In addition, this can help one read instruNet World data when no hardware is present, since instruNet World wants to see hardware channels when it loads their data. For a summary of different simulation strategies, click here.

When simulating, disconnect or power off the real instruNet hardware to avoid confusing real with simulated.

Another application of Simulate is to specify that an instruNet device is to be simulated in the event that the real device hits a calibration error (e.g. broken unit, over voltage input) via the Calibrate RecoveryOn command. This can be helpful in recovering from a hardware failure with a large system, where one wants their software to not fail in the event that one device, out of many, fails. To see if a device is being simulated, one select "Installed Hardware Report" under the Hardware menu and note that simulated devices and networks include a "Sim" on their description line.

Simulate On sets up the simulation of one i555 at address net #1 dev #1 when Simulate Engage is next executed or at the next instruNet Reset. Simulate Off turns OFF the simulation of this one i555 when simulate engage is next executed or at the next instruNet Reset.

Simulate devModelNum netNum firstDevNum lastDevNum specifies that on the next Simulate Engage or next instruNet Reset, that instruNet devModelNum device (e.g. "430" is model number for the i430 card) on network netNum between deviceNum firstDevNum and lastDevNum be simulated. For example, if one types the following code into the Script page, presses the Execute button, and then presses the Network tab (or select INSTALLED HARDWARE REPORT under HARDWARE menu), they would see ten i100's on network #1, and three on network #2, (simulated of course).

simulate off
simulate 100, 1, 1, 10
simulate 100, 2, 1, 3
simulate engage

The following simulates an i555 (i.e. one i430 card):

simulate off
simulate 240 1 1
simulate 400 1 1 1
simulate 410 1 1 1 1
simulate 430 1 1 2 2
simulate engage

The following simulates one i430 and fourteen i423:

simulate off
simulate 240 1 1
simulate 400 1 1 1
simulate 410 1 1 1 1
simulate 430 1 1 2 2
simulate 423 1 1 3 16
simulate engage

The following simulates 3 different card cages with five i423's each:

simulate off
simulate 240 1 1
simulate 400 1 1 1
simulate 410 1 1 1 1
simulate 430 1 1 2 2
simulate 423 1 1 3 7
simulate 240 2 1
simulate 400 2 1 1
simulate 410 2 1 1 1
simulate 430 2 1 2 2
simulate 423 2 1 3 7
simulate 240 3 1
simulate 400 3 1 1
simulate 410 3 1 1 1
simulate 430 3 1 2 2
simulate 423 3 1 3 7
simulate engage

Table chList, settingsGroup, fieldName, (PageFileOrStr), (separator), (lastRowChar), (charPerCol)

The Table function prints the value of the specified field for every channel in the chList on one row of text. If a destination page, string, or open file is not specified, then it prints to the current page. The channel list is stated explicitly (e.g. "1/1/1/7, 1/1/1/10"), or through a define name#. The settingGroup parameter refers to a settings area (e.g. Hardware, General, Mapping) and the fieldName parameter refers to the name of a field (e.g. scale, wiring, sensor). For a list of these, please see:

The optional separator parameter is text that is placed between each data point (e.g. "\t" is a tab), and the optional lastRowChar parameter is text that is placed at the end of each row (e.g. "\r" is a carriage return). The optional charPerCol parameter specifies the number of characters dedicated to each point, padding with spaces (" ") when necessary. For an example that uses the Table function, click here or here.

 

File Commands

All file commands write success/failure information to the FileOk variable. For comments on how to work with files, click here.

Close [ fileName / all ]

Closes the specified open file; or, if keyword all is specified, closes all open instruNet files.

Create fileName, [ masterDir / showDialog / lastDialog / osDir / appDir / prodDir ]

This function will create a file with the specified file name in the specified directory. Keyword showDialog invokes the File Save dialog which allows the user to specify the OS file name (which is different from fileName used by the code to keep track of the new file) and file save location; keyword lastDialog causes the new file to be placed in the same directory as the last file I/O operation; keyword osDir causes the file to be placed in the operating system directory (i.e. "Windows\System32\") ; keyword appDir causes the new file to be placed in the same directory as the currently executing application program; keyword masterDir causes the file be placed at an internal pathname called the "Master Directory"; and keyword prodDir causes the new file to be placed in "..\program files\instruNet\" (i.e. the instruNet Product Directory).

One can set the Master Directory with the "SetMasterDir" command, which is described below. The fileName optionally includes a directory prefix. For example, if you create a folder called "End_User_Data" in the "..\program files\instruNet\" directory, and then create a file with prodDir keyword and "\\End_User_Data\\xyz.txt" filename, the file will be created at "..\program files\instruNet\End_User_Data\xyz.txt". We use "\\" in the fileName to represent a "\" character instead of a control character indicated by the "\". If the user presses Cancel in the File I/O dialog, this routine does not return an error, yet keyword FileOk is set to FALSE. Related Topics: File I/O Example.

Flush [ fileName / all ]

Writes pending data to disk for the specified open file. This is not a necessary function, since data is flushed periodically automatically, yet is here to allow additional control over internal file buffers.

Open fileName, [ masterDir / showDialog / lastDialog / osDir / appDir/ prodDir ]

Opens the specified file in the specified directory. For details on the directory options, please see the above discussion on the "Create" command.

SetMasterDir [ showDialog / lastDialog ], (newFolder)

Sets the master directory pathname via a file open dialog ('showDialog') or to the last used pathname ('lastDialog'). Keyword newFolder causes a new folder to be created. After being set, this global pathname can be used to direct other file I/O operations.

SetPointer fileName, byteIncrement, [ fromStart / fromEOF / fromPos ]

All open files have an internal pointer that refers to the last written to, or last read from, byte location (starting with 0). The SetPointer command moves this pointer a relative amount forward or backward from the 1st byte of the file ('fromStart'), the end of the file ('fromEOF') or from the current position ('fromPos'). If the byteIncrement value is positive, the pointer is moved forward; otherwise, it is moved backward.

SetSize fileName, [ numBytes / toPointerPosition ]

Sets the size of the specified open file to a specific number of bytes; or if keyword toPointerPosition is used, to the location that was last read from or written to. Before spooling a large amount of data to disk, it is often helpful to preset the file size, so that new space on the disk is not constantly being allocated during data acquisition time.