动态引用 PowerBuilder 结构值

发布于 2024-11-02 13:25:52 字数 562 浏览 1 评论 0原文

在 PowerBuilder 12 Classic 中,我尝试动态访问/设置结构的属性/元素。知道如何做到这一点吗?

我正在尝试构建一个开发人员实用程序,它将检查任意结构(在编译时未知的结构)以查找其元素。我可以通过访问结构的 ClassDefinitionVariableList 属性来获取元素的名称和类型。但是知道元素的名称和类型对我没有帮助,因为我不知道如何通过名称访问元素。

例如,假设我有一个包含两个字符串元素的结构 st_personfirst_namelast_name。有没有办法表达设置值?任何像这样的遥远的事情:

st_person l_person
Any myStructure

myStructure = l_person
myStructure.setValue("first_name") = 'John'
myStructure.setValue("last_name") = 'Smith'

我真的希望我没有错过一些明显的事情。

In PowerBuilder 12 Classic, I am trying to dynamically access/set the properties/elements of a structure. Any idea how to do this?

I'm attempting to build a developer utility which will examine an arbitrary structure (one which is unknown at compile time) to find its elements. This I can get the names and types of the elements by accessing the VariableList property of the structure's ClassDefinition. But knowing the name and type of the element doesn't help me, as I know no way to access the elements by name.

For example, say I have a structure st_person with two string elements: first_name and last_name. Is there a way to express setting the value? Anything remotely like this:

st_person l_person
Any myStructure

myStructure = l_person
myStructure.setValue("first_name") = 'John'
myStructure.setValue("last_name") = 'Smith'

I really hope I'm not missing something obvious.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

王权女流氓 2024-11-09 13:25:52

不,你不会错过任何东西,除非你在 PBNI 中编程。根据我对 PBNI 的了解,您应该能够做到这一点,但我不是有关 PBNI 的可靠信息来源。

您使用结构有原因吗?听起来您想要的东西接近哈希表或命名项集。我在 PFC 的链接列表之一的顶部构建了自己的命名项集,其中每个节点中的键是名称,数据是……好吧,数据。非常粗略地说,我有一个 of_get (string as_name) 返回 any 和 of_set (string as_name, any aa_value)。这样,我就可以

myList = CREATE n_cst_NamedItemSet
myList.of_Set ("first_name", "John")
myList.of_Set ("last_name", "Smith")

在接收此消息的另一端(这对于 OpenWithParm 和其他需要一个参数的东西来说非常有用)

is_FirstName = of_Get ("first_name")
is_LastName = of_Get ("last_name")

更进一步,我有 of_Defined (string as_name) 来测试是否存在和 of_Get (string as_name, ref任何 aa_value) 返回整数,如果找到则返回成功,以启用可选参数和对象之间更宽松的契约等功能。

还有更多,但这应该可以帮助您继续。如果您不使用 PFC 并且不想从中提取链接列表,那么您可能没有理由不能在一对并行无界数组之上构建它:一个 String 用于键,一个 Any 用于数据。或者,将 DataStore 替换为 String 键列(DataStore 可以更快地搜索键)和 Number 列作为无界 Any 数组的索引。

祝你好运,

特里。

No, you're not missing anything, unless you program in PBNI. From what I've heard of PBNI, you should be able to do this, but I'm not a reliable source of information about PBNI.

Is there a reason why you're using a structure? It sounds like what you want is close to a hash table or a named item set. I've built my own named item set on top of one of PFC's linked lists, where in each node the key is the name, and the data is... well, the data. Very roughly, I have an of_get (string as_name) returns any, and of_set (string as_name, any aa_value). That way, I can

myList = CREATE n_cst_NamedItemSet
myList.of_Set ("first_name", "John")
myList.of_Set ("last_name", "Smith")

and on the other end that receives this (this is great for OpenWithParm and other things that expect one parameter)

is_FirstName = of_Get ("first_name")
is_LastName = of_Get ("last_name")

Going a step further, I have of_Defined (string as_name) to test for existence and of_Get (string as_name, ref any aa_value) returns integer that returns success if found, to enable things like optional parameters and looser contracts between objects.

