Miscellaneous functions
SRON provides these 15 functions :
beep()
copy()
display_exception()
exit()
get_exec_time()
len()
randint()
randdouble()
randrange()
setprecision()
sizeof()
sleep()
syscmd()
typeof()
version()
1. beep():
This function is used to make a beep sound. It requires two 'Int' type arguments frequency and duration.
2. copy():
This function creates a copy of the value passed to it. So, the changes made to the original value does not affect the new value.
OUTPUT:
abcd abc
3. display_exception()
This function is used to display error message during runtime. It takes a String type input.
4. exit():
This function exits the program and suddenly stops it. It takes a 'Int' value as argument.
exit(exit_code)
This exit_code tells the operating system, why program halted.
If exit_code is 0, program is exiting due to no errors. If exit_code is 1, program is exiting due to some minor errors. If exit_code is -1, program is exiting due to some serious errors.
5. get_exec_time():
This function returns the time taken by program to execute the code.
OUTPUT:
Time Taken = 0.0001 seconds
6. len():
This function returns the length of any value passed.
OUTPUT:
8 10
7. randint():
This function returns a random 'Int' type value. Takes no arguments.
OUTPUT:
5251570147017362282
8. randdouble():
This function returns a random 'Double' type value. Takes no arguments.
OUTPUT:
0.947283
9. randrange():
This function returns a random number between a particular range. It takes two arguments start_point and end_point. If you pass two 'Int' values, then it will generate a 'Int' type random value between them. And if you pass two 'Double' values, then it will generate a random 'Double' type value between them.
OUTPUT:
6 9.89077
10. setprecision():
This function sets the number of decimal digits to be printed by 'print()' and 'println()' function. setprecision(num_of_precision) If num_of_precision must be more than 0 and less than 10, otherwise by default 5 decimal digits will be set as the precision.
OUTPUT:
123.123457 123.12346
11. sizeof():
This function returns the size of the data in bytes. You can use it to find how much memory, your variable is taking.
OUTPUT:
8 8 1 1 32 48
12. sleep():
This function is used to pause the execution for some given time. It expects an integer type value as argument. It pauses the code for given milliseconds.
13. syscmd():
This function is used to execute a command in the host operating system's command processor. It takes a 'String' type value as argument. If the command is executed, then it returns a 'Void' value otherwise displays an exception.
14. typeof():
This function returns a 'String' value specifying the type of the passed value.
OUTPUT:
Int Double Char Bool String List
15. version():
This function returns the version of SRON installed in your system.
OUTPUT:
2.1
Last updated