如何获取当前运行的 MLM 名称,开头没有用户名?特殊关键字THIS_MLM_NAME
以 格式返回USERNAME-302364198::MLM_NAME_HERE
MLM 的名称,但我只想要 MLM 的名称本身。
我尝试使用SUBSTRING
:
SUBSTRING 200 CHARACTERS
STARTING AT ((FIND "::" IN THIS_MLM_NAME) + 2)
FROM THIS_MLM_NAME;
但这只是返回null
。我究竟做错了什么?
如何获取当前运行的 MLM 名称,开头没有用户名?特殊关键字THIS_MLM_NAME
以 格式返回USERNAME-302364198::MLM_NAME_HERE
MLM 的名称,但我只想要 MLM 的名称本身。
我尝试使用SUBSTRING
:
SUBSTRING 200 CHARACTERS
STARTING AT ((FIND "::" IN THIS_MLM_NAME) + 2)
FROM THIS_MLM_NAME;
但这只是返回null
。我究竟做错了什么?
问题是这THIS_MLM_NAME
实际上不是 Arden 字符串。如果你测试THIS_MLM_NAME IS STRING
你会得到错误的。要解决此问题,请将其转换为字符串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);
由于在 Sunrise Acute Care 的 Arden 实现中没有调试器,我编写了以下 MLM 来帮助显示有关变量的信息(命名模块MOD_VARIABLE_INFO
或更改代码以匹配实际名称):
// 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;
虽然此 MLM 为 . 返回“未知” THIS_MLM_NAME
,但它至少表明它不是任何本机 Arden 数据类型,也不是 .Net 数据类型。
在 Sunrise MLM 编辑器中,您可以通过语法检查 MLM,然后单击“语法检查 MLM”选项卡,选择“函数定义”,然后查看右下方窗格中的代码来查看底层 Lisp 中发生了什么。搜索THIS_MLM_NAME
,你会发现(SETQ THIS_MLM_NAME 'USERNAME-302364198::MLM_NAME)
。从这里您可以看到该变量已被设置为一个普通的带引号/未计算的 lisp 表达式,而不是一个字符串,它看起来像(SETQ THIS_MLM_NAME "USERNAME-302364198::MLM_NAME")
.