Skip to content
TheChatArchiveThe Chat Archive
gpt-4-0314· OpenAIAi2 WildChat-4.8M (AI2)

i need to print only once this mess() even if the message should be printed more than…

  1. User

    i need to print only once this mess() even if the message should be printed more than once: function extern void function.ext.custom.function.2.command.execute() {
    r.print = tcyesno.no if ticst001.bfls = tcyesno.yes and ticst001.iswh <> 0.00 then select timfc001.pdno:temp.orno, min(timfc001.seqn):temp.fseq, max(timfc001.seqn):temp.tseq from timfc001 where timfc001.pdno = :ticst001.pdno and timfc001.pono inrange {:ticst001.pono} and {:ticst001.pono} group by timfc001.pdno as set with 1 rows

                selectdo
                endselect
                
                select	timfc001.*
                from	timfc001 for update
                where   timfc001.pdno = :ticst001.pdno
                and     timfc001.pono inrange {:ticst001.pono} and {:ticst001.pono}
                and     timfc001.seqn inrange :temp.fseq and :temp.tseq
                |as set with 1 rows
                selectdo
                        timfc001.qcnd = timfc001.qoro
                        db.update(ttimfc001,db.retry)
                                
                        select  whinh220.*
                        from    whinh220 for update
                        where   whinh220.oorg = :timfc001.oorg 
                        and     whinh220.orno = :timfc001.pdno 
                        and     whinh220.pono = :timfc001.pono 
                        and     whinh220.seqn inrange :temp.fseq and :temp.tseq                        
                        and     whinh220.lsta = whinh.lstb.staged
                |        as set with 1 rows
                        selectdo
                                whinh220.lsta = whinh.lstb.shipped
                                whinh220.qcnl = whinh220.qapr
                                db.update(twhinh220,db.retry)
                                select  * 
                                from    ticst001 for update
                                where   ticst001._index1 = {:ticst001.pdno, :ticst001.pono}
                                selectdo
                                        ticst001.iswh = 0
                                        db.update(tticst001, db.retry)
                                endselect
                        endselect
                endselect
        
                commit.transaction()
                refresh.curr.occ()
        else
                if     r.print = tcyesno.no  then
                        mess("ticst0001.01c", 1)                
                        r.print = tcyesno.yes
                endif
        endif
    

    }

  2. Assistant

    You can use a boolean variable to control the printing of the message only once. Here's the modified code:

    function extern void function.ext.custom.function.2.command.execute() {
    r.print = tcyesno.no bool hasPrinted = false // Add a bool variable "hasPrinted"

        if ticst001.bfls = tcyesno.yes and ticst001.iswh <> 0.00 then
                select  timfc001.pdno:temp.orno, min(timfc001.seqn):temp.fseq, max(timfc001.seqn):temp.tseq
                from    timfc001
                where   timfc001.pdno = :ticst001.pdno
                and     timfc001.pono inrange {:ticst001.pono} and {:ticst001.pono}
                group by timfc001.pdno
                as set with 1 rows
        
                selectdo
                endselect
                
                select    timfc001.*
                from    timfc001 for update
                where   timfc001.pdno = :ticst001.pdno
                and     timfc001.pono inrange {:ticst001.pono} and {:ticst001.pono}
                and     timfc001.seqn inrange :temp.fseq and :temp.tseq
                |as set with 1 rows
                selectdo
                        timfc001.qcnd = timfc001.qoro
                        db.update(ttimfc001,db.retry)
                                
                        select  whinh220.*
                        from    whinh220 for update
                        where   whinh220.oorg = :timfc001.oorg 
                        and     whinh220.orno = :timfc001.pdno 
                        and     whinh220.pono = :timfc001.pono 
                        and     whinh220.seqn inrange :temp.fseq and :temp.tseq                        
                        and     whinh220.lsta = whinh.lstb.staged
                |        as set with 1 rows
                        selectdo
                                whinh220.lsta = whinh.lstb.shipped
                                whinh220.qcnl = whinh220.qapr
                                db.update(twhinh220,db.retry)
                                select  * 
                                from    ticst001 for update
                                where   ticst001._index1 = {:ticst001.pdno, :ticst001.pono}
                                selectdo
                                        ticst001.iswh = 0
                                        db.update(tticst001, db.retry)
                                endselect
                        endselect
                endselect
        
                commit.transaction()
                refresh.curr.occ()
        else
                if     r.print = tcyesno.no and !hasPrinted then // Check if the message has already been printed
                        mess("ticst0001.01c", 1)                
                        r.print = tcyesno.yes
                        hasPrinted = true // Set the "hasPrinted" variable to true after printing the message
                endif
        endif
    

    }

  3. User

    mi stampa comunque 2 mess()

  4. Assistant

    My apologies for the confusion. Since you want the message printed only once, I assume that you want it printed once per call to the function. You can use a static variable to achieve this. Here's the modified code with a static variable:

    function extern void function.ext.custom.function.2.command.execute()
    {       
            static bool hasPrinted = false; // Change hasPrinted to a static bool variable
    
            r.print = tcyesno.no
    
            if ticst001.bfls = tcyesno.yes and ticst001.iswh <> 0.00 then
                    select  timfc001.pdno:temp.orno, min(timfc001.seqn):temp.fseq, max(timfc001.seqn):temp.tseq
                    from    timfc001
                    where   timfc001.pdno = :ticst001.pdno
                    and     timfc001.pono inrange {:ticst001.pono} and {:ticst001.pono}
                    group by timfc001.pdno
                    as set with 1 rows
            
                    selectdo
                    endselect
                    
                    select    timfc001.*
                    from    timfc001 for update
                    where   timfc001.pdno = :ticst001.pdno
                    and     timfc001.pono inrange {:ticst001.pono} and {:ticst001.pono}
                    and     timfc001.seqn inrange :temp.fseq and :temp.tseq
                    |as set with 1 rows
                    selectdo
                            timfc001.qcnd = timfc001.qoro
                            db.update(ttimfc001,db.retry)
                                    
                            select  whinh220.*
                            from    whinh220 for update
                            where   whinh220.oorg = :timfc001.oorg 
                            and     whinh220.orno = :timfc001.pdno 
                            and     whinh220.pono = :timfc001.pono 
                            and     whinh220.seqn inrange :temp.fseq and :temp.tseq                        
                            and     whinh220.lsta = whinh.lstb.staged
                            |as set with 1 rows
                            selectdo
                                    whinh220.lsta = whinh.lstb.shipped
                                    whinh220.qcnl = whinh220.qapr
                                    db.update(twhinh220,db.retry)
                                    select  * 
                                    from    ticst001 for update
                                    where   ticst001._index1 = {:ticst001.pdno, :ticst001.pono}
                                    selectdo
                                            ticst001.iswh = 0
                                            db.update(tticst001, db.retry)
                                    endselect
                            endselect
                    endselect
            
                    commit.transaction()
                    refresh.curr.occ()
            else
                    if r.print = tcyesno.no and !hasPrinted then // Check if the message has already been printed
                            mess("ticst0001.01c", 1)                
                            r.print = tcyesno.yes
                            hasPrinted = true; // Set the hasPrinted variable to true after printing the message
                    endif
            endif
    }
    

    Now the mess() function will only be called once per call to function.ext.custom.function.2.command.execute().

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.