The Best Solution


Results 1 to 18 of 18

Threaded View

  1. #10
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    deuhhh, if my Sunday's brain and logic is still good... the conditions could be reduced a little bit, but multiple IF-THENs still execute faster
    Code:
    START:
    @   SIZESTART
        if (ML_Value[0] > $5A) and (ML_Value[0] < $82) then 
            Summe_Alarm.0 = 0
            else
                summe_alarm.0 = 1
            endif
    
        if (ML_Value[1] > $5A) and (ML_Value[1] < $82) then 
            Summe_Alarm.1 = 0
            else
                summe_alarm.1 = 1
            endif
        
        if (ML_Value[2] > $5A) and (ML_Value[2] < $82) then 
            Summe_Alarm.2 = 0
            else
                summe_alarm.2 = 1
            endif
    
        if (ML_Value[3] > $5A) and (ML_Value[3] < $82) then 
            Summe_Alarm.3 = 0
            else
                summe_alarm.3 = 1
            endif
    
        if (ML_Value[4] > $5A) and (ML_Value[4] < $82) then 
            Summe_Alarm.4 = 0
            else
                summe_alarm.4 = 1
            endif
    
        if (ML_Value[5] > $5A) And (ML_Value[5] < $82) then 
            Summe_Alarm.5 = 0
            else
                summe_alarm.5 = 1
            endif
    
        if (ML_Value[6] > $5A) and (ML_Value[6] < $82) then 
            Summe_Alarm.6 = 0
            else
                summe_alarm.6 = 1
            endif
    
        if (ML_Value[7] > $5A) and (ML_Value[7] < $82) then 
            Summe_Alarm.7 = 0
            else
                summe_alarm.7 = 1
            endif
    
    @   SIZEEND "IF-THEN-ELSE"
    
    @   SIZESTART
        for temp = 0 to 7
            if (ML_Value[temp] > $5A) and (ML_Value[temp] < $82) then 
                Summe_Alarm.0[temp] = 0
                else
                    Summe_Alarm.0[temp] = 1
                endif    
            next temp
    @   SIZEEND "FOR-TO-NEXT"
     
    @   SIZESTART
        temp = 0
        repeat
            if (ML_Value[temp] > $5A) and (ML_Value[temp] < $82) then 
                Summe_Alarm.0[temp] = 0
                else
                    summe_Alarm.0[temp]=1
                endif
            temp=temp+1
            until temp = 8
    @  SIZEEND "REPEAT - UNTIL"
    
    @   SIZESTART
        temp = 0
        while temp!=8
            if (ML_Value[temp] > $5A) and (ML_Value[temp] < $82) then 
                Summe_Alarm.0[temp] = 0
                else
                    Summe_Alarm.0[temp] = 1
                endif                
            temp=temp+1
            wend
    @   SIZEEND "WHILE - WEND"
    Quote Originally Posted by BenchMark Report

    IF-THEN-ELSE: 248 WORDS, 827 UsEC
    FOR-TO-NEXT: 70 WORDS, 1380 UsEC
    REPEAT - UNTIL: 66 WORDS, 1339 UsEC
    WHILE - WEND: 68 WORDS, 1364 UsEC
    Last edited by mister_e; - 28th May 2007 at 01:53.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

Similar Threads

  1. Strange I2C problem (and solution)
    By brid0030 in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 5th December 2008, 20:14
  2. Replies: 6
    Last Post: - 20th September 2008, 13:28
  3. Replies: 7
    Last Post: - 7th February 2008, 10:46
  4. Need PC software solution
    By mister_e in forum Off Topic
    Replies: 9
    Last Post: - 27th November 2005, 03:18
  5. Battery Solution
    By Keith in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd July 2005, 07:07

Members who have read this thread : 0

You do not have permission to view the list of names.

Posting Permissions

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