Code Compatibility Issue


Closed Thread
Results 1 to 22 of 22

Hybrid View

  1. #1
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Is anyone supposed to be able to actually read that?
    Everyone's got a "Colon", and they all stink.
    <br>
    It's exactly the same code, except for the changes/fixes...you know it, I know it, the guy that wrote it knows it and should be able to read his own stuff....and you don't have to scroll thru 17 pages of stuff to get to the end...

  2. #2
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by skimask View Post
    It's exactly the same code, except for the changes/fixes...
    Ha, It's exactly the same. Except EVERYTHING'S different.

    You've changed the SYMBOL's to VAR's, removed the LET's and changed a binary number to decimal. And while the program now looks completely different. After compiling, the HEX file will be byte for byte identical to the original code. No changes. No fixes.

    you know it, I know it, the guy that wrote it knows it and should be able to read his own stuff....and you don't have to scroll thru 17 pages of stuff to get to the end...
    Since it doesn't look anything like the original program, the "guy that wrote it" now has to spend probably several hours searching colon by colon, trying to find what it was that you changed. (took me an hour)

    And won't he be pissed after doing all that, only to find out that it doesn't make any difference. Because it's exactly the same program, just written with different words, and a really bad format.

    There's no way to follow the flow of the program. You can't see any type of structure. It's just a bunch of lines of code. Very long lines at that. My guess is that you have a Wide screen monitor and make the code fit a maximized window, all the way across the screen. For anyone with a normal sized screen, they're now scrolling left and right, instead of up and down. And when viewing in a browser, it all wraps around and you can't find where one line ends and the next one begins.

    And one last problem ... There's no room for comments.
    Come back to that program in 6 months, and you're going to need some laxitives for those Colon's.

    On a scale of 1-10, I'd give this formatting a 9 for the the best way to NOT write your program.
    <br>
    DT

  3. #3
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    Ha, It's exactly the same. Except EVERYTHING'S different.
    And I come back to reading the manual once again...

    You've changed the SYMBOL's to VAR's, removed the LET's and changed a binary number to decimal. And while the program now looks completely different. After compiling, the HEX file will be byte for byte identical to the original code. No changes. No fixes.
    The manual says 'Symbol can only be used to alias a variable, not to create it'. As far as the LET and SYMBOL, I referenced both of those at the beginning of the post... No changes, no fixes? I'm wondering...

    Since it doesn't look anything like the original program, the "guy that wrote it" now has to spend probably several hours searching colon by colon, trying to find what it was that you changed. (took me an hour)
    Huh...I'm fairly handy with an 'Enter' key, and maybe a little bit of the 'Delete' key. Only took me about a couple of minutes or so to get one command per line. And again, the guy should be able to recognize what's where in the first place.

    And won't he be pissed after doing all that, only to find out that it doesn't make any difference.
    Maybe so, but maybe he'll learn a bit of something here and there and fix his own problem.

    There's no way to follow the flow of the program. You can't see any type of structure. It's just a bunch of lines of code. Very long lines at that. My guess is that you have a Wide screen monitor and make the code fit a maximized window, all the way across the screen. For anyone with a normal sized screen, they're now scrolling left and right, instead of up and down.
    Could be... I run 16 x 12, turned 90 degrees. And who's to say what's normal? What does your newspaper, comic book, any other book look like? I'll bet if you put a page from one of those across your screen, it would fit a lot better if the screen was rotated about 90 degree, left or right... If anything, I'd say the way 'normal' people use a monitor is 'abnormal' compared to the way people have been reading printed material for years.

    And one last problem ... There's no room for comments. Come back to that program in 6 months, and you're going to need some laxitives for those Colon's.
    True...but I won't be coming back to it.

    On a scale of 1-10, I'd give this formatting a 9 for the the best way to NOT write your program.
    I think what you really mean is that you'd give this formatting a 9 for the best way NOT to write YOUR program.
    However, I'd give this formatting a 10 for the BEST way to write MY program.
    Last edited by skimask; - 6th July 2007 at 16:02.

  4. #4
    Join Date
    Apr 2006
    Location
    New Hampshire USA
    Posts
    298


    Did you find this post helpful? Yes | No

    Smile No comment....

    I use “find and replace” to “de-colon-ize” the code and flip it from a big horizontal file to a big vertical file.

    Two problems, have to watch for wanted colons like labels, and the vertical code still has no comments.

    -Adam-
    Ohm it's not just a good idea... it's the LAW !

  5. #5
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Pic_User View Post
    I use “find and replace” to “de-colon-ize” the code and flip it from a big horizontal file to a big vertical file. Two problems, have to watch for wanted colons like labels, and the vertical code still has no comments.
    -Adam-
    All the labels have a space after the colon. The colons in the middle of the code (except for here with the vB smilies and such) always have characters on both sides. And Cntrl-H (Word) and Cntrl-R (MCS) are my friend.

  6. #6
    Join Date
    Jul 2003
    Location
    Colorado Springs
    Posts
    4,959


    Did you find this post helpful? Yes | No

    Default

    The manual says 'Symbol can only be used to alias a variable, not to create it'.
    The only uses of SYMBOL in the original program was as an ALIAS. So nothing disagrees with the manual.

    And LET is shown in the manual as a valid statement. (although optional)
    Huh...I'm fairly handy with an 'Enter' key, and maybe a little bit of the 'Delete' key. Only took me about a couple of minutes or so to get one command per line.
    So to read your re-formatted program, we have to re-format it again???
    <br>
    DT

  7. #7
    skimask's Avatar
    skimask Guest


    Did you find this post helpful? Yes | No

    Default

    Quote Originally Posted by Darrel Taylor View Post
    The only uses of SYMBOL in the original program was as an ALIAS. So nothing disagrees with the manual.
    But it doesn't really agree either. doesn't say anything about being able to use one of the 'predefined' variables, such as PortA...

    So to read your re-formatted program, we have to re-format it again???
    <br>
    You don't have to do anything...

    Hey, at least I'm not wasting time posting spam for cheap phones, laptops and camera's!

  8. #8
    Join Date
    Sep 2004
    Location
    montreal, canada
    Posts
    6,898


    Did you find this post helpful? Yes | No

    Default

    Let's see if i remove my usual 'code template' from and try to format the code a little bit... i've never read/check it carefully if it make sense so far... at least, no compilation error.
    Code:
    <font color="#000000">        TRISA   = 0
            TRISB   = 2
            CMCON   = 7
            ADCON1  = 15
            ADCON0  = 0
            
            Ground_1    <font color="#000080">VAR </font>PortB.0
            Ground_2    <font color="#000080">VAR </font>PortB.3
            Lame_1      <font color="#000080">VAR </font>PortB.2
            Lame_2      <font color="#000080">VAR </font>PortB.5
            LED_1       <font color="#000080">VAR </font>PortB.6
            LED_2       <font color="#000080">VAR </font>PortB.7
            Off_1       <font color="#000080">VAR </font>PortA.0
            Off_2       <font color="#000080">VAR </font>PortA.2
            On_1        <font color="#000080">VAR </font>PortA.1
            On_2        <font color="#000080">VAR </font>PortA.3
            Positive_1  <font color="#000080">VAR </font>PortB.1
            Positive_2  <font color="#000080">VAR </font>PortB.4
            Speaker     <font color="#000080">VAR </font>PortA.4
            Switch      <font color="#000080">VAR </font>PortA.5
            
            Cal                 <font color="#000080">VAR BYTE
            </font>Ground_Lame_1       <font color="#000080">VAR BIT
            </font>Ground_Lame_2       <font color="#000080">VAR BIT
            </font>Lockout             <font color="#000080">VAR WORD
            </font>Lockout_Cal         <font color="#000080">VAR WORD
            </font>On1_Flag            <font color="#000080">VAR BIT
            </font>Off1_Flag           <font color="#000080">VAR BIT
            </font>On2_Flag            <font color="#000080">VAR BIT
            </font>Off2_Flag           <font color="#000080">VAR BIT
            </font>PG1_Count           <font color="#000080">VAR BYTE
            </font>PG2_Count           <font color="#000080">VAR BYTE
            </font>PL1_Count           <font color="#000080">VAR BYTE
            </font>PL2_Count           <font color="#000080">VAR BYTE
            </font>Positive_Bell_1     <font color="#000080">VAR BIT
            </font>Positive_Bell_2     <font color="#000080">VAR BIT
            </font>Positive_Ground_1   <font color="#000080">VAR BIT
            </font>Positive_Ground_2   <font color="#000080">VAR BIT
            </font>Positive_Lame_1     <font color="#000080">VAR BIT
            </font>Positive_Lame_2     <font color="#000080">VAR BIT
            
            
            </font>Cal=18
            Lockout_Cal=373
            <font color="#000080">HIGH </font>On_1
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>On_1
            
            <font color="#000080">HIGH </font>Off_1
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>Off_1
    
            <font color="#000080">HIGH </font>Off_2
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>Off_2
            
            <font color="#000080">HIGH </font>On_2
            <font color="#000080">PAUSE </font>500
            <font color="#000080">LOW </font>On_2
            
            <font color="#000080">INPUT </font>Lame_1
            <font color="#000080">INPUT </font>Lame_2
            
    Foil:
            <font color="#000080">INPUT </font>Positive_1
            <font color="#000080">INPUT </font>Positive_2
            <font color="#000080">INPUT </font>Ground_1
            <font color="#000080">INPUT </font>Ground_2
            <font color="#000080">HIGH </font>Positive_1
            Positive_Ground_1=Ground_1
            Positive_Lame_1=Lame_2
            Positive_Bell_1=Ground_2
            <font color="#000080">LOW </font>Positive_1
            <font color="#000080">INPUT </font>Positive_1
            <font color="#000080">INPUT </font>Positive_2
            <font color="#000080">INPUT </font>Ground_1
            <font color="#000080">INPUT </font>Ground_2
            <font color="#000080">HIGH </font>Positive_2
            Positive_Ground_2=Ground_2
            Positive_Lame_2=Lame_1
            Positive_Bell_2=Ground_1
            <font color="#000080">LOW </font>Positive_2
            <font color="#000080">INPUT </font>Positive_2
            <font color="#000080">HIGH </font>Ground_1
            Ground_Lame_1=Lame_1
            <font color="#000080">LOW </font>Ground_1
            <font color="#000080">INPUT </font>Ground_1
            <font color="#000080">HIGH </font>Ground_2
            Ground_Lame_2=Lame_2
            <font color="#000080">LOW </font>Ground_2
            
            <font color="#000080">IF </font>(Positive_Ground_1 = 0) <font color="#000080">AND </font>(Positive_Bell_1 = 0) <font color="#000080">THEN
                    </font>PG1_Count = PG1_Count + 1
                    <font color="#000080">ELSE
                        </font>PG1_Count = 0
                    <font color="#000080">ENDIF
            
            IF </font>(Positive_Ground_2 = 0) <font color="#000080">AND </font>(Positive_Bell_2 = 0) <font color="#000080">THEN
                    </font>PG2_Count = PG2_Count + 1
                    <font color="#000080">ELSE
                        </font>PG2_Count = 0
                    <font color="#000080">ENDIF
                    
            IF </font>(Positive_Lame_1 = 1) <font color="#000080">AND </font>(Positive_Ground_1 = 0) <font color="#000080">THEN
                    </font>PL1_Count = PL1_Count + 1
                    <font color="#000080">ELSE
                        </font>PL1_Count = 0
                    <font color="#000080">ENDIF
                    
            IF </font>(Positive_Lame_2 = 1) <font color="#000080">AND </font>(Positive_Ground_2 = 0) <font color="#000080">THEN
                    </font>PL2_Count = PL2_Count + 1
                    <font color="#000080">ELSE
                        </font>PL2_Count = 0
                    <font color="#000080">ENDIF
            
            IF </font>PL1_Count =&gt; Cal <font color="#000080">THEN
                    HIGH </font>On_1 
                    On1_Flag = 1
                    <font color="#000080">ENDIF
                    
            IF </font>PL2_Count =&gt; Cal <font color="#000080">THEN
                    HIGH </font>On_2 
                    On2_Flag = 1
                    <font color="#000080">ENDIF
                    
            IF </font>(PG1_Count =&gt; Cal) <font color="#000080">AND </font>(PL1_Count &lt; Cal) <font color="#000080">THEN
                    HIGH </font>Off_1 : Off1_Flag = 1
                    <font color="#000080">ENDIF
                    
            IF </font>(PG2_Count =&gt; Cal) <font color="#000080">AND </font>(PL2_Count &lt; Cal) <font color="#000080">THEN
                    HIGH </font>Off_2 
                    <font color="#000080">LET </font>Off2_Flag = 1
                    <font color="#000080">ENDIF
                    
            </font>LED_1 = Ground_Lame_1 
            LED_2 = Ground_Lame_2
            
            <font color="#000080">IF </font>(On1_Flag = 1) <font color="#000080">OR </font>(Off2_Flag = 1) <font color="#000080">OR </font>(On2_Flag = 1) <font color="#000080">OR </font>(Off1_Flag = 1) <font color="#000080">THEN
                    </font>Lockout = Lockout + 1
                    <font color="#000080">ELSE
                        </font>Lockout = 0
                    <font color="#000080">ENDIF
            
            IF </font>Lockout =&gt; Lockout_Cal <font color="#000080">THEN
                    PAUSE </font>2000 
                    <font color="#000080">LOW </font>On_1 
                    <font color="#000080">LOW </font>On_2 
                    <font color="#000080">LOW </font>Off_1 
                    <font color="#000080">LOW </font>Off_2 
                    On1_Flag = 0 
                    On2_Flag = 0 
                    Off1_Flag = 0  
                    Off2_Flag = 0        
                    <font color="#000080">ENDIF
            
            GOTO </font>Foil
            <font color="#000080">END
    </font>
    now comments, code section, steps should fit
    Last edited by mister_e; - 6th July 2007 at 19:12.
    Steve

    It's not a bug, it's a random feature.
    There's no problem, only learning opportunities.

  9. #9
    Join Date
    Feb 2006
    Posts
    20


    Did you find this post helpful? Yes | No

    Default

    I fixed the problem. As it turned out there was no problem with my origonal code. The problem lay in the configuration of pin B0. I traced the bad signals I was getting back to that point with my oscilloscope and when I switched the functions of B0 over to C7 it worked as expected. Also, there is absolutly nothing wrong with using the SYMBOL command the way I used it in my origonal code. It simply throws in an alias name for a pin, constant or whatever and makes the program easier to work with. I also prefer to include the LET command as it gives the code a more finished look and in my opinion makes it easier to read.

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. Loop with two motor and 2 sensors
    By MrRoboto in forum mel PIC BASIC
    Replies: 4
    Last Post: - 8th December 2008, 23:40
  3. Making Program Code Space your playground...
    By Melanie in forum Code Examples
    Replies: 15
    Last Post: - 19th July 2008, 08:26
  4. Code Issue - select case or 'if' issue - not sure why
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 2
    Last Post: - 7th October 2007, 08:52
  5. Code Issue? - Pin Labels
    By jamie_s in forum mel PIC BASIC Pro
    Replies: 4
    Last Post: - 12th July 2006, 16:28

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