Results 1 to 3 of 3

Thread: [Answers] Macro

  1. #1
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135

    [Answers] Macro

    Q:
    Code:
    SELECT COUNT(GSID) AS CountEntry FROM bantam_stats!gamesheet WHERE gamenumber = &GameNumber AND hometeam IN ("&strTeamID")
    A:
    Remove the quotes:
    IN (&strTeamID)



    Q:
    Code:
    lcCursor = "Cursor2"
    open database southwind
    use shippers
    select 0
    select * from shippers into cursor (lcCursor)
    insert into shippers select * from (lcCursor)
    A:
    Why not just use a &cursor2
    lianja supports macro expressions too &(basename(cursor2))



    ​All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-12-14 at 02:23.

  2. #2
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    Q:
    My goal is to create a function to clear column data ('old value' and 'new value') from any array based on array name.
    A:
    you could pass the array name and macro substitute it where necessary.

    Code:
    public arr1(5,3)
    arr1(1,1) = 'txtName'
    arr1(1,2) = 'test'
    arr1(1,3) = 'testing'
    ? arr1
    
    proc myproc
        para myarray
        &myarray(1,2) = .f.
        &myarray(1,3) = .f.
        ? arr1
    endproc
    
    do myproc with "arr1"


    Q:
    what does the '&' sign just before the (field(i)) do? (? &(field(i)))
    A:
    The "&" character indicates a macro substitution:
    http://www.lianja.com/doc/index.php/%26



    All topics in [Answers] alphabetically:http://www.lianja.com/community/show...ll=1#post12352
    Last edited by josipradnik; 2016-12-14 at 02:22.

  3. #3
    Lianja MVP
    Join Date
    Dec 2012
    Location
    Croatia, Zagreb
    Posts
    1,135
    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


    All topics in [Answers] alphabetically: http://www.lianja.com/community/show...p?2717-Answers





Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Journey into the Cloud
Join us