There's more, but that should get you going. If you're not using PFC and you don't feel like carving the linked lists out of it, there's probably no reason you can't build this on top of a pair of parallel unbounded arrays: one String for keys and one Any for data. Or, substitute a DataStore with a String key column (DataStore makes searching for keys quicker) and a Number column as an index into an unbounded Any array.

Good luck,

Terry.

神经暖 2024-11-09 13:25:52

我添加另一个答案是为了响应 Hugh 将字符串转换为枚举值的新目标(他于 2011 年 5 月 20 日发表的评论)。我有一些代码可以生成将字符串转换为枚举以及将枚举转换为字符串的代码,以 PFC 风格完成(如 n_cst_conversion)。要适应您的 PowerBuilder 版本,您唯一需要做的就是在构造函数中更新枚举分类列表。 (我通常从 PB 对象浏览器的报告中获取此信息,然后运行一些常规文本搜索和替换。)它并不完美,但它可以帮助您直到下次进行重大升级。

祝你好运,

特里。


n_cst_enumscripts

InstanceVariables

string is_EnumTypes[]

事件构造函数返回 long

is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "accessiblerole"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "alignment"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "argcallingconvention"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "arrangeopen"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "arrangetypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "band"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "border"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "borderstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "button"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "charset"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "clipboardformat"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "connectprivilege"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "converttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "cputypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "datetimeformat"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dbnotification"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "direction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "displaysizemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dragmodes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dwbuffer"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dwconflictresolution"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dwitemstatus"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "encoding"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "errorreturn"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "exceptionaction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fileaccess"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "filelock"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "filemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "filetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fillpattern"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fontcharset"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fontfamily"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fontpitch"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "graxisdatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grcolortype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grdatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grgraphtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grlegendtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grobjecttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grresettype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grroundtotype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grscaletype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grscalevalue"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grsorttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grsymboltype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grtictype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "helpcommand"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "htickmarks"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "icon"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkcollectionmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkcompressionmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkeditstatus"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpentip"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpersistenceformat"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpiceditmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpicstatus"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "keycode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "languageid"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "languagesortid"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "libdirtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "libexporttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "libimporttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "linestyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "listviewview"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "location"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailfiletype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "maillogonoption"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailreadoption"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailrecipienttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailreturncode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "maskdatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "menuitemtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "menumergeoption"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "menustyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "metadatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "moncaldisplaystate"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "moncalrepeattype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "object"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "olefunctioncalltype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omactivatetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omactivation"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omcontentsallowed"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omdisplaytype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omlinkupdateoptions"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "orientationtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "ostypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "paragraphsetting"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "parmtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "pbtypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "pdfmethod"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "pointer"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "profileroutinekind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "registryvaluetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "richtexttoolbaractivation"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "rowfocusind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "saveastype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "savemetadata"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "scriptkind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "seektype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "setpostype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sizemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "spacing"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sqlfunction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sqlpreviewfunction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sqlpreviewtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "stgreadmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "stgsharemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "syncprocesstype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "tabposition"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "textcase"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "textstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "timerkind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "toolbaralignment"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "toolbarstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "traceactivity"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "tracecategory"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "treenavigation"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "trigevent"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "typecategory"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "userobjects"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "valschemetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "varaccess"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "variablecardinalitytype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "variablekind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "vtextalign"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "vtickmarks"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "webpagingmethod"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "weekday"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "windowanimationstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "windowstate"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "windowtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "writemode"

*function of_enumprototypes () 返回字符串*

integer li_EnumCount, li_Enum
string ls_Prototypes
TypeDefinition ltd_Enum
EnumerationDefinition led_Enum

ls_Prototypes = "Add this list to the forward prototypes section of pfc_n_cst_conversion~r~n~r~n"

li_EnumCount = UpperBound (is_EnumTypes)
FOR li_Enum = 1 TO li_EnumCount
    ls_Prototypes += "public function string of_string (" + is_EnumTypes[li_Enum] + " aenum_Value)~r~n"
