Skip to content

FunctionLength - cDRReport

Methods - Properties - Events

Method Type

Function

Return Type

Integer

Arguments

Argument Description
sReportID ID of the report. Can be ID of the main report or the ID of a sub-report. This argument can be passed as an empty string. The empty string can be written as C_USEMAINDRREPORTID.
sFunction Content of the function to analyze.
iFunction Function index

Description

Analyzes the function content and returns the theoretical length of the function's return value. The result depends on the data type of the passed function, which can be found using the FunctionType method.

This method cannot be used before the report OCX object is initialized. The COM object creation is - when not done before - created as part of the OpenReport method.

DataFlex Framework usage

  • Web
  • Windows
  • FlexTron

Sample

Object oReport is a cDRReport
    Set psReportName to 'MyReport.dr'
End_Object

Object oShowFunctionReturnTypeButton is a Button
    Set Label to 'Return type of Function0'

    Function BuildReturnTypeString Integer iType Integer iLength Returns String
        String sResult

        Case Begin
            Case (iType = SQL_CHAR)
                Move 'char' to sResult
                Case Break
            Case (iType = SQL_NUMERIC)
                Move 'number' to sResult
                Case Break
            Case (iType = SQL_INTEGER)
                Move 'integer' to sResult
                Case Break
            Case (iType = SQL_DOUBLE)
                Move 'double' to sResult
                Case Break
            Case (iType = SQL_DATETIME)
                Move 'datetime' to sResult
                Case Break
            Case Else
                Move 'unknown' to sResult
                Case Break
        Case End

        Move (sResult * '[' + String(iLength) + ']') to sResult

        Function_Return sResult
    End_Function

    Procedure OnClick
        String sReportId sFunctionContent sText
        Integer iFunction iLength iType

        Get OpenReport of oReport to sReportId
        If (sReportId <> '') Begin
            Get psFunction of oReport sReportId 'Function0' to sFunctionContent
            Get FunctionIdByName of oReport sReportId 'Function0' to iFunction
            Get FunctionType of oReport sReportId sFunctionContent iFunction to iType
            Get FunctionLength of oReport sReportId sFunctionContent iFunction to iLength
            Get BuildReturnTypeString iType iLength to sText
            Send Info_Box ('Function0 returns' * sText)
            Send CloseReport of oReport sReportId
        End
    End_Procedure
End_Object