2

I am trying to retrieve stored functions from a table and have them executed at run-time. Ex MyTableFieldValue contains:

$PARAMETER(MyClass,MyParameterName) 

Where MyTableFieldValue is a field value in a table called MyTable. MyParameterName value in class MyClass is actually "ThisParameter"

I want to do this:

Set parameterName = MyTableFieldValue 

Where parameterName should contain "ThisParameter".

Instead it contains

$PARAMETER(MyClass,MyParameterName).

How do I force cache to actually evaluate what is in MyTableFieldValue ?

4

1 回答 1

3

如果您的表中的数据不是用户可编辑的,您可以使用间接来计算您的值,如文档中所述

http://docs.intersystems.com/latest/csp/docbook/DocBook.UI.Page.cls?KEY=GCOS_operators#GCOS_operators_indirection_arg

在您的示例中,它看起来像

Set @("parameterName = "_MyTableFieldValue)

但是,如果用户可以更改表中的数据,这是不安全的,因为他们可以通过这种方式执行几乎任何代码。在这种情况下,您应该解析字符串,找到您的类名和参数名,然后显式运行 $parameter 函数调用。

于 2017-02-09T04:13:11.880 回答