IF..AND/OR..THEN and PBPL


Closed Thread
Results 1 to 6 of 6
  1. #1
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146

    Default IF..AND/OR..THEN and PBPL

    hi all,
    I have just been caught out introducing PBPL into some older code, I have prepared an example which demonstates the observation.

    This demo is on an 18F4520 PBP 2.5 MCSP 3.0.0.5.
    Code:
    define OSC 16
    
    
    '---------------------------- debug defines  -----------------------------------
    
    DEFINE DEBUG_REG PORTB 
    DEFINE DEBUG_BIT 5
    DEFINE DEBUG_BAUD 38400    
    DEFINE DEBUG_MODE 0        
    '-------------------------------------------------------------------------------
    
    
    
    
    W0      var word
    W1      var word(8)
    Counter var byte
    Index   var byte
    Sum     Var word
    
    Counter = 0
    Sum = 0
    
    
    
    Start:
    w1[0] = 567
    w1[1] = 568
    w1[2] = 566
    w1[3] = 566
    w1[4] = 568
    w1[5] = 586
    w1[6] = 567
    w1[7] = 567
    
    
    w0 = w1[0]       'place first value of w1array into W0 to be able to compare against it  
    for index = 1 to 7
        if w1[index] < (w0 - 2) or w1[index] > (w0 + 2) then
          
          debug #w1[index],"   Value out of range" ,10
               
        else
          Sum = Sum + w1[index]
          Counter = Counter + 1  
          debug #w1[index]," within range  ",10 
        endif
    next index
    
    pause 1000
    goto start
    
    END
    If this code is compiled using PBP the IF...AND...THEN routine works perfectly, but if you compile with PBPL then it fails. Is it possible that there some additional fuses I should be setting when converting from PBP to PBPL?

    I have found that using the AND/OR in an IF..THEN statement is very code hungry so I try not to use it that often. But I was not expecting this problem at all, took me quite a long time to find it and even then it did not occur to me it was associated with PBPL

    Duncan

  2. #2
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    if w1[index] < (w0 - 2) or w1[index] > (w0 + 2) then

    Duncan
    I believe that's similar to a problem I had a couple of months ago. There's a simple fix in one of the PBPL macro files for it, but I'm at work and don't have it handy. Involves changing a CT to BT or something along those lines. It's not the AND/OR that causes the problems, it's the index'ing part of the problem. I just don't remember what it is...
    If you don't get a fix from MeLabs or have it posted here when I get home today, I'll post the fix in a fresh thread....(I know...should've done that weeks ago...)

    Besides that...
    w1 var word(8)
    should be
    w1 var word[8]
    Last edited by skimask; - 25th January 2008 at 14:16.

  3. #3
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Thanks Skimask,

    I did not think to check melabs for a patch

    I downloaded the patch and the issue has gone away


    I seem to always think that it is me that is doing something wrong, a confidence issue.

    At least I am up to speed with that code now , so I am considering making some improvements whilst I know what is going on.

    Maybe we should all be on an email mailing list at melabs for announcements and patches, after all everybody and thier father are trying to bombard me with stuff I do not want or have never heard of before. Why not things I should be kept up to date with?

    Thanks again

    duncan

  4. #4
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by duncan303 View Post
    Thanks Skimask,
    I did not think to check melabs for a patch
    I downloaded the patch and the issue has gone away
    I seem to always think that it is me that is doing something wrong, a confidence issue.
    At least I am up to speed with that code now , so I am considering making some improvements whilst I know what is going on.
    Maybe we should all be on an email mailing list at melabs for announcements and patches, after all everybody and thier father are trying to bombard me with stuff I do not want or have never heard of before. Why not things I should be kept up to date with?
    Thanks again
    duncan
    The patch fixes a few things...
    The issue I was talking about is a bit different (deals with variables and constants inside the brackets, easy workaround, but still broken). I found a piece of paper here at work, under another pile at my desk with notes on it. The issue I found is a very small issue and I'd doubt highly somebody else will come across it and cause them a headache also.
    Most patches and issues are posted here in one way or another, but, as I've found, I just go back to MeLabs site once in awhile just to see what's up. Works for me, and keeps down the overall email traffic
    Last edited by skimask; - 25th January 2008 at 14:54.

  5. #5
    Join Date
    Oct 2004
    Location
    North Norfolk UK
    Posts
    146


    Did you find this post helpful? Yes | No

    Default

    Yes I accept that it would probably be better to keep the overall email traffic down.

    I am not on PBP every day so it might be helpfull for somebody like me. I have to admit that I do tend to leave major upgrades either hardware or software for as long as possible to try a keep a longer period of stability to work in. Therefore I should check regularily for patches.

    As to the syntax........ well spotted. I just checked the new and old manuals to see where I have got it into my head to use ( ) in defining an array. It is certainly not there. I seem to have used it like that for years, obviously a bad habit......... but not any more

    Duncan

  6. #6
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Thumbs up

    Quote Originally Posted by duncan303 View Post
    As to the syntax........ well spotted. I just checked the new and old manuals to see where I have got it into my head to use ( ) in defining an array. It is certainly not there. I seem to have used it like that for years, obviously a bad habit......... but not any more
    Duncan
    QBASIC?
    GW-BASIC?

Similar Threads

  1. PBPL and TCP/IP
    By edtp in forum Ethernet
    Replies: 10
    Last Post: - 4th March 2011, 19:35
  2. PBP and PBPL
    By keymuu in forum mel PIC BASIC Pro
    Replies: 45
    Last Post: - 30th January 2009, 17:58
  3. USB PBPL Compile errors
    By Rob in forum USB
    Replies: 11
    Last Post: - 7th April 2008, 08:18
  4. PBPL and MPLAB ... registration ?
    By Acetronics2 in forum mel PIC BASIC Pro
    Replies: 1
    Last Post: - 13th December 2007, 17:17
  5. PBP 2.50 pbpw vs pbpl .exe
    By Archangel in forum mel PIC BASIC Pro
    Replies: 10
    Last Post: - 21st September 2007, 15:28

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