Inside: ME Introspection

Announcements of available shared folders

Inside: ME Introspection

Postby Prairie » Tue Nov 22, 2016 10:25 am

Inside is a Shared Folder that is still being developed. I wrote a handful of functions to allow me to explore the organization and structure of the MorphEngine (ME) and to allow me to more easily read the code of its various functions.

The primary functions are ME and MEvar.
ME takes two strings as inputs. The first input is a string representing the two primary objects of ME, either: "calculator"|"display".
The second is a string representing the path from the ME object, including the null string, "". Another example might be "functions"

Example Usage:
ME("calculator", "") -> Returns all of the name of the keys associated with the "calculator" object.
ME("calculator", "functions/complex") -> Returns the name of the keys stored within "calculator.functions.complex", i.e., the name of the complex functions.
ME("calculator", "vars") -> Returns all of the name of the keys associated within "calculator.vars", i.e., the name of all of the variables "var"


MEval takes the same two strings as inputs as ME.

Example Usage:
MEval("calculator", "push") -> Returns the value associated with "calculator.push", i.e., the code for "push"
Meval("calculator", "vars.Stocks.INTC") -> Returns the value associated with "vars.Stocks.INTC", i.e., the RPL code to return the stock price of INTC.

There are other functions for convenience, based upon ME and MEval.These are pairs of functions to call keys/value for various paths within the "calculator" object. These functions are:

calc/calc->, funcs/func->, vars/var->, types/type->
Example usage is the same for each:

calc(""), calc("functions/complex")
calc->("pop")
functions->("functions/complex/sin")
vars("My Vars")

Here is code for a few of these functions:
Code: Select all
"ME"
function (strME, strPath) {
  var strME = calculator.unquote(strME);
  var strPath=calculator.unquote(strPath);

  // Available MorphEngine Objects
  var obME = {
    "calculator" : calculator,
    "display" : display};

  var ks = obME[strME];
  var k;
  var sks;
  var dp = strPath.split(".");
  if (strPath == "") {
    sks = Object.keys(ks);
    sks.sort();
    return sks;}
  while (dp.length > 0) {
    k = dp.shift();
    ks = ks[k];}
  sks =Object.keys(ks);
  sks.sort();
  return sks;
}


"MEval"
function (strME, strPath) {
  var strME = calculator.unquote(strME);
  var strPath=calculator.unquote(strPath);

  // Available MorphEngine Objects
  var obME = {
    "calculator" : calculator,
    "display" : display
  };
  var ks = obME[strME];
  var k;
  var dp = strPath.split(".");
  if (strPath == "") {
    return strPath}
  while (dp.length > 0) {
    k = dp.shift();
    ks = ks[k];}
  return ks;}

"calc"
function (strPath) {
  var strME = "calculator";
  var strPath=calculator.unquote(strPath);
  return Inside.ME(strME, strPath); }

"calc→"
function (strPath) {
  var strME = "calculator";
  var strPath=calculator.unquote(strPath);
  return Inside.MEval(strME, strPath); }

"funcs"
function (strPath) {
  var strME = "calculator";
  var strPrefix = "functions";
  // No editing below
  var strPath=calculator.unquote(strPath);
  if (strPath == "") {strPath = strPrefix;}
  else {strPath = strPrefix + "." + strPath;}
  return Inside.ME(strME, strPath)}

"func→"
function (strPath) {
  var strME = "calculator";
  var strPrefix = "functions";
  // No editing below
  var strPath=calculator.unquote(strPath);
  if (strPath == "") {strPath = strPrefix;}
  else {strPath = strPrefix + "." + strPath;}
  return Inside.MEval(strME, strPath)}
Prairie
 
Posts: 26
Joined: Mon Sep 30, 2013 2:47 pm

Return to Downloadable Folders / Shared Data

Who is online

Users browsing this forum: No registered users and 0 guests

cron