Macro

Q:
The problem appears to be the ‘&sql’ executing inside a try block, if this happens and then an error is generated afterwards, the crash occurs.
Changing various elements of the code causes the problem not to occur, this was the only combination where I could get it to happen reliably.

Code:
////////////////////////////////////////////////////////////////
// Event delegate for 'click' event
proc page1_section2_field2_click()

        dbName = "mydb"
        if ExecuteCommand1('open database &dbName')         
               
                private tab[]                   
                tab._name = "a"
                //This will raise an error
                if tab.name = "a"
                endif           
               
        endif   
       
endproc


function ExecuteCommand1(sql)

        try             
                &sql
                return .T.
        catch to e
                return .F.             
        endtry
       
endfunc

A:
Put the return statements outside the try/endtry block:
RETURN is also not allowed inside a TRY block or a CATCH block

Code:
function ExecuteCommand1(sql)

        try
                &sql
                // ? "Tried"
                lreturn  = .T.
        catch to e
                // ? "Caught"
                lreturn  = .F.
        endtry
                return lreturn
endfunc


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s