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

    thanks mike , both option work ok , as it turned out i decided to go with "and" option , it just really large array group and as such it has about 30 " and " statements per match group of the records it takes about 10k compile for that section , large arrays do take space , i need to write the sorting index routine for this large array in PBP next , not seen any examples where using large data arrays to sort as yet

    cheers

    Sheldon

  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,
    Generally, using nested IF/THENs produces less code than using AND. For example
    Code:
    IF A = 1 THEN
      IF B = 2 THEN
        IF C = 3 THEN
          IF D = 4 THEN
              IF E = 5 THEN
                HIGH PortB.0
              ENDIF
          ENDIF
        ENDIF
      ENDIF
    ENDIF
    Compiled for a 16F628 is 30 words and 76 bytes for 18F4520 (all variables are bytes) while using AND, like this
    Code:
    IF (A = 1) AND (B = 2) AND (C = 3) AND (D = 4) AND (E = 5) THEN
      HIGH PortB.0
    ENDIF
    takes 79 words for the 16F628 and 162 bytes for the 18F4520.

    /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