System Functions

You can use system functions and system variables to change general program settings and output behavior, and to manage the variables and functions in memory.


System variables

The System variables in SpeQ can be changed from within the Workarea or in the Settings window. In the Workarea you can just enter the following to change for example the Angles setting.
Angles = Deg
       Angles mode set to Degrees
To check the current setting of a System variable, you can enter
Angles
       Angles = Deg
SpeQ has the following system variables, which can be found in the Functionstree under the header System, Variables.
Variable Description
Angles = Rad, Deg, Grad Set the Angles mode to radians, degrees or gradians. The Angles mode is important for trigonometric functions like Sin and Cos. The default value is Rad. You can also change Angles from within the Settings window.

Bytes = 1, 2, 4 Set the number of bytes for binary, hexagonal and octal numbers. You can read more about this on the page Numeral Systems. You can also change Bytes from within the Settings window.

Decimals = 1 to 9, Float Set the number of decimals displayed in answers. You can set Decimals to Float to automatically show all relevant decimals in answers. You can read more about Decimals on the page Settings.

Representation = Bin, Dec, Oct, Hex, Fraction Change the default representation of results. For example when you set Representation to Hex, all answers will be displayed in their hexadecimal representation. And if you set Representation to Fraction, the results will be displayed as a fraction. The default value is Dec, the decimal numeral system.

SciNotation = Auto, On, Off, Engineer Set scientific notation to Auto, On, Off, or Engineer. Scientific notation returns values like 950000000 as 9.5e8 for better readability. Here "e8" means "times ten to the power 8". This makes values easier to read. The notation Engineer chooses the power in the notation always as a multiple of three. You can also change this option in the Settings window.

Precision loss
When you've set the scientific notation Off, you can come across the problem of precision loss. The computer does calculate with a finite precision of about 16 digits. When the scientific notation is Off and you get a result that is larger than 10^16 the answer will end with # characters, which means that the exact value of these digits is unknown. See the examples below for a demonstration.


Back to top

System functions

There are two functions for cleaning up memory: Clear and ClearAll. With these functions you can remove earlier defined variables and functions from memory. You can read how to define functions and variables on the pages Defining Variables and Defining Functions
Function Description
ClearAll Clear all defined variables and functions from memory. You can see a list of all defined variables and functions in the Memorylist.

Clear(variable)
Clear(function)
Clear(var1, var2, var3, ...)
Clear the specified variables or functions from memory. Which variables and functions are currently in memory can be seen in the Memorylist.

Run(filename) Execute the content of the the entered file. This way, you can easily load common functions or variables that you regularly use. Supported file types are *.spq and *.txt. If no path is given, SpeQ first searches the file in the current directory, then in the program directory.
Back to top

Examples

'Examples of changing the Angles mode

'Change the angles mode. A circle contains 2*Pi radians,
'so 0.25*Pi is a quarter of a circle.
Angles = Rad
       Angles mode set to Radians
Sin(0.25 * Pi)
       Ans = 0.707106781
Cos(0.25 * Pi)
       Ans = 0.707106781

'This is equal to the Sine at 45 degrees.
Angles = Deg
       Angles mode set to Degrees
Sin(45)
       Ans = 0.707106781
'Examples of using the system variable Decimals

Decimals = Float
       Decimals set to Float
Pi
       Ans = 3.141592654
Decimals = 3
       Decimals set to 3
Pi
       Ans = 3.142
2/4
       Ans = 0.500

'Get the current setting of Decimals
Decimals
       Decimals = 3
'Examples of using Representation

' Set the default representation to hexadecimal
Representation = Hex
       Representation set to Hex
15 + 12
       Ans = 0x1B

' Set the default representation to fraction
Representation = Fraction
       Representation set to Fraction
0.125
       Ans = 1/8

' Set the default representation back to decimal
Representation = Dec
       Representation set to Dec
15 + 12
       Ans = 27
'Examples of using Scientific Notation

SciNotation = Auto
       SciNotation set to Auto
2000+300
       Ans = 2300

SciNotation = On
       SciNotation set On
2000+300
       Ans = 2.3e2
3/1000
       Ans = 2.727e-3
'Examples of using the system functions Clear and ClearAll

'Create a few variables.
'(Press F9 to show or hide the Memorylist)
var1 = 2.25
       var1 = 2.25
var2 = 4* (2 + Sqrt(var1))
       var2 = 14

Clear(var1)
       Variable var1 is deleted
2 * var1
       Error: Unknown variable var1
ClearAll
       Memory cleared
'Examples of using the system function Run

'Run the provided example "geometric forms.spq"
'this file creates functions to calculate the circumreference, 
'surface, and volume of various geometric forms
Run(examples\geometric forms.spq)
       Done

'now you can use the functions created in the file
'calculate the area and circumreference of a circle with radius of 15 cm
radius = 15 cm;
C_circle(radius)	
       Ans = 94.247779608 cm
A_circle(radius)
       Ans = 706.858347058 cm²
' Demonstration of precision loss

SciNotation = Auto;
111111111 * 111111111
       Ans = 1.234567899e16

SciNotation = Off;
111111111 * 111111111
       Ans = 123456789876543##

SciNotation = Auto;
Back to top

See Also

Defining Functions, Defining Variables, Memorylist, Settingswindow, Statusbar