NEXT
FOR li_Enum = 1 TO li_EnumCount
    ls_Prototypes += "public function integer of_" + is_EnumTypes[li_Enum] + " (string as_Value, " + is_EnumTypes[li_Enum] + " ae_Value)~r~n"
NEXT
ls_Prototypes += "~r~n~r~n"

RETURN ls_Prototypes

*function of_enumscripts () 返回字符串*

integer li_EnumCount, li_Enum, li_ValueCount, li_Value
string ls_Scripts, ls_Name
TypeDefinition ltd_Enum
EnumerationDefinition led_Enum

li_EnumCount = UpperBound (is_EnumTypes)
FOR li_Enum = 1 TO li_EnumCount
    ltd_Enum = FindTypeDefinition (is_EnumTypes[li_Enum])
    led_Enum = ltd_Enum

    ls_Scripts += "public function string of_string (" + is_EnumTypes[li_Enum] + &
        " aenum_Value);//////////////////////////////////////////////////////////////////////////////~r~n" + &
        "//~r~n" + &
        "//~tFunction:~t~tof_String~r~n" + &
        "//~r~n" + &
        "//~tAccess:~t~t~tpublic~r~n" + &
        "//~r~n" + &
        "//~tArguments:~r~n" + &
        "//~tae_icon~t~t~tThe " + is_EnumTypes[li_Enum] +" value to be converted to a string.~r~n" + &
        "//~r~n" + &
        "//~tReturns:  ~t~tstring~r~n" + &
        "//~t~t~t~t~t~tA string representation of the " + is_EnumTypes[li_Enum] + " value.~r~n" + &
        "//~t~t~t~t~t~tIf aenum_Value is NULL, the function returns NULL.~r~n" + &
        "//~t~t~t~t~t~tIf aenum_Value is Invalid, the function returns '!'.~r~n" + &
        "//~r~n" + &
        "//~tDescription:~tConverts the " + is_EnumTypes[li_Enum] + " enumerated datatype to a~r~n" + &
        "//~t~t~t~t~t~treadable string representation.~r~n" + &
        "//~r~n" + &
        "//////////////////////////////////////////////////////////////////////////////~r~n" + &
        "string ls_Null~r~n~r~n// Check parameter~r~nIF IsNull (aenum_Value) THEN~r~n~tSetNull (ls_Null)~r~n~tRETURN ls_Null~r~nEND IF~r~n~r~n"
    ls_Scripts += "CHOOSE CASE aenum_Value~r~n"
    li_ValueCount = UpperBound (led_Enum.Enumeration)
    FOR li_Value = 1 TO li_ValueCount
        ls_Name = led_Enum.Enumeration[li_Value].Name
        ls_Scripts += "~r~n~tCASE " + ls_Name + "!;RETURN ~"" + ls_Name + "~"~r~n"
    NEXT
    ls_Scripts += "~r~nEND CHOOSE~r~n~r~n// Invalid parameter~r~nRETURN ~"!~"~r~nend function~r~n~r~n"
NEXT

