Code tags not preserving formating.

jpanhalt

Joined Jan 18, 2008
11,087
You posted as Text, not code. Try without the "=Text" or use the appropriate "equal." For Assembly, it is "=ASM" or "=MPASM." I suspect C is something like =C, but I am not sure.
 

dl324

Joined Mar 30, 2015
16,845
When I looked at the code block, there was no formatting to maintain. When I did some formatting, it was maintained:
Code:
  if (PIR4bits.CCP5IF == 1)  {
    PIR4bits.CCP5IF = 0;
    unsigned char thisPeriod;

    thisPeriod = CCPR5H;
    thisPeriod = (thisPeriod << 8) | CCPR5L;

    ticksPerRev = abs(thisPeriod - prevCCPPeriod);
    prevCCPPeriod = thisPeriod;
    revTimeUpdated = 1;
  }
 

jpanhalt

Joined Jan 18, 2008
11,087
Replacing tabs with spaces may be required for proper formatting.

Since a tab is a user setting, I am not sure code tags allow that setting to be read. MPLAB (and presumably MPLABX) allow you to use tabs and automatically replaces then with spaces. What is your setting? In MPLAB, it is in editor properties:
upload_2019-1-25_3-37-44.png

If your setting is the same, cut and paste would read spaces.
 

jpanhalt

Joined Jan 18, 2008
11,087
Code tags used to accept tabs.
Are you sure? Is it possible that what you thought there were tabs, were converted to spaces? What is your properties setting for tabs to spaces in MPLABX?

Perhaps most important, several other members have posted properly formatted C-code as text since your original post.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Are you sure? Is it possible that what you thought there were tabs, were converted to spaces? What is your properties setting for tabs to spaces in MPLABX?

Perhaps most important, several other members have posted properly formatted C-code as text since your original post.
As my boss would say "Are you Pittsburgh sure"? ;)

Yeah I am Pittsburgh sure. Meaning I suspect I am sure but not certain.

Not sure where he got that. I have lived here all of my life and never heard that phrase. ;)
 

WBahn

Joined Mar 31, 2012
29,978
When you paste code into a dialog box, how it behaves is browser-dependent. Keep in mind that, at the moment it is pasted in, the browser has no idea about code tags or anything else -- it's just text being pasted into a dialog box. Many browsers believe that all white-space should be reduced to a single white space and that there should never be white space at the beginning of a line of text. This is something that changes from time to time as the browser updates. I suspect the mentality goes back to the days when transmission speeds were so slow and storage costs so high that eliminating double spaces represented a significant performance and cost gains, but I get so tired of the browser deciding that it knows what I want more than I do.

I have found that I have to double check every time I create a code tag entry and often have to manually insert spaces to get the indenting I want.
 

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
What the heck is the difference between a tab and an indent?

P.S> I did upgrade MPLabX recently. I wonder if there is a difference in the default settings for the tab/space thing?
 

WBahn

Joined Mar 31, 2012
29,978
What the heck is the difference between a tab and an indent?

P.S> I did upgrade MPLabX recently. I wonder if there is a difference in the default settings for the tab/space thing?
I was wondering the same thing. My best guess is it refers to selecting a block of code and then indenting it using some toolbar icon. I have no idea why you would ever make that level of indenting different than what you get with the tab key, but maybe they saw some use scenario for it.
 

jpanhalt

Joined Jan 18, 2008
11,087
What the heck is the difference between a tab and an indent?

P.S> I did upgrade MPLabX recently. I wonder if there is a difference in the default settings for the tab/space thing?
Why don't you check?

Edit:
The Help tab defines indent. That definition seems to be C-compiler "optimized. " However, both indents and tabs can be converted to spaces if the appropriate box is checked (see post #12)
upload_2019-1-25_14-2-44.png
or if you use "indent" it seems to be the default and maybe cannot be changed. Since you use tabs, that might be a setting you should check.
 
Last edited:

Thread Starter

spinnaker

Joined Oct 29, 2009
7,830
Well it is set so I assume it was set before when it was working. So there must be another issue. Perhaps a change in browser as WBahn suggested.
 
Top