|
The Calculator provided with 010 Editor is a full expression calculator using a syntax similar to C. The calculator can be loaded by clicking the 'Tools > Calculator...' menu option or pressing F8.
Expressions
For evaluating simple expressions, enter an expression in the calculator with no semi-colon (';') at the end of the line. Click the Run button or press F8 again to display the results in the Output text area at the bottom of the window. For example:
0x1000 + 512*123
will display '67072 [10600h]' in the Output area. If a semi-colon is included at the end of the line, the expression is treated as a C program and to display results in the Output panel the return keyword must be used. For example:
return 0x1000 + 512*123;
All standard C operators are supported including +, -, *, /, ~, ^, &, %, |, <<, >>, ?:, brackets, etc. Decimal, hex, octal, and binary number formats are supported. For example:
(312 + 013) * (0x1000 | 0b10)
See Script Basics and Expressions for more information on expressions.
Variables
Variables can also be declared and used in the calculator using C syntax. For example:
int x = 0x4210 + 512;
int y = (x << 16) + x;
return y;
A variables declared in the calculator will be displayed in the Variables list. Strings and arrays are also supported. See Data Types for a full list of supported data types.
Functions
010 Editor includes a number of functions for math operations, editing files, editing strings, and interacting with the interface. Most functions are similar to their C counterparts but have a capital first letter. The Printf function is supported and can be used for displaying output in the Output text area. For example:
Printf( "Integer result = %d, String result = '%s'\n",
0x24 << 3, "Test" );
See Interface Functions, I/O Functions, String Functions, Math Functions, or Tool Functions for a full list of functions.
Code Editor
The Calculator is displayed in the Code Editor, which can also be used for editing Scripts and Templates. See Introduction to Templates and Scripts and Using the Code Editor for more information.
|