FOR li_Enum = 1 TO li_EnumCount
    ltd_Enum = FindTypeDefinition (is_EnumTypes[li_Enum])
    led_Enum = ltd_Enum

    ls_Scripts += "public function integer of_" + is_EnumTypes[li_Enum] + &
                " (string as_Value, " + is_EnumTypes[li_Enum] + " ae_Value);//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "//~r~n" + &
                "//~tFunction:  ~t~tof_" + is_EnumTypes[li_Enum] + "~r~n" + &
                "//~r~n" + &
                "//~tAccess:  ~t~tpublic~r~n" + &
                "//~r~n" + &
                "//~tArguments:~r~n" + &
                "//~tas_Value~t~t~tThe string value to be converted to " + is_EnumTypes[li_Enum] + " datatype value.~r~n" + &
                "//~tae_Value~t~t~tA " + is_EnumTypes[li_Enum] + " variable passed by reference which will~r~n" + &
                "//~t~t~t~t~t~t~thold the " + is_EnumTypes[li_Enum] + " value that the string value was~r~n" + &
                "//~t~t~t~t~t~t~tconverted to.~r~n" + &
                "//~r~n" + &
                "//~tReturns: ~t~tinteger~r~n" + &
                "//~t~t~t~t~t~t1 if a successful conversion was made.~r~n" + &
                "//~t~t~t~t~t~tIf as_Value value is NULL, function returns -1~r~n" + &
                "//~t~t~t~t~t~tIf as_Value value is Invalid, function returns -1~r~n" + &
                "//~r~n" + &
                "//~tDescription:  Converts a string value to a " + is_EnumTypes[li_Enum] + " data type value.~r~n" + &
                "//~r~n" + &
                "//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "//~r~n" + &
                "//~tRevision History~r~n" + &
                "//~r~n" + &
                "//~tPFC OS Issues~r~n" + &
                "//~t6~tAuto-generated intial version~r~n" + &
                "//~t~tTerry Voth: http://www.techno-kitten.com~r~n" + &
                "//~r~n" + &
                "//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "//~r~n" + &
                "//~tCopyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.~r~n" + &
                "//~tAny distribution of the PowerBuilder Foundation Classes (PFC)~r~n" + &
                "//~tsource code by other than Sybase, Inc. and its subsidiaries is prohibited.~r~n" + &
                "//~r~n" + &
                "//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "as_Value = Lower (as_Value)~r~n~r~n// Check parameter~r~nIF IsNull (as_Value) THEN~r~n~tRETURN -1~r~nEND IF~r~n~r~n"
    ls_Scripts += "CHOOSE CASE as_Value~r~n"
    li_ValueCount = UpperBound (led_Enum.Enumeration)
    FOR li_Value = 1 TO li_ValueCount
        ls_Name = led_Enum.Enumeration[li_Value].Name
        ls_Scripts += "~r~n~tCASE ~"" + ls_Name + "~", ~"" + ls_Name + "!~"~r~n~t~tae_Value = " + ls_Name + "!~r~n~t~tRETURN 1~r~n"
    NEXT
    ls_Scripts += "~r~nEND CHOOSE~r~n~r~n// Invalid parameter~r~nRETURN -1~r~nend function~r~n~r~n"
NEXT

RETURN ls_Scripts

I'm adding another answer to respond to Hugh's new target (his comment on May 20/2011) of converting strings to enumerated values. I've got code that generates code that converts strings to enumerated and enumerated to strings, done in PFC style (like n_cst_conversion). The only thing you have to do to adapt to your version of PowerBuilder is, in the Constructor, update the list of enumerated classifications. (I usually get this from a report from PB's object browser, run through some regular text search and replace.) It's not perfect, but it gets you by until the next time you do a major upgrade.

Good luck,

Terry.


n_cst_enumscripts

InstanceVariables

string is_EnumTypes[]

event constructor returns long

is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "accessiblerole"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "alignment"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "argcallingconvention"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "arrangeopen"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "arrangetypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "band"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "border"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "borderstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "button"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "charset"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "clipboardformat"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "connectprivilege"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "converttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "cputypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "datetimeformat"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dbnotification"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "direction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "displaysizemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dragmodes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dwbuffer"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dwconflictresolution"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "dwitemstatus"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "encoding"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "errorreturn"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "exceptionaction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fileaccess"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "filelock"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "filemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "filetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fillpattern"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fontcharset"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fontfamily"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "fontpitch"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "graxisdatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grcolortype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grdatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grgraphtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grlegendtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grobjecttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grresettype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grroundtotype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grscaletype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grscalevalue"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grsorttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grsymboltype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "grtictype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "helpcommand"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "htickmarks"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "icon"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkcollectionmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkcompressionmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkeditstatus"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpentip"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpersistenceformat"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpiceditmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "inkpicstatus"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "keycode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "languageid"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "languagesortid"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "libdirtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "libexporttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "libimporttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "linestyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "listviewview"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "location"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailfiletype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "maillogonoption"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailreadoption"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailrecipienttype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "mailreturncode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "maskdatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "menuitemtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "menumergeoption"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "menustyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "metadatatype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "moncaldisplaystate"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "moncalrepeattype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "object"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "olefunctioncalltype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omactivatetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omactivation"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omcontentsallowed"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omdisplaytype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "omlinkupdateoptions"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "orientationtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "ostypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "paragraphsetting"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "parmtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "pbtypes"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "pdfmethod"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "pointer"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "profileroutinekind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "registryvaluetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "richtexttoolbaractivation"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "rowfocusind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "saveastype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "savemetadata"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "scriptkind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "seektype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "setpostype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sizemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "spacing"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sqlfunction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sqlpreviewfunction"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "sqlpreviewtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "stgreadmode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "stgsharemode"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "syncprocesstype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "tabposition"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "textcase"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "textstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "timerkind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "toolbaralignment"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "toolbarstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "traceactivity"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "tracecategory"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "treenavigation"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "trigevent"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "typecategory"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "userobjects"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "valschemetype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "varaccess"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "variablecardinalitytype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "variablekind"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "vtextalign"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "vtickmarks"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "webpagingmethod"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "weekday"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "windowanimationstyle"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "windowstate"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "windowtype"
is_EnumTypes[UpperBound (is_EnumTypes) + 1] = "writemode"

