Can you give varied levels of priority to blocks of code?


Closed Thread
Results 1 to 8 of 8

Hybrid View

  1. #1
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Smile That Simple?

    HI STEVE B.

    Wow that is very close to my first try which I could not get to work I had used button commands and IF THEN statements and included an ENDIF statment within the subroutine, I see you put them all at near the end of program, I am curious about the indenting you used, is it there so you the programmer can keep it straight in your mind or does it affect the program in some way?

    Anyway I want to thank you and Melanie for your help, I really appreciate it!
    I hope to be helpful to someone else someday!

    Best Regards
    Joe Stokes

  2. #2
    Join Date
    May 2006
    Location
    Del Rio, TX, USA
    Posts
    343


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Joe S.
    I am curious about the indenting you used, is it there so you the programmer can keep it straight in your mind or does it affect the program in some way?
    Joe,
    Indenting is just a way to keep nested levels of code straight. It is purely technique and does not affect the code in any way (with the exception of Labels, which should start in the first column). I've seen a number of different schemes. It is just one aspect in organizing your programs. The key is find something that works for you and sticking to it religiously. Then, when you come back to a piece of code you wrote 6 months ago (or you have a complex, many line program), you can quickly reaquiant yourself with what is happening and find what you need easily.

    Here is a very nice post by Melanie on the idea of program structure. If you have nothing to start from, you can't get much better than learning the ropes from someone like Melanie.

    I see you put {the IF... statements} all at near the end of program
    Again, in this case just another way to orginize things to hopefully make the logic a little clearer.

    Wow that is very close to my first try which I could not get to work
    Maybe just for fun you could post the code you tried that did not work, and folks here could show you why it didn't. Could be a chance to learn from some very smart, capable folks (from whom I myself am indepted greatly). If so, look here for formating, particularly using [code]...[/code] to format your posts so they are more readable.

    Good Luck,
    Steve

  3. #3
    Join Date
    Aug 2006
    Location
    Look, behind you.
    Posts
    2,818


    Did you find this post helpful? Yes | No

    Cool Gone

    I wrote over the file I tried originally, with the while / wend code but I figured out why it didn't work, I had made labels and coded them this way
    b1 var byte
    b2 var byte
    b3 var byte
    LABEL!:

    button1 ,port ,...
    anyway I copied the button command out of the book assigned the variables to them and used IF Var b1= 1 then
    serout 7,n2400, [" string"]
    endif
    LABEL2: more of the same

    and what it did was display all the strings in a loop

    so I trashed that code and went with my no variable code
    LABEL1: while PortA.0 = 1
    serout ["mystring"]
    wend

    LABEL2: WHILE PortA.1 =1
    SEROUT ["more strings"]
    wend
    ETC . . .

    and that would display at the push of a button
    whereas you put the if statements under the main routine and made the LABEL statements into sub routines being called by the IF's
    Like ah said I was Green ! I've only had PBP for about 2 weeks now and never coded anything before, . . . well PC Batch files, but nothing else.
    I needed to give my code precedence and you showed me the way!
    AND IT WORKS!

    Thank You again
    Joe Stokes

    " I have never been lost, but there were a few times I was a might bewildered" ... Danial Boone

Similar Threads

  1. How much code space do PBP statements use.
    By Darrel Taylor in forum Code Examples
    Replies: 5
    Last Post: - 13th February 2009, 21:31
  2. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  3. Re-Writing IF-THEN-AND-ENDIF code?
    By jessey in forum mel PIC BASIC Pro
    Replies: 6
    Last Post: - 18th August 2006, 17:23
  4. Still HSEROUT woes
    By Charles Linquis in forum mel PIC BASIC Pro
    Replies: 34
    Last Post: - 11th July 2006, 21:13
  5. Timer PIC16F57
    By leonel in forum mel PIC BASIC Pro
    Replies: 25
    Last Post: - 1st July 2005, 08:14

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