Tuesday, June 19, 2012

Runtime Expression Editor: It’s Magic, You Know!



Last month, I was singing “Oh, oh, oh it’s Magic, you know! Never believe it’s not so!” with 250 of my colleagues in Jaffa, one of the oldest port cities in the world. Why?

Because it is Magic! When I first got involved with the Magic Application Platform twelve years ago there was a lot of talk in the industry about rules engines, business rules editors, and the like. Today, you’re more likely to hear people discuss cloud computing or service-oriented architecture than business rules engines. But one of the features that puts the “Magic” in the Magic xpa Application Platform is the Runtime Expression Editor. One of the reasons Magic employees believe so passionately in the solutions we bring to market is because we know that the productivity features offered are unparalleled. The Runtime Expression Editor is a great example of how our smarter technology works to help accelerate business performance.
When running an application of the Magic xpa Application Platform, the end user can “zoom in” on a range field by pressing the F5 function key, for example. This will reveal the expression that is being used to determine what is being displayed in the view for that range field. Using the pulldown and context menus an end user can edit the expression on the fly. The Runtime Expression Editor can use numeric, string, “basic,” date & time, and variable functions (see the partial lists below from the Magic xpi reference documentation).

If an end user tries to use functions that are not in one of the groups mentioned above, a message appears: “Function not allowed for use in expression.”

Not every end user will have the aptitude needed to use the runtime expression editor.  However, more advanced users who want to be able to adjust business rules at runtime in order to view different results will find this a very powerful feature. Instead of rewriting the application, the business rule can be modified at runtime allowing for various kinds of what-if analysis. This takes the burden off of programming teams and gives power users the ability to work their Magic. After all "it's Magic, you know!"

Partial List of Functions Available in the Runtime Expression Editor

Numeric Functions

Multiplication Operator
Addition Operator
Subtraction Operator
Division Operator
Exponentiation Operator
ABS – Returns the absolute value of a real number, without regard to sign.
ACOS – Returns the arc cosine value of a number, in radians.
ASIN – Returns the trigonometric arc sine of a number, in radians.
ATAN – Returns the arc tangent of a number, in radians.
ChkDgt – Generates a check digit.
COS – Returns the cosine of an angle, where the angle is expressed in radians.
EXP – Calculates the exponential value of x.
Fix – Extracts a specified part of a number, real or integer.
HStr – Returns the hexadecimal (base 16) value of a decimal (base 10) number.
LOG – Returns the natural logarithm of a number.
MAX – Returns the greatest value from a group of values with the same attributes.
MIN – Returns the smallest of a group of values with the same attribute.
MOD – Returns the remainder of an integer division.
MStr – Converts a number to a Magic number with a specified length in bytes.
RAND – Generates random numbers.
Range – Checks whether a number falls within a range, and returns a Boolean true or false.
Round – Extracts a specified part of a number and rounds the result.
SIN – Returns the sine of an angle, where the angle is expressed in radians.
Str – Converts a number to an alpha string, according to a picture.
TAN – Returns the tangent of an angle, where the angle is expressed in radians.

 

String Functions
  
& – Concatenates Alpha strings.
ANSI2OEM – Converts data from ANSI to OEM.
ASCIIChr – Converts a number to a corresponding character in the ASCII character set.
ASCIIVal – ASCII value of a string character.
AStr – Applies a selected format to a string value.
CRC – Calculates redundancy check.
Del – Deletes characters from a string.
DStr – Converts a date or a date expression to a character string.
Fill – Repeats a string.
Flip – Inverts a string.
HVal – Returns the decimal (base 10) value of a hexadecimal (base 16) number.
Ins – Inserts a string in another string.
InStr – Searches for the first occurrence of a string in another string.
Left – Extracts a substring from the left.
Len – Returns the defined length of an Alpha string.
Logical – Converts a visual representation to a logical representation.
Lower – Returns a string in lowercase.
LTrim – Removes leading blanks.
MID – Extracts a substring.
MlsTrans – Returns the translation of a string.
mTVal – Converts a time value in milliseconds from an Alpha string to a numeric value.
MVal – Converts a Magic xpa number (with a specified length in bytes) to a number.
OEM2ANSI – Converts data from OEM to ANSI.
Rep – Replaces a substring within a string.
RepStr – Replaces all occurrences of a defined substring with another substring in a given source string.
Right – Extracts a substring from the right.
RTrim – Removes trailing blanks.
SoundX – Compares homonyms.
StrBuild – Replaces placeholders in a template string with string values.
StrToken – Returns a token from a delimited string.
StrTokenCnt – Returns the number of existing delimited tokens in a given string.
StrTokenIdx – Returns the token index in a delimited Alpha string.
Translate – Translates all logical names and nested logical names to their actual values.
TranslateNR – Translates all logical names, including nested logical names, in a string to their actual values.
Trim – Removes leading and trailing blanks.
TVal – Converts a time value stored as an Alpha character string to a numeric value.
UnicodeChr – Converts a numeric value to its corresponding Unicode character.
UnicodeFromANSI – Converts an ANSI string to Unicode characters as determined by the selected code page.
UnicodeToANSI – Converts a Unicode string to ANSI characters according to a selected code page.
UnicodeVal – Converts a Unicode character to its corresponding numeric value.
Upper – Returns a string in uppercase.
Val – Converts an Alpha character to a number.
Visual – Converts a logical representation to a Visual representation.

