help clean up some code


Closed Thread
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Feb 2012
    Location
    PERTH AUSTRALIA
    Posts
    838


    Did you find this post helpful? Yes | No

    Default Re: help clean up some code

    i always knew the if , then way produces less words but with 30 "and" compares per test , if then way look really bad and hard to follow, there seems to be no really short way to do large compares for arrays

  2. #2
    Join Date
    Oct 2005
    Location
    Sweden
    Posts
    3,624


    Did you find this post helpful? Yes | No

    Default Re: help clean up some code

    Hi,
    I haven't looked into it in detail but perhaps you could use ARRAYREAD with the WAIT or WAITSTR modifer to do what you want?
    Code:
    Value VAR BYTE[6]   ' Array of 6 bytes for the "new values"
    DummyVAR   'Needed for ArrayWrite to do what we want - possibly
    
    ARRAYREAD Value, 6, NoMatch, [WAIT("123456"), DummyVAR]    ' Search the Value-array for 123456, jump to NoMatch if not found.
    ' Continue here if match is found
    ' ....
    ' ....
    
    NoMatch:
    ' Continue here if no match was found
    The above tries to match the array to a static string of 123456, if what you want to match is changing then use a second array for the "match condition" and use WAITSTR instead of WAIT. At least that's how I THINK it should work, I haven't actually tried it though.....

    /Henrik.

Similar Threads

  1. Serial problem between BasicStamp code and PBP code
    By AllanZilkowsky in forum mel PIC BASIC Pro
    Replies: 22
    Last Post: - 6th April 2014, 03:15
  2. Working code but my layman approach uses too much code space
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 14th December 2012, 21:44
  3. How can I clean up my code?
    By Christopher4187 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 19th June 2012, 00:34
  4. How to drop from 6V to 5V a "clean" way?
    By flotulopex in forum Off Topic
    Replies: 20
    Last Post: - 10th October 2007, 11:03
  5. Code: Why is this code greater than 2000 words?
    By DrDreas in forum mel PIC BASIC Pro
    Replies: 9
    Last Post: - 1st June 2007, 20:51

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