Array comparison


Closed Thread
Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2006
    Posts
    89

    Default Array comparison

    I have an array that is 12 spaces long. I am trying to compare the second space of the array ( array[1] ) to a numerical value. The array contains ascii characters and numbers ( numbers in this case ). When array[1] is equal to or greater than 6, I want to make a pin go high. This is the code I am using:

    if array[1] >= 6 then
    high portb.7
    endif

    When I do this, it makes the pin high no matter what. I know for sure that array[1] is not greater than 6 because I can see what value it is on an lcd. Any ideas as to what I am doing wrong? Thanks for any help.

  2. #2
    Join Date
    Feb 2005
    Location
    Kolkata-India
    Posts
    563


    Did you find this post helpful? Yes | No

    Default Are you sure that is a number

    Hi there,

    IF you are using

    Code:
    LCDOUT, array[1]
    and it is displaying 6 on your LCD screen it essensially means that it is definately not a 6 but an ASCII representation of 6 which is decimal 54. So check it out.

    IF you are using

    Code:
    LCDOUT, DECarray[1]
    then it is a "6" and something else makes your port high. Why not include an else in your IF-ENDIF routine that turns of the bit when it is not greater than 6.

    As I always yell on this forum that a more bit of code is needed. For example how are you transferring values or getting values into an array. If by serial in and hyperterminal then it is definately "ASCII"
    Last edited by sougata; - 30th March 2006 at 06:09.
    Regards

    Sougata

Similar Threads

  1. Bits, Bytes Words and Arrays
    By Melanie in forum FAQ - Frequently Asked Questions
    Replies: 24
    Last Post: - 14th June 2016, 07:55
  2. Simple Array Demo
    By Archangel in forum Code Examples
    Replies: 5
    Last Post: - 15th February 2010, 04:46
  3. Array values changing
    By MyBuddy in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 29th October 2009, 23:13
  4. Filling pdu array with gps data!
    By camolas in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 4th October 2008, 00:54
  5. RS232 receive an array (packet)
    By ELCouz in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 12th February 2008, 05:02

Members who have read this thread : 1

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