Date and Time Functions

AddDate – Performs calculation on date.
AddDateTime – Calculates the difference between two Datetime values Adds a time interval to a Datetime value, which is represented by Magic xpa Date and Time fields. The specified amount of years, months, days, hours, minutes, and seconds are added to the current value of Date & Time, and stored back into those two variables.
AddTime – Performs calculations on a time variable.
BOM – Returns start date of month specified.
BOY – Returns end date of year specified.
CDOW – Name of the day (e.g. Sunday) from date.
CMonth – Name of the month (e.g. January) from date.
Date – System date.
Day – Day of month (1-31) from date.
DifDateTime – Calculate the difference between two Datetime values.
DOW – Number of the day of the week (1-7) from date.
DStr – Date-to-string conversion.
DVal – String-to-date conversion.
EOM – Returns date of end of month specified.
EOY – Returns date of end of year specified.
Hour – Returns the hour portion of the time value.
MDate – Returns the Magic xpa date as input in logon screen.
Minute – Returns the minute portion of the time value.
Month – Returns the month portion of a date.
mTime – Retrieves the time value in milliseconds from midnight to the current time.
mTStr – Converts a time value in milliseconds to a specified Alpha string picture format.
NDOW – Converts the number of the day to the name of the day.
NMonth – Converts the number of the month to the name of the month.
Second – Returns the second portion of the time value.
Time – Returns the system time.
TStr – Converts the time value to an Alpha string.
TVal - Converts a time value stored as an Alpha character string to a numeric value, according to a picture.
Year – Returns the year of a date.

Variable Functions

CaretPosGet – Returns the current caret position in the Edit control.
DataViewToDNDataTable – Generates a .NET DataTable object from the current data view.
DataViewToHTML – Creates an HTML file from the data view variables sent to it.
DataViewToText – Creates a text file from the data view variables sent to it.
DataViewToXML – Creates an XML file from the data view variables sent to it.
DataViewVars – Fetches the variables displayed on the form from where the Print Data event was raised.
EditGet – Retrieves the control value in the edit mode.
EditSet – Sets the edited value of the control that invoked the last handler.
GetComponentName – Fetches the name of the current component.
GetGUID – Fetches the GUID of the application.
IsDefault – Tests if the value of a variable is equal to its default value.
ISNULL – Checks for the existence of a NULL value in a variable.
MarkedTextGet – Returns marked text.
MarkedTextSet – Replaces the marked text with a specified string.
MarkText – Marks the specified number of characters starting from a defined start position.
All Var functions use pointers to variables in memory. Each variable in the memory has a unique number according to the runtime tree. For example, if program A calls Program B, and in Program A there are 3 variables and in B there are 2, then Variable A in program A receives the number 1 in Runtime and variable A in program B receives the number 4. The Var functions allow you to get information about dynamic variables.
VarAttr – Returns a column’s attribute.
VarCurr – Retrieves the variable identifier.
VarCurrN – Returns the current value of a variable according to the variable’s name.
VarDbName – Queries a selected data view to retrieve the physical definition of each variable.
VarIndex – Returns the index of a variable according to the variable’s name.
VarInp – Identifies the last variable where the input has occurred.
VarMod – Variable modification check.
VarName – Provides a variable’s origin and description.
VarPic – Returns a string value that represents the picture of the selected field.
VarPrev – Retrieves the original value of a variable, based on a dynamic value representing a variable index within the Variable list.

1 comment:

  1. Now if someone could just explain to me what "basic functions" are...

    ReplyDelete