*function of_enumprototypes () returns string*

integer li_EnumCount, li_Enum
string ls_Prototypes
TypeDefinition ltd_Enum
EnumerationDefinition led_Enum

ls_Prototypes = "Add this list to the forward prototypes section of pfc_n_cst_conversion~r~n~r~n"

li_EnumCount = UpperBound (is_EnumTypes)
FOR li_Enum = 1 TO li_EnumCount
    ls_Prototypes += "public function string of_string (" + is_EnumTypes[li_Enum] + " aenum_Value)~r~n"
NEXT
FOR li_Enum = 1 TO li_EnumCount
    ls_Prototypes += "public function integer of_" + is_EnumTypes[li_Enum] + " (string as_Value, " + is_EnumTypes[li_Enum] + " ae_Value)~r~n"
NEXT
ls_Prototypes += "~r~n~r~n"

RETURN ls_Prototypes

*function of_enumscripts () returns string*

integer li_EnumCount, li_Enum, li_ValueCount, li_Value
string ls_Scripts, ls_Name
TypeDefinition ltd_Enum
EnumerationDefinition led_Enum

li_EnumCount = UpperBound (is_EnumTypes)
FOR li_Enum = 1 TO li_EnumCount
    ltd_Enum = FindTypeDefinition (is_EnumTypes[li_Enum])
    led_Enum = ltd_Enum

    ls_Scripts += "public function string of_string (" + is_EnumTypes[li_Enum] + &
        " aenum_Value);//////////////////////////////////////////////////////////////////////////////~r~n" + &
        "//~r~n" + &
        "//~tFunction:~t~tof_String~r~n" + &
        "//~r~n" + &
        "//~tAccess:~t~t~tpublic~r~n" + &
        "//~r~n" + &
        "//~tArguments:~r~n" + &
        "//~tae_icon~t~t~tThe " + is_EnumTypes[li_Enum] +" value to be converted to a string.~r~n" + &
        "//~r~n" + &
        "//~tReturns:  ~t~tstring~r~n" + &
        "//~t~t~t~t~t~tA string representation of the " + is_EnumTypes[li_Enum] + " value.~r~n" + &
        "//~t~t~t~t~t~tIf aenum_Value is NULL, the function returns NULL.~r~n" + &
        "//~t~t~t~t~t~tIf aenum_Value is Invalid, the function returns '!'.~r~n" + &
        "//~r~n" + &
        "//~tDescription:~tConverts the " + is_EnumTypes[li_Enum] + " enumerated datatype to a~r~n" + &
        "//~t~t~t~t~t~treadable string representation.~r~n" + &
        "//~r~n" + &
        "//////////////////////////////////////////////////////////////////////////////~r~n" + &
        "string ls_Null~r~n~r~n// Check parameter~r~nIF IsNull (aenum_Value) THEN~r~n~tSetNull (ls_Null)~r~n~tRETURN ls_Null~r~nEND IF~r~n~r~n"
    ls_Scripts += "CHOOSE CASE aenum_Value~r~n"
    li_ValueCount = UpperBound (led_Enum.Enumeration)
    FOR li_Value = 1 TO li_ValueCount
        ls_Name = led_Enum.Enumeration[li_Value].Name
        ls_Scripts += "~r~n~tCASE " + ls_Name + "!;RETURN ~"" + ls_Name + "~"~r~n"
    NEXT
    ls_Scripts += "~r~nEND CHOOSE~r~n~r~n// Invalid parameter~r~nRETURN ~"!~"~r~nend function~r~n~r~n"
