如何在开头没有用户名的情况下获取当前运行的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
。我做错了什么?
答案 0 :(得分:4)
问题是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")
。