|
| |
NEW MATH! (Release 7.0)
 |
StampPlot can now perform multiple expressions in a
single line. |
 |
Operations are from left to right. |
 |
Spaces MUST be used between each value/operation. |
 |
Operations are performed left to right, unless additional
brackets are used. |
 |
If you distribute your macros and use "new
math", ensure users upgrade their product. |
 |
See
release updates |
Then general form of a math statement is:
!MATH datamarker=value1, operation,value2
Such as:
!MATH %m10 = %m1,*,10
!STAT %m10
(set %m10 to the value of %m1 times 10)
Math statements may be used in code by enclosing in brackets.
!STAT 60,[60,SIN],[60,ADC],[[60,COS],FORMAT,0.00]
The values may be numeric, strings, data markers, or in the case of addition and subtraction, a time.
| * |
Multiply.
!MATH %m2=2
!MATH %m5=%m2,*,10
!STAT %m5
!STAT [%m2,*,5] |
| / |
Divide. |
| + |
Add
| Adding numbers |
Adding Date/Time |
Adding Strings |
!MATH %m2=10
!MATH %m5=%m2,+,10
!STAT %m5 |
!MATH %m2=1/5/01
12:00
!MATH %m5=%m2,+,23:59
!STAT %m5 |
!MATH %m2=Hi,+,
There
!STAT %m2 |
|
| - |
Subtract:
| Subtracting numbers |
Subtracting Date/Time |
Subtracting Strings |
!MATH %m2=15
!MATH %m5=%m2,-,10
!STAT %m5 |
!MATH %m2=1/5/01
12:00
!MATH %m5=%m2,-,23:59
!STAT %m5 |
!MATH %m2=Hi
There,-, There
!STAT %m2 |
|
| ADC |
Converts analog value1 to binary
string
!MATH %m15=45,ADC
!STAT %m15
or
!STAT [45,ADC] |
| AND |
Returns results of logically bit-ANDing
value1 and value2 (decimal values)
!MATH %m1=205
!MATH %m14=%m1,AND,128
!STAT %m14 |
| ASC |
Math instruction ASC: Returns a value for the
ASCII value of a character, or first character in a string.
!MATH %m1=ABCD,ASC
!STAT %m1 |
| ATN |
Returns the inverse-tangent
See SIN |
| ATNR |
See SINR |
| BIN2DEC |
see DAC |
| BIT |
Returns bit value of value1 (decimal number)
in position value2
!MATH %m21=56,bit,5
!STAT %m21 |
| CHR |
Returns a character for a given ASCII
value
!MATH %m5=65,CHR
!STAT %m5 |
| COS |
see SIN |
| COSR |
See SINR |
| DAC |
Converts a binary string (0's and 1's) to
analog value
!MATH %m15=0110010
!STAT %m15
|
| DEC2BIN |
see ADC |
| DEC2HEX |
Converts a decimal value to hex. Good for
converting BCD value to Decimal also.
!MATH %m10=63,DEC2HEX
!STAT %m10 |
| FORMAT |
Formats value 1 to a mask defined by value
2
!MATH %m20=%m20,FORMAT,0.00
!STAT %m20 |
| HEX2DEC |
Converts a hex value to decimal
!MATH %m10=1FFF,HEX2DEC
!STAT %m10 |
| POW |
Power-raise value1 to the power of
value2:
!MATH %m2=2
!MATH %m1=%m2,pow,3
!STAT %m1 |
| LEN |
Returns the length of a string
!MATH %m10=Hello,LEN
!STAT %m10 |
| LN |
Returns the natural log of a value |
| LOG |
Returns value1 to the log of base value2.
!MATH %m0=500
!MATH %m20=%m0,log,10
!STAT %m20 |
| MID |
Returns a portion of a string starting from the LEFT position at start for
the length of characters defined.
!MATH data=data,mid,start,length
!MATH %m10=Hello There World!
!MATH %m5=%m10,MID,7,5
!STAT %m5 |
| MIN |
Sets min value
!MATH %m20=2
!MATH %m20=%m20,MIN,5
!STAT %m20 |
| MAX |
Sets max value
!MATH %m20=80
!MATH %m20=%m20,MAX,75
!STAT %m20 |
| MOD |
Returns remainder
!MATH %m13=18,MOD,5
!STAT %m13 |
| NOT |
Inverts a value
!MATH %m0=128,NOT
!STAT %m0 |
| OR |
Returns the OR'd value. See AND |
| POS |
Returns the character at the given position
(starting from right)
!MATH %m0=ABCDEF
!MATH %m1=%m0,pos,2
!STAT %m1 |
| SIN |
Returns sin of value1 in degrees
!MATH %m25=45,sin
!STAT %m25 |
| SINR |
Returns sine of value1 in radians
!MATH %m25=45,SINR
!MATH %m25 |
| TAN |
see SIN |
| TANR |
See SINR |
| XOR |
Returns the Exclusive OR value. See AND |
Adding Time:
Time may be added and subtracted, such that, if the current time was 10:00:
!MATH %m20=RTime
!MATH %m21=%m20,+,1:15
!STAT %m20, %m21
%m21 would equal 11:15
This is useful in having certain events take place at a time of day, and then again at an interval.
Macro Values:
Macro Values may be used in a math instruction:
!MATH %m5=AINVAL0
Or within other instructions and bracketed math operations
!STAT The time is (RTIME)
| AMAX |
Plot analog max on scale |
QUEUE |
Bytes in Queue |
| AMIN |
Plot Min |
DPOINT |
Current data point |
| TMAX |
Max time on scale (seconds) |
XR |
Current X-Click relative |
| TMIN |
Min Time on scale (seconds) |
XA |
absolute |
| RTIME |
Real time (system clock) |
XF |
offset |
| PTIME |
Current Plot time in seconds |
XP |
percent |
| PRTIME |
Returns the real time of the plot (useful when
plotting historical data) |
YR |
Current Y click relative |
| PRDATE |
Returns the real date of the plot (useful when
plotting historical data) |
YA |
Absolute |
| PRDT |
Returns the real date & Time of the plot (useful when
plotting historical data) |
YF |
offset |
|
|
YP |
percent |
| COOR |
Returns the current coordinates for percentage plotting. Many macro may update an image coordinates as an 'interrupt to a routine. This allows storing the coordinates until the interrupting routine is complete. |
| AINVAL0-9 |
Returns the value of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro. |
| AINMIN0-9 |
Returns the maximum or minimum values of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro.
. These values are cleared to "?" on New Plots, and Resets if clear min/max on reset is
set, and clear min/max (!CLMM) |
| AINAVE0-9 |
Returns the average value of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro. |
| AINCOUNT0-9 |
Returns the count of accumulated values of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro. |
| AINACCUM0-9 |
Returns the accumulated value of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro. |
| AINMAX0-9 |
Returns the maximum or minimum values of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro.
These values are cleared to "?" on New Plots, and Resets if clear min/max on reset is set. |
| AINTIMEMIN0-9 |
Returns the Date and Time of the maximum or minimum values of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro. These values are cleared on New Plots, and Resets if clear min/max on reset is set. |
| AINTIMEMAX0-9 |
Returns the Date and Time of the maximum or minimum values of analog channels 0-9. These values are INDEPENDENT of using the default routine in macro.
These values are cleared on New Plots, and Resets if clear min/max on reset is set. |
| APATH |
Returns the full path to the Application root
directory.
!APPS (APATH)data\mytest.htm |
| BIT0-16 |
Returns 1 or 0 of the bit position of DIGITAL, 0 is
LSB |
| CR |
Returns a carriage return for separating instructions on as single line.
!STAT Hi(CR)!TITL my plot |
| CD |
Returns the value of the serial
CD line. |
| CTS |
Returns the value of the serial
CTS line. |
| DATAVAL1 - 9 |
Data value in the Values Window, Data
boxes |
| DIGITAL or DIN |
Returns the last digital string received without the %. |
| DSR |
Returns the value of the serial
DSR line. |
| DTR |
Returns the value of the serial
DTR line (Settable using !SDTR). |
DATALOG or
NAMD |
Returns the file name only of the data log. |
| FPATH |
Returns the full path to the current Macro directory from the root drive. This allows the macro to use the full path to a file.
!APPA (FPATH)test.htm |
| ME |
Returns the path and filename to the macro currently being executed. This allows a macro to set itself to be the default start-up macro without needing to know the entire path.
INIT:
!DEFS (ME)
!NPSU ON
ENDMAC |
| MESSAGE |
Returns the last message box messages received. It will contain the date & time if time stamping is enabled. |
MSGLOG or
NAMM |
Returns the file name only of the data log. |
| PATH |
Returns the path to the current macro directory using S-plot as the root.
This allows placing media in the current macro directory and using the current macro for data and snapshots.
~IMGP 0a,0a,100a,100a,(PATH)mypic.jpg
~NAMS (PATH)mypicapshot.jpg |
| PI |
Returns the value of PI |
| RND |
Returns a random number 0-99 |
| RTS |
Returns the value of the serial
RTS line (Settable using !SRTS). |
| SNAP |
Returns the path
& file name of the last snapshot. |
| SNAPNAME |
Returns the file name only of the last snapshot. |
| STATUS |
Returns the current status message in the user status box. |
| TITLE |
Returns the current user-set value of the plot Title. |
 | Color Macro Values:
These macro values may be used when specifying colors:
(BLACK)
(D_BLUE)
(D_GREEN)
(BROWN)
(TEAL)
(PURPLE)
(OLIVE)
(GREY)
(D_GREY)
(BLUE)
(GREEN)
(AQUA)
(RED)
(MAGENTA)
(YELLOW)
(WHITE)
|
Please see the Macro Math Discussions for more
information on math |