
PRO
dbeard
USA
Asked
— Edited

I need to understand what the following functions do and how to use them, they maybe just what I need. Can someone assist?
Where can I find more information on the following script functions. Specifically what they do and what the syntax looks like to use them.
Scientific Math Functions
Now()
Today()
DateTime Functions
MinDate()
MaxDate()
MonthName()
AddDays()
AddMonths()
AddYears()
AddHours()
AddMinute()
AddSeconds()
FmtNum()
FmtDate()
I think those of that come from scripting and programming backgrounds have leg up because we already have experience under out belts. To bring that knowledge forward for others and make it "EZ" is a huge challenge.
Would EZ-Robot host some sort of Scripting Wiki where a counsel of volunteers members could have access to add and edit content? Maybe set some rules like a majority vote is required to add or edit content? EZ-Robot gets an overriding vote and edit control of course. Just tossing this idea out there.
Alan
Example: 1) how to make a startup script to set servo home positions and zero sensors. Set maximum servo speeds to prevent damage to the robot parts.
2) run script examples. Show functions and a simple example on what they can do. ( how to call Auto Position functions and connect them to run a sequence, for example)
3) how to activate voice commands from a script.
4) More complex script functions have a special area of examples.
5) A format to build scripting from.
I know many people in this community already have examples of many of these scripts. A many of us new to scripting need is a place to see them and customize them to do what we want them to do. I know I would learn a lot easier that way.
Scripting For Dummies
Ron R
Scientific and Math Functions
The following functions are used in the form of:
$Variable =Function(Value)
Examples:
$TheSine =Sin(2.5)
$TheAngle =ASin($TheSine)
$TheExp =Exp(1)
$TheVal =Ciel(45.01)
$TheVal =Pi()
They can also be used as intermediate values in script statements.
Examples:
$TheFinalVal =Sin(2.33)+Round(Floor($TheVal))
Print(" "+Sin(Abs($TheAngle))+" is the final value" )
Trig Functions
(2pi Radians =360 degrees)
1 Rad =57.295779513 degrees
Sin(Angle in Radians) Sine function
Sin(1) = 0.841471
Cos(Angle in Radians) Cosine function
Cos(1) = 0.540302
Tan(Angle in Radians) Tangent Function
Tan(1) = 1.557408
Sec(Angle in Radians) Secant function (reciprocal of the Cosine)
Sec(1) = 1.850816
Csc(Angle in Radians) Cosecant function (reciprocal of the Sine)
Csc(1) = 1.188395
Cot(Angle in Radians) Cotangent function (reciprocal of the Tangent)
Cot(1) = 0.6420926
Hyperbolic functions
SinH(Angle in Radians) Hyperbolic Sine function
SinH(1) = 1.1752012
CosH(Angle in Radians) Hyperbolic Cosine function
CosH(1) = 1.5430806
TanH(Angle in Radians) Hyperbolic Tangent function
TanH(1) = 0.7615942
Inverse Functions Results are in Radians
ASin(Sine of Angle) Arcsine function (Angle whose Sine is X)
ASin(0.841471) = 1.00
ACos(Cosine of Angle) Arccosine function (Angle whose Cosine is X)
ACos(00.540302) = 1.00
ATan(Tangent of Angle) Arctangent function (Angle whose Tangent is X)
ATan(1.557408) = 1.00
Math Functions
Abs(Number) Absolute Function - Returns number without sign
Abs(-3.1416) = 3.1416
Abs(3.1416) = 3.1416
Abs(-2) = 2
Abs(2) = 2
Sqrt(Number) Square Root - Returns the square root of a number
Sqrt(100) = 10
Sqrt(7.07) = 2.659
Sqrt(-5) =NaN =Not a Number - can't take square root of a negative
Ciel(Number) (Ceiling) Returns the smallest integer >= to a given number.
Ciel(8) = 8
Ciel(8.001) = 9
Ciel(45) = 45
Ciel(-45) = -45
Ciel(45.001) = 46
Ciel(-45.001) = -45
Ciel(45.95) = 46
Ciel(-45.95) = -45
Floor(Number) Returns the largest integer <= a given number.
Floor(8) = 8
Floor(8.001) = 8
Floor(8.9) = 8
Floor(45) = 45
Floor(-45) = -45
Floor(45.001) = 45
Floor(-45.001) = -46
Floor(45.95) = 45
Floor(-45.95) = -46
Exp(Number) Returns e to the x power. e = Euler's constant (~2.718282)
Exp(-1) = 0.367879
Exp(0.95) = 2.5857
Exp(1) = 2.718282
Exp(0) = 1
Log10(Number) Returns Log-base10
Log10(2) = 0.30103
Log10(20) = 1.30103
Log10(1) = 0
Log10(10) = 1
Log10(100) = 2
Log10(1000) = 3
Log10(0) = -Infinity
Log10(-2) = NaN = Not a Number (Invalid)
Log(Number) Returns the natural log function (base e)
Log(1) = 0
Log(10)= 2.3025851
Log(-1) = NaN =Not a Number (out of range)
Log(0) = -Infinity
Max(Number1, Number2) returns the largest of 2 numbers
Max(1,2) = 2
Max(-1, -2) = -1
Max(-10,20) = 20
Max(1,2,3,4,5) = 2 - Anything beyond 2 numbers is ignored
Max(1) =Error - Must have at least 2 values
Max() = Error
Min(Number1, Number2) returns the smallest of 2 numbers
Min(1,2) = 1
Min(-1, -2) = -2
Min(-10,20) = -10
Min(1,2,3,4,5) = 1 - Anything beyond 2 numbers is ignored
Min(1) =Error - Must have at least 2 values
Min() = Error
Round(Number) Returns the value of a number rounded to the nearest integer
Round(1.25) = 1
Round(1.49) = 1
Round(1.5) = 2
Round(1) = 1
Round(-1.25) = -1
Round(-1.5) = -2
E() returns the value of e
E() = 2.718281828459045
Pi() Returns the value of pi
Pi() =3.14159265358979
You're welcome. You might want to copy and paste it all again since I just found (and corrected) a couple of errors.
@DaveSchulpius
Hmmm. Maybe I should put in a picture of a couple of aspirins at the end for just such maladies.
Date-Time Functions
Add Functions
AddMonths(DateTimeType, Amount to Add)
AddYears(DateTimeType, Amount to Add)
AddHours(DateTimeType, Amount to Add)
AddMinute(DateTimeType, Amount to Add)
AddSeconds(DateTimeType, Amount to Add)
They are used in the form of:
$Variable =Function(Value1, Value2)
Date and Time Units
$Month - Returns the current month number of the year
$Year - Returns the current year
$Day - Returns the current day number of the month
$DayName - Returns the current day name as a string
$Hour - Returns the current hour number of the day
$Minute - Returns the current minute number of the hour
$Second - Returns the current seconds number of the minute
$MonthName - Returns the current month name as a string
$Time - Returns the current time as a string
They are used in the form of:
$Variable =Function
$TheSecond =$Second
Additional Date-Time Functions
MinDate() = 1/1/0001 12:00:00 AM - Returns Min in Date-time range
MaxDate() = 12/31/9999 11:59:59 PM - Returns Max in Date-time range
MonthName(Number of Month) - Returns string with month full name
Now() - Returns the current date-time as a string
Today() - Returns the current date as a string but the time =12:00:00
Date-Time Conversion
CDateTime("dd/mm/yyyy hr:min:sec" )
Used in the form of:
$Variable =Function("dd/mm/yyyy hr:min:sec" )
$TheDateTime =CDateTime("1/11/2000 10:10:10" )
NOTES:
Add Functions
To work with these functions the first value must be in a standard Date-Time number (Type = Double)
To convert a date-time string into that form you can use the CDateTime function. It works like this:
$TheDateTime =CDateTime("dd/mm/yyyy hr:min:sec" )
Once in this form, the variable can be used in any of the "Add" functions.
Example:
$StartDateTime =CDateTime("1/1/2000 10:10:10" )
AddDays($StartDateTime,10) = 1/11/2000 10:10:10
AddYears($StartDateTime,10) = 1/1/2010 10:10:10
AddMonths($StartDateTime,10) = 11/1/2000 10:10:10
AddMinutes($StartDateTime,10) = 1/1/2000 10:20:10
They can also be used as intermidiate values in script statements.
Example:
$TheNewDateTime = AddDays(CDateTime("1/1/2000 10:10:10" ), 10)
Additional Date-Time Functions
MinDate() = 1/1/0001 12:00:00 AM - Returns Min val in Date-time range
MaxDate() = 12/31/9999 11:59:59 PM - Returns Max val in Date-time range
MonthName(Number of Month) - Returns string with month full name
$TheMonth =MonthName(10) ("October" )
Now() Returns the current date-time as a string
$TheDateTime =Now()
Today() Returns the current date as a string but the time always =12:00:00
$TheDate =Today()
The Now() and Today() functions are good for getting the date and time together.
However, if you want only the time use the following instead:
$Time - Returns only the time in a string
$TheTime =$Time
$Date Returns both the date and time.
$TheDateTime =$Date
It is odd that $Date returns both the date and time, however you can get the
date only with the following code:
Code:
this is another really cool lesson!
Cool to have somebody how can explain this so good!
Boris
Thank you. I'm glad that you have such a good grasp of English that it can be useful to you. Hopefully it will be to other non-native English speaking users as well.
If you ever find the time, it could be helpful to your fellow German speaking EZ-Robot users if you could translate some of it to German. The commands have to be in English so they will work in the scripts, but some parts of it can be in whatever language is appropriate, especially in the NOTES portion.
Thanks again for your kind words.
@JustinRatliff ,Dave Schulpius
Thank you as well for your comments. It also helps me, to take the time to clean up my notes on these things and have something better laid out to refresh my memory from time to time. Win-win all around.
@AllReaders
If anyone finds errors or has different ways of expressing the meaning behind these functions, by all means post it. Any critique or revision is more than welcome. Please feel free to add to it as well. Won't hurt my feelings a bit.
JustinRatliff
Dave Shulpius
Steve G.
Robot-Doc
thetechguru
Andy Roid
WBS00001
rentaprinta
Rich
Thanks everyone.