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.
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)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...
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
And I come back to reading the manual once again...
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...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.
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.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)
Maybe so, but maybe he'll learn a bit of something here and there and fix his own problem.And won't he be pissed after doing all that, only to find out that it doesn't make any difference.
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.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.
True...but I won't be coming back to it.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.
I think what you really mean is that you'd give this formatting a 9 for the best way NOT to write YOUR program.On a scale of 1-10, I'd give this formatting a 9 for the the best way to NOT 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.
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 !
The only uses of SYMBOL in the original program was as an ALIAS. So nothing disagrees with the manual.The manual says 'Symbol can only be used to alias a variable, not to create it'.
And LET is shown in the manual as a valid statement. (although optional)
So to read your re-formatted program, we have to re-format it again???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.
<br>
DT
But it doesn't really agree either. doesn't say anything about being able to use one of the 'predefined' variables, such as PortA...
You don't have to do anything...So to read your re-formatted program, we have to re-format it again???
<br>
Hey, at least I'm not wasting time posting spam for cheap phones, laptops and camera's!![]()
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.
now comments, code section, steps should fitCode:<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 => Cal <font color="#000080">THEN HIGH </font>On_1 On1_Flag = 1 <font color="#000080">ENDIF IF </font>PL2_Count => Cal <font color="#000080">THEN HIGH </font>On_2 On2_Flag = 1 <font color="#000080">ENDIF IF </font>(PG1_Count => Cal) <font color="#000080">AND </font>(PL1_Count < Cal) <font color="#000080">THEN HIGH </font>Off_1 : Off1_Flag = 1 <font color="#000080">ENDIF IF </font>(PG2_Count => Cal) <font color="#000080">AND </font>(PL2_Count < 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 => 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>
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.
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.
Bookmarks