function - 为什么返回值总是空字符串?
问题描述
我的 PowerBuilder 函数在某些条件下返回硬编码字符串值。
我检查了调试器,其中一个条件肯定会发回硬编码字符串,但在调用函数的一侧,我总是得到空字符串“”。
这个 PowerBuilder 技巧对我来说是新的,我无法确定该函数是否有问题或调用该函数的脚本。
请查看函数的代码并帮助我摆脱这些 PowerBuilder 沟渠。:(
问候,
/// Function Name: _wichTransObject
/// Parameters: Gets Datawindow control
/// Return: String name of the transaction object to use.
/// Purpose: when image is there in nested reports or the directly blob column is used in datawindow object,
/// only native connection can display images while ODBC fails. This function was written to select proper
/// transaction object so images are displayed in reports.
String dwSyntax, dwo, OriginalDwo
Long RptAt, RptDwoAt, BlobAt
dw_1.SetRedraw(FALSE)
OriginalDwo = dw_1.DataObject
dwSyntax = dw_1.Describe("datawindow.syntax");
/// Nested Reports may have images in them. That can be checked
/// find the report and if exist then pick its dwo and repeat same steps again for more reports
RptAt = Pos(dwSyntax, "report(", 1)
DO WHILE RptAt > 0
RptDwoAt = 0
RptDwoAt = Pos(dwSyntax, "dataobject=", RptAt) /// Get the dataobject of current report
IF RptDwoAt > 0 THEN
/// set the dataobject to dw_1 and explore it further
dwo = Mid(dwSyntax, RptDwoAt + 12, Pos(dwSyntax, "~"", RptDwoAt + 12) - ( RptDwoAt + 12 ))
dw_1.DataObject = dwo
/// explore the nested dataobject and look for blob column
dwSyntax = dw_1.Describe("datawindow.syntax");
BlobAt = Pos(dwSyntax, "keyclause", 1)
IF BlobAt > 0 THEN /// if blob exist then return NATCA
dw_1.DataObject = OriginalDwo
dw_1.SetRedraw(TRUE)
Return "NATCA"
END IF
END IF
LOOP
/// find the report and if exist then pick its dwo and repeat same steps again for more reports
BlobAt = Pos(dwSyntax, "keyclause", 1)
IF BlobAt > 0 THEN
dw_1.DataObject = OriginalDwo
dw_1.SetRedraw(TRUE)
Return "NATCA"
ELSE
dw_1.DataObject = OriginalDwo
dw_1.SetRedraw(TRUE)
Return "SQLCA"
END IF
/// 以下是调用上述函数的代码
String WTO
WTO = _WhichTransObject(dw_pb_report)
IF WTO = "NATCA" THEN
/// Make a native connection
dw_1.SetTransObject(NATCA)
ELSE
/// Go away with ODBC
dw_1.SetTransObject(SQLCA)
END IF
解决方案
重命名函数解决了这个问题。
对于我总是以下划线开头的事件,这从来都不是问题。但是,我猜测在不知道确切原因的情况下更改函数名称。
WTO = oayoay_whichtransobject(dw_pb_report)
从函数中获取正确的返回值。那是一个全球性的功能。
推荐阅读
- apache-camel - Camel - ActiveMQ 对空队列做出反应
- spring-boot - Spring Cloud Gateway 负载均衡类型
- java - 某些图像无法在适配器上加载(滑翔)
- python - 如何在kivy中使用其他包?
- python - PyQt 应用程序中的非阻塞 IPython Qt 控制台
- javascript - 发生onclick事件时如何将每个段落存储到javascript数组中?
- javascript - netlify lambda 函数中的 Dialogflow
- rest - 托管 Web 服务时我的 web.config 文件有问题
- javascript - 如何在 Dynamics CRM 中操作 HTML-Web 资源
- google-apps-script - 使用 Google 应用脚本将电子邮件标记为已读