NEXT

FOR li_Enum = 1 TO li_EnumCount
    ltd_Enum = FindTypeDefinition (is_EnumTypes[li_Enum])
    led_Enum = ltd_Enum

    ls_Scripts += "public function integer of_" + is_EnumTypes[li_Enum] + &
                " (string as_Value, " + is_EnumTypes[li_Enum] + " ae_Value);//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "//~r~n" + &
                "//~tFunction:  ~t~tof_" + is_EnumTypes[li_Enum] + "~r~n" + &
                "//~r~n" + &
                "//~tAccess:  ~t~tpublic~r~n" + &
                "//~r~n" + &
                "//~tArguments:~r~n" + &
                "//~tas_Value~t~t~tThe string value to be converted to " + is_EnumTypes[li_Enum] + " datatype value.~r~n" + &
                "//~tae_Value~t~t~tA " + is_EnumTypes[li_Enum] + " variable passed by reference which will~r~n" + &
                "//~t~t~t~t~t~t~thold the " + is_EnumTypes[li_Enum] + " value that the string value was~r~n" + &
                "//~t~t~t~t~t~t~tconverted to.~r~n" + &
                "//~r~n" + &
                "//~tReturns: ~t~tinteger~r~n" + &
                "//~t~t~t~t~t~t1 if a successful conversion was made.~r~n" + &
                "//~t~t~t~t~t~tIf as_Value value is NULL, function returns -1~r~n" + &
                "//~t~t~t~t~t~tIf as_Value value is Invalid, function returns -1~r~n" + &
                "//~r~n" + &
                "//~tDescription:  Converts a string value to a " + is_EnumTypes[li_Enum] + " data type value.~r~n" + &
                "//~r~n" + &
                "//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "//~r~n" + &
                "//~tRevision History~r~n" + &
                "//~r~n" + &
                "//~tPFC OS Issues~r~n" + &
                "//~t6~tAuto-generated intial version~r~n" + &
                "//~t~tTerry Voth: http://www.techno-kitten.com~r~n" + &
                "//~r~n" + &
                "//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "//~r~n" + &
                "//~tCopyright © 1996-1997 Sybase, Inc. and its subsidiaries.  All rights reserved.~r~n" + &
                "//~tAny distribution of the PowerBuilder Foundation Classes (PFC)~r~n" + &
                "//~tsource code by other than Sybase, Inc. and its subsidiaries is prohibited.~r~n" + &
                "//~r~n" + &
                "//////////////////////////////////////////////////////////////////////////////~r~n" + &
                "as_Value = Lower (as_Value)~r~n~r~n// Check parameter~r~nIF IsNull (as_Value) THEN~r~n~tRETURN -1~r~nEND IF~r~n~r~n"
    ls_Scripts += "CHOOSE CASE as_Value~r~n"
    li_ValueCount = UpperBound (led_Enum.Enumeration)
    FOR li_Value = 1 TO li_ValueCount
        ls_Name = led_Enum.Enumeration[li_Value].Name
        ls_Scripts += "~r~n~tCASE ~"" + ls_Name + "~", ~"" + ls_Name + "!~"~r~n~t~tae_Value = " + ls_Name + "!~r~n~t~tRETURN 1~r~n"
    NEXT
    ls_Scripts += "~r~nEND CHOOSE~r~n~r~n// Invalid parameter~r~nRETURN -1~r~nend function~r~n~r~n"
NEXT

RETURN ls_Scripts
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文