Results 1 to 4 of 4

Thread: Doc Error: NavigateForwardCustom code example missing ByRef

  1. #1

    Default Doc Error: NavigateForwardCustom code example missing ByRef

    Go to online help:

    NavigateForwardCustom

    There's a code example there:

    Code:
    Object oStatusHelper is a cWebButton
        Set piColumnSpan to 4
        Set psCaption to "Help Me Decide"
        Set piColumnIndex to 4
    
        Procedure OnClick
            Send NavigateForwardCustom of oZoomCustomerStatusHelp Self
            // note that using NavigateForward would work just as well in this sample
        End_Procedure
        
        Procedure OnGetNavigateForwardData tWebNavigateData NavigateData Handle hoToView
            String sValue
            Boolean bChecked
            Get GetChecked of oCustomerStatus to bChecked
            WebGet psValue of oCustomerName to sValue
            Get NamedValueAdd NavigateData.NamedValues "name" sValue to NavigateData.NamedValues
            Get NamedValueAdd NavigateData.NamedValues "status" bChecked to NavigateData.NamedValues
        End_Procedure
        
        Procedure OnNavigateBack Handle hoCallback tWebNavigateData NavigateData
            Boolean bFound bOldStat bNewStat
            String sValue
            Get NamedValueGet NavigateData.NamedValues "newstatus" to sValue
            Get GetChecked of oCustomerStatus to bOldStat
            Move (sValue="1") to bNewStat
            If (bNewStat<>bOldStat) Begin
                Send SetChecked of oCustomerStatus bNewStat
                WebSet pbChanged of oCustomerStatus to True
            End
        End_Procedure
    End_Object
    The above example can never work as the example code is missing a ByRef.

    Eg.
    Code:
    Procedure OnGetNavigateForwardData tWebNavigateData NavigateData Handle hoToView
    Should have been:
    Code:
    Procedure OnGetNavigateForwardData tWebNavigateData ByRef NavigateData Handle hoToView
    --
    Wil

  2. #2
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,849

    Default Re: Doc Error: NavigateForwardCustom code example missing ByRef

    Thanks Wil, I've made a note.

  3. #3

    Default Re: Doc Error: NavigateForwardCustom code example missing ByRef

    Dennis,

    Cool.

    Maybe I should clarify if it helps.
    Being lazy I had copied that example code and adjusted it for my needs.
    Adjusted the NavigateData variable to pass a few parameters to the view that would be invoked.
    Even called "Send SetNavigateData of hoToView NavigateData" but the data was always empty when looking at it from hoToView.

    The reason is this code in cWebObject:
    Code:
        // Private: Callback method sent to the callback control when a view receives NavigateForward.
        // This should populate the tWebNavigateData in the default way according to the control's data bindings.
        {Visibility=Private}
        Procedure GetNavigateForwardData Handle hoView tWebNavigateData ByRef NavigateData
            // ask the view to load the default data
            Send LoadDefaultNavigateForwardData of hoView Self (&NavigateData)    
            // Send event hook for manually populating the NavigateData struct.
            Send OnGetNavigateForwardData (&NavigateData) hoView
        End_Procedure
    Because of the missing ByRef the data stays whatever it is before calling OnGetNavigateForwardData.
    As such you cannot change the data unless you define the variable as ByRef in the method.
    It wasn't until I debugged it that I saw why it was behaving this way.

    --
    Wil

  4. #4
    Join Date
    Nov 2008
    Location
    Round Rock, TX
    Posts
    8,849

    Default Re: Doc Error: NavigateForwardCustom code example missing ByRef

    That makes sense. :-)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •