using AND as an IF statement


Closed Thread
Results 1 to 28 of 28

Hybrid View

  1. #1
    mramos's Avatar
    mramos Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Melanie
    You can't go and buy a bottom-end Mercedes A10 and then complain it hasn't got the features and performance of a Mercedes 300SLK Turbo - yet both carry the same badge on the front.
    BASIC has had "if endif" in all that I have used since 1981 (excluding GWBASIC/BASIC) , on many platforms and OSs (uC to PC, Unix, MAC, etc).

    Far as the car (if a car was basic), I agree, but I need four tires, motor, steering wheel, transmission. "IF ENDIF" to me is part of basic (and be part of a writing basic code) and good programming practice. My thought is give up the i2C for ENDIF for the beginners. If they are buying devices like 12c and LCDs they should then spend some money on the PRO version.

    My plan was to port all my Atmel RVKBASIC programs to PBASIC. Without the proper conditional form of IF ENDIF, it would take some time. I have cancelled that plan for now.

    I would rather see clean (readable) code. I did not think I was tricked, the more I read, the more I think they are after the Parallax people. That is fine, but it woud make the standard basic more like a standard basic IMHO.

    I will pop in, I love to help people, I have good status (like yours) on some of the EE forums. Sadly, I feel I am now forced now spend even more for something that I think should be in there and out the cash for the standard.

    I can make an include a 16628.inc with the ports defined and others defines for the values I need to drop in the registers, that will not be an issues, I hope it has an include function in the standard... And I will make it work for future projects. And MEL did tell me a trick to solve the lack of support for certain older pics. So I am good. Just not porting all my stuff to PICS, too much work.

    Oh yea, in that post I edited, I did remove what I think the fellow meant in his original post. Sorry. He had a typo.

    Anyway, thanks for your input.

  2. #2
    mramos's Avatar
    mramos Guest


    Did you find this post helpful? Yes | No

    Default

    Bartman, thanks for understanding my point.. I feel the same way, that a basic command is "crippled" that should not be. The rest of it, I will work around.

    To have clean code (easy to understand, is that not why we like BASIC). It is needed.

    If I want to GOTO (jump all over) ASM has GOTO. hehehe.. The manual even
    starts walking about GOTOs all over.

    And the help files in the IDE should be broke up for better understanding.

    Again, my thoughts.

  3. #3
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by mramos
    ...that a basic command is "crippled" that should not be. ...
    It's not actually crippled, it is just not developed. MELabs put less work into it, they charge less for it. As you noted, it is much closer to ASM than it is to BASIC.

    Much like ErnieM's #2 and I am sure others, here is what I did in the past. It is not quite as clean as the PBP version but is quite readable nonetheless (one extra goto per if-then)

    ;in PBP

    If X = 5 then
    x = 5
    y = 6
    z = 7
    Else
    x = 7
    y = 0
    z = 6
    Endif

    ;in PBC

    If X<>5 then Else1
    x=5
    y=6
    z=7
    goto EndIf1
    Else1:
    x=7
    y=0
    z=6
    EndIf1:


    for the next If-Then, use Else2, Endif2, etc.


    Paul Borgmeier
    Salt Lake City, Utah
    USA
    Last edited by paul borgmeier; - 1st June 2006 at 07:40.

  4. #4
    mramos's Avatar
    mramos Guest


    Did you find this post helpful? Yes | No

    Default

    That will work if you have 3-5 IF ELSE ENDIF. Also, you might want to indent the code between the IF ELSE ENDIF.

    But it will make extra work.

  5. #5
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    I don't quite agree with you Paul.

    It is called "BASIC" and Basic commands are missing. I was using proper IF...THEN...ELSE...ENDIF 20 years ago when I learned Basic so to me it is rather incomplete without them. Yes, you can work around them. You shouldn't have to.

    As mentioned, there are other commands which aren't so "Basic" that could have been saved for PBP that are included with PBC. The trade off isn't the most useful I don't think.

    Bart

  6. #6
    Join Date
    Feb 2003
    Location
    Salt Lake City, Utah USA
    Posts
    517


    Did you find this post helpful? Yes | No

    Smile

    Quote Originally Posted by bartman
    Yes, you can work around them. You shouldn't have to.
    You do not have to - upgrade to PBP and problem solved! (That is what I did half a decade ago. Upgrading to PBP costs you no more than starting with PBP.)

    Quote Originally Posted by mramos
    That will work if you have 3-5 IF ELSE ENDIF. Also, you might want to indent the code between the IF ELSE ENDIF.

    But it will make extra work.
    I do not see why you are limited to 3-5 IF's - you should only be code space limited. Just increase the number for each Else EndIf and all will be well. Yes, it is a little extra work - I was just providing a work around that worked for me. As noted above, I solved my problem by upgrading and could not be happier.

    Paul Borgmeier
    Salt Lake City, Utah
    USA

  7. #7
    mramos's Avatar
    mramos Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier
    I do not see why you are limited to 3-5 IF's - you should only be code space limited. Just increase the number for each Else EndIf and all will be well. Yes, it is a little extra work - I was just providing a work around that worked for me. As noted above, I solved my problem by upgrading and could not be happier.
    USA
    No, I meant I personally would not go more than 3-5 (scratching the last number on a post-it note), I would get lost in my ELSE1/2/3/4 counts and generate more headaches.

    Anyway, I like Paul feel, leave out non-basic stuff so people will want the PBP, and let the basic be BASIC. The idea of basic, it to make it simple and teach beginners programming, without IF ENDIF structure, the code looks back, and would confuse a beginner.

    And in the last 20 years, BASIC evolved. It would be nice to see PBC do it as well.

    I wanted to port my Atmel programs over, but the free RVKBASIC has both like PBP, since it is a BASIC compiler for microcontrollers.

    But thanks for the idea, I have done it that way in the pass, a VERY long time ago. I could write a pre-processor to fix it, since I have no symbolic debugger I guess. I have no project at this time (do to the IF ENDIF issue). But if I get a new one I will look at the PBC again and the pre-processor option.

    I would think there are conditions when they compile PBC and PBC that it could be turned on easly, maybe a wist list on this forum?

    I can not imagine Paul and I are the only two, no there are another fellow.

    The Admin here is a "VERY" fair person and do not think she will be offened.

  8. #8
    Join Date
    Nov 2004
    Location
    Saskatchewan Canada
    Posts
    189


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by paul borgmeier
    You do not have to - upgrade to PBP and problem solved! (That is what I did half a decade ago. Upgrading to PBP costs you no more than starting with PBP.)
    I did upgrade. That's not the point I'm trying to make. They are Basic statements and they should be part of of Pic BASIC to begin with. Code is confusing and messy using work arounds. The key word here is BASIC. Don't call it BASIC if the basic commands aren't there.

    Call it "The Incentive to Upgrade sort of like Basic, but not really" software package. I shouldn't need to buy a pro version to do basic things using commands that have been part of the Basic language for a very long time.

    My first project was very, VERY simple and straight forward and really amounted to no more than flashing LEDs, but it was very frustrating writing it without those commands and I knew going in they were missing. I can feel the pain of anyone who expects a Basic command set, but gets only half of the important one. That is the point I'm trying to make.

    It is really sad that I had to upgrade to get that command set for my next project which was more complex, but still very simple. Hobby only, but I had to move up to a pro version to do it? Seems wrong.

    Bart

  9. #9
    dw_pic's Avatar
    dw_pic Guest


    Did you find this post helpful? Yes | No

    Default continued: Using AND as an IF statement

    Hi Paul,
    And thanks for your post.
    I am the originator of the post, and yours has been the closest to responding to its original meaning. Although, I have been entertained by the various responses. Thats part the fun.

    Its fun to watch a topic start and monitor its wild swings.
    I got the original PBC years ago when it first came out, and yes, I was extremely happy with it. I knew, from many programming languages previous, that the IF test statement was missing, and without it, have created many real fun projects. My latest (last winter) was an automated antenna tuner run by just one pic. It constantly monitors the frequency band of my transmitter, and pre-sets up the tuner which is located about 30 feet outside, for a low SWR on 9 different bands.

    Part of the fun for me, is being able to create something for under $50 which would haved cost me close to $400 off the shelf.

    I pondered whether to simply purchase PBP for this latest project.

    The weird thing is, I could sware that I figured out a way to make a semi- IF statement work using the AND in PBC on one of my very first projects.
    I have scratched through all of my old projects paperwork finding nothing.

    I figured, with all of the top notch programmers on this BB, that someone would have been doing something similar. Perhaps even a pre-built assembly subroutine that would simulate an IF statement.

    I guess not.
    But let the fun continue!!
    Thanks dude,
    dw_pic


    Quote Originally Posted by paul borgmeier
    It's not actually crippled, it is just not developed. MELabs put less work into it, they charge less for it. As you noted, it is much closer to ASM than it is to BASIC.

    Much like ErnieM's #2 and I am sure others, here is what I did in the past. It is not quite as clean as the PBP version but is quite readable nonetheless (one extra goto per if-then)

    ;in PBP

    If X = 5 then
    x = 5
    y = 6
    z = 7
    Else
    x = 7
    y = 0
    z = 6
    Endif

    ;in PBC

    If X<>5 then Else1
    x=5
    y=6
    z=7
    goto EndIf1
    Else1:
    x=7
    y=0
    z=6
    EndIf1:


    for the next If-Then, use Else2, Endif2, etc.


    Paul Borgmeier
    Salt Lake City, Utah
    USA

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