With this library it is possible to write arithmetic operations and paths in a string and have them calculated by the library. All basic arithmetic operations and other operations are supported.
Functions:
- Calculate()
- Syntax:
Code: Select all
Result = Calculate(Calculation$, @ErrorOutput$)
- Description: Calculates the given mathematical task.
- Parameter:
- Calculation$: The following operations can be used: + - ± * / % ^ e == != > >= < <= ! && || pi sqrt() abs() round() min() max() ceil() floor() trunc() log() log10() cos() sin() tan() acos() asin() atan() cosh() sinh() tanh() deg2rad() rad2deg() rand()
- @ErrorOutput$: If an error occurs, the error message is stored in the string variable.
- Return value: The result is returned as a double value.
- Example:
Code: Select all
EnableExplicit Global PBEx_Math CompilerIf #PB_Compiler_Processor = #PB_Processor_x86 PBEx_Math = OpenLibrary(#PB_Any, "PB.Ex_Math_x86.dll") CompilerElseIf #PB_Compiler_Processor = #PB_Processor_x64 PBEx_Math = OpenLibrary(#PB_Any, "PB.Ex_Math_x64.dll") CompilerEndIf If PBEx_Math Prototype.d Calculate(Calculation.p-Unicode, ErrorOutput) Global Calculate.Calculate = GetFunction(PBEx_Math, "Calculate") EndIf Define ErrorOutput$ = "" Debug "1 + 2 - 1 = " + Calculate("1 + 2 - 1", @ErrorOutput$) Debug "2^32 = " + Calculate("2^32", @ErrorOutput$) Debug "5 + 2 * 2 = " + Calculate("5 + 2 * 2", @ErrorOutput$) Debug "(10 + 20) * 10 = " + Calculate("(10 + 20) * 10", @ErrorOutput$) Debug "pi * 4 = " + Calculate("pi * 4", @ErrorOutput$) Debug "2.5 + 10 = " + Calculate("2.5 + 10", @ErrorOutput$) Debug "Modulo = " + Calculate("2 % 1 == 0", @ErrorOutput$) Debug "AND condition = " + Calculate("1 == 1", @ErrorOutput$) Debug "sqrt(64) = " + Calculate("sqrt(64)", @ErrorOutput$) Debug "round(5.4) = " + Calculate("round(5.4)", @ErrorOutput$) Debug "is 5 ot 10 greater? = " + Calculate("max(5, 10)", @ErrorOutput$) Debug "15 > 10? = " + Calculate("15 > 10", @ErrorOutput$) Debug "sin(1.5708) = " + Calculate("sin(1.5708)", @ErrorOutput$) CloseLibrary(PBEx_Math)
- Syntax:
Systemvoraussetzungen:
- Windows Vista oder höher
- .NET Framework 4.5 oder höher
- Unicode-Aktivierung (standardmäßig ab PB 5.50)
The following copyright texts must be provided:
Download: This project was discontinued due to errors and is no longer available.Copyright(c) 2017 François Ségaud
Copyright © 2019 RSBasic.de
I would be very pleased about feedbacks, improvement suggestions, error messages or wishes. If you want to support me, you can also donate something. Thanks