我的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
答案 0 :(得分:0)
重命名功能解决了此问题。
对于我总是以下划线开头的事件,这从来都不是问题。但是,我猜测是在不知道确切原因的情况下更改了函数名称。 “ WTO = oayoay_whichtransobject(dw_pb_report)”从函数获得正确的返回值。那是一项全球职能。