Welcome to Synthiam!

Program robots using technologies created from industry experts. ARC is our free-to-use robot programming software that makes features like vision recognition, navigation and artificial intelligence easy.

Get Started
Asked — Edited
Resolved Resolved by WBS00001!

Ezscript Functions

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()

AI Support Bot
Related Content
Synthiam
Based on your post activity, we found some content that may be interesting to you. Explore these other tutorials and community conversations.
#5  
EZ Script writing manual for beginners would be a very welcomed document even if only online and in a PDF format.
United Kingdom
#6  
Yes, an online or PDF version would be good. That way, any syntax changes could easily be made. I know it's been discussed before where people asked for a paperback version, but because of any syntax or new additions made, it wouldn't be viable. Hey, who knows... The new ARC re-write that DJ was working on might contain some changes in the script menu in this regard. Here's hoping.
PRO
USA
#7  
I am glad others have the same questions aboutthe functions within EZB. I thought it was just me and figured I was going to get flamed for asking. I looked through the manual multiple times before posting to make sure I wasn't missing something. Hopefully with the new version we will get some further documentation regarding the features and functions within EzScript.
#8  
I totally agree that some type of expansion of the EzScript documentation needs to be done with some actual REAL World examples so that some sort of basic understanding of what happens when used can be thrust into my mind. Once I have a basic idea of what a script command is doing it becomes easier to apply it to a functional script.
#9  
So we are kinda of talking about a Wiki where we could all or at least some use could add and edit content. We do that more or less here and many of contribute tutorials which are not in the Learn section. But I agree with the vib here, we something a little more.

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.
#10  
JustinRatliff you've hit upon a great concept but WiKi control becomes the issue and EZ Robot may not have the staff to oversee the process.
#11  
A couple of years ago, before Revolution and all the tutorials, Josh Starnes was going to set up a Wiki, but he got busy with school. I think it is a great idea to have some method of having documentation in some kind of organized fashion. The forum is great, but it can take a while to find the right search terms to find a topic with an answer you are looking for and a lot of reading to determine if the answer is correct or not. The tutorials are great, but don't cover everything and not great as a reference you can refer back to over and over. Written documentation has been discussed many times with the main objection that DJ changes and adds to the software faster than he can document it (and his dyslexia makes it unlikely that he will write detailed documentation anyway). I think a community Wiki may be the best option if someone will step up to create and oversee it. I'll be happy to contribute and help edit, but I don't have the kind of time to offer right now to build it.

Alan
#12  
I just started another thread saying the same thing. Many of us know ZERO about programming. I am lucky I can get my computer to turn on! (Still trying to figure why I go to Start to shut it Off.... LOL) I just want a simple step by step format to learn how to script, with examples, and an explaination on how they work.

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
#13  
I've been making notes on some of this stuff for some time now. I thought I'd clean some of them up concerning the Science and Math functions. I'll have a look at the date-time functions next.

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
#14  
WBS00001 thanks a lot for posting your summary of Scientific and Math Functions. I guess for now I'm going to copy and paste into a word doc until I get enough really good examples that will make some sense and become a great memory jogger.
#16  
@Robot-Doc
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. :D
#17  
After a bit more searching in C# code, I have divined the Operations of the date and time functions. I have divided it up into 2 sections. The list of the functions with brief extras, and a NOTES section with more detail:

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:


$TheDate = $Day+"/"+$Month+"/"+$Year
#18  
Hi WBS00001,


this is another really cool lesson!

Cool to have somebody how can explain this so good!

Boris
#19  
Awesome @WBS00001 Thank you for experimenting and documenting that! :)
#20  
This must have taken a lot of your time. Thanks for spending it on us. Excellent gift!
#21  
@rentaprinta
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. :)
United Kingdom
#22  
I'm not sure where I saved it but I have a very extensive list of EZ-Script functions/commands and examples/descriptions I wrote some time back as part of a possible tutorial/e-book thingy. If I can find it I'll upload and post it.
PRO
USA
#23  
I would like to thank everyone that replied. There was a lot of good information that came from everyone. That includes

JustinRatliff
Dave Shulpius
Steve G.
Robot-Doc
thetechguru
Andy Roid
WBS00001
rentaprinta
Rich

Thanks everyone.
PRO
USA
#24  
Just stumbled onto this. This is a fantastic thread and well overdue subject to execute. Short of taking basic programming in high school around 1980-1984, I have yet to undertake any kinda modern day coding lessons. I learn by example and deconstructing. The few scripts that Dave Cochran wrote for me is an excellent example of this. How things associate with one another. I know I would Benefit greatly by a function/script /example " programming for dummies tutorials" like Dave suggested. wiki or PDF or perhaps video tutorials ?