Get currently-running MLM name in Arden

543 Views Asked by At

How do I get the currently-running MLM name without the user name at the beginning? The special keyword THIS_MLM_NAME returns the name of the MLM in the format USERNAME-302364198::MLM_NAME_HERE, but I just want the MLM's name by itself.

I tried using SUBSTRING:

SUBSTRING 200 CHARACTERS
STARTING AT ((FIND "::" IN THIS_MLM_NAME) + 2)
FROM THIS_MLM_NAME;

But this just returns null. What am I doing wrong?

1

There are 1 best solutions below

0
On

The problem is that THIS_MLM_NAME is not actually an Arden string. If you test THIS_MLM_NAME IS STRING you will get false. To fix that, convert it to a string with THIS_MLM_NAME AS STRING:

ThisMLMName := SUBSTRING 200 CHARACTERS
   STARTING AT ((FIND "::" IN STRING (THIS_MLM_NAME AS String)) + 2)
   FROM (THIS_MLM_NAME AS String);

Since there is no debugger in Sunrise Acute Care's implementation of Arden, I wrote the following MLM to help show information about variables (name the module MOD_VARIABLE_INFO or change the code to match the actual name):

// data slot
(Variable, Padding) := ARGUMENT;
Result := "";
IF NOT EXIST Padding THEN
   Padding := "";
ENDIF;
CR := (13 FORMATTED WITH "%c") || Padding;
Delimiter := "";
MOD_VARIABLE_INFO := MLM 'MOD_VARIABLE_INFO';
IF Variable IS LIST THEN
   Result := Result || "List(" || (COUNT Variable) || ") [" || CR || "   ";
   FOR Item IN Variable DO
      Result := Result || Delimiter;
      TempResult := CALL MOD_VARIABLE_INFO WITH Item, Padding || "   ";
      Result := Result || TempResult;
      Delimiter := "," || CR || "   ";
   ENDDO;
   Result := Result || CR || "]";
ELSEIF Variable IS STRING THEN
   Result := Result || "String";
ELSEIF Variable IS NUMBER THEN
   Result := Result || "Number";
ELSEIF Variable IS BOOLEAN THEN
   Result := Result || "Boolean";
ELSEIF Variable IS NET_OBJECT THEN
   Result := Result || ".Net Object";
ELSEIF Variable IS NULL THEN
   Result := Result || "Null";
ELSEIF Variable IS OBJECT THEN
   Result := Result || "Object {" || CR || "   ";
   FOR Attr IN (EXTRACT ATTRIBUTE NAMES Variable) DO
      Result := Result || Delimiter || Attr || ": ";
      Item := ATTRIBUTE Attr FROM Variable;
      TempResult := CALL MOD_VARIABLE_INFO WITH Item, Padding || "   ";
      Result := Result || TempResult;
      Delimiter := "," || CR || "   ";
   ENDDO;
   Result := Result || CR || "}";
ELSE
   Result := Result || "Unknown (" || Variable || ")";
ENDIF;
// logic slot
CONCLUDE True;
// action slot
RETURN Result;

While this MLM returns "Unknown" for THIS_MLM_NAME, it at least shows that it is not any of the native Arden data types nor is it a .Net data type.

In the Sunrise MLM Editor, you can see what is going on in the underlying Lisp by syntax checking the MLM, then clicking on the "Syntax Check MLM" tab, selecting "Function Definition" then looking at the code in the lower right pane. Search for THIS_MLM_NAME and you will find (SETQ THIS_MLM_NAME 'USERNAME-302364198::MLM_NAME). From this you can see that the variable has been set to a plain quoted/unevaluated lisp expression rather than a string, which would look like (SETQ THIS_MLM_NAME "USERNAME-302364198::MLM_NAME").