The Best Solution


Closed Thread
Results 1 to 18 of 18

Hybrid View

  1. #1

    Default The Best Solution

    Hi ,

    I Have a question?

    What is the best Solution to simplify this code:

    if (ML_Value[0] <= $5A) or (ML_Value[0] => $82) then Summe_Alarm.0 = 1
    if (ML_Value[1] <= $5A) or (ML_Value[1] => $82) then Summe_Alarm.1 = 1
    if (ML_Value[2] <= $5A) or (ML_Value[2] => $82) then Summe_Alarm.2 = 1
    if (ML_Value[3] <= $5A) or (ML_Value[3] => $82) then Summe_Alarm.3 = 1
    if (ML_Value[4] <= $5A) or (ML_Value[4] => $82) then Summe_Alarm.4 = 1
    if (ML_Value[5] <= $5A) or (ML_Value[5] => $82) then Summe_Alarm.5 = 1
    if (ML_Value[6] <= $5A) or (ML_Value[6] => $82) then Summe_Alarm.6 = 1
    if (ML_Value[7] <= $5A) or (ML_Value[7] => $82) then Summe_Alarm.7 = 1

    if (ML_Value[0] > $5A) and (ML_Value[0] < $82) then Summe_Alarm.0 = 0
    if (ML_Value[1] > $5A) and (ML_Value[1] < $82) then Summe_Alarm.1 = 0
    if (ML_Value[2] > $5A) and (ML_Value[2] < $82) then Summe_Alarm.2 = 0
    if (ML_Value[3] > $5A) and (ML_Value[3] < $82) then Summe_Alarm.3 = 0
    if (ML_Value[4] > $5A) and (ML_Value[4] < $82) then Summe_Alarm.4 = 0
    if (ML_Value[5] > $5A) And (ML_Value[5] < $82) then Summe_Alarm.5 = 0
    if (ML_Value[6] > $5A) and (ML_Value[6] < $82) then Summe_Alarm.6 = 0
    if (ML_Value[7] > $5A) and (ML_Value[7] < $82) then Summe_Alarm.7 = 0

    Thanks a lot for any answer.

    Regard Pesti
    Last edited by Pesticida; - 26th May 2007 at 18:19.

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Code:
    for temp = 0 to 7
    if (ML_Value[temp] <= $5A) or (ML_Value[temp] => $82) then Summe_Alarm.temp = 1
    if (ML_Value[temp] > $5A) and (ML_Value[temp] < $82) then Summe_Alarm.temp = 0
    next temp

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


    Did you find this post helpful? Yes | No

    Default

    Yup but this should return a syntax or modifier error. Summe_alarm.0[temp]=x should cure the problem
    Steve

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

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by mister_e View Post
    Summe_alarm.0[temp]=x
    DOH! I just woke up, that's my excuse and I'm sticking to it.

  5. #5


    Did you find this post helpful? Yes | No

    Default

    Thank you for the very good solution !
    Another Question :-)
    Why I need Zero for : Summe_Alarm.0[Temp] and why not just
    Summe_Alarm.[Temp] ?
    I know that I receive a syntax but I dont understand what is the reason for use Zero !

    Regard Pesti
    Last edited by Pesticida; - 26th May 2007 at 21:00.

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


    Did you find this post helpful? Yes | No

    Default

    kind of fussy writing stuff i guess.

    further reference:
    http://www.picbasic.co.uk/forum/showthread.php?t=544
    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, 19:14
  2. Replies: 6
    Last Post: - 20th September 2008, 12:28
  3. Replies: 7
    Last Post: - 7th February 2008, 09:46
  4. Need PC software solution
    By mister_e in forum Off Topic
    Replies: 9
    Last Post: - 27th November 2005, 02:18
  5. Battery Solution
    By Keith in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 22nd July 2005, 06: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