Why does code collapse in threads?

807
3
Jump to solution
07-02-2021 09:07 PM
LanceKirby2
Occasional Contributor II

The title says it all. Why does code collapse from a vertical formatted structure to a horizontal unformatted structure when people reply with code? Is there anyway to view the original formatted code?

0 Kudos
1 Solution

Accepted Solutions
DanPatterson
MVP Esteemed Contributor

two reasons

first, people weren't using Code formatting ... the Community Version - Esri Community

to format their code

second, threads that pre-date the transition from "GeoNet" to "esri Community" were often collapsed because the pre-existing code formatting structure didn't carry forward, leaving most/many posts with their code flattened.    Check the date of the pre-existing code, if it was before Nov 2020 it in all likelihood has flattened code.  You can copy and recover the code, but you will have to recreate the indentation levels while parsing into lines of code.

For example, from  Transect lines, parallel lines, offset lines - Esri Community

 

rads = np.deg2rad(bearing)    dx = np.sin(rads) * dist    dy = np.cos(rads) * dist    #    n = len(bearing)    N = [N, n][n>1]  # either the number of lines or bearings‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

has to be reformatted to read

 

rads = np.deg2rad(bearing)    
dx = np.sin(rads) * dist    
dy = np.cos(rads) * dist    
#    
n = len(bearing)    
N = [N, n][n>1]  # either the number of lines or bearings;

 

 

 

 


... sort of retired...

View solution in original post

0 Kudos
3 Replies
DanPatterson
MVP Esteemed Contributor

two reasons

first, people weren't using Code formatting ... the Community Version - Esri Community

to format their code

second, threads that pre-date the transition from "GeoNet" to "esri Community" were often collapsed because the pre-existing code formatting structure didn't carry forward, leaving most/many posts with their code flattened.    Check the date of the pre-existing code, if it was before Nov 2020 it in all likelihood has flattened code.  You can copy and recover the code, but you will have to recreate the indentation levels while parsing into lines of code.

For example, from  Transect lines, parallel lines, offset lines - Esri Community

 

rads = np.deg2rad(bearing)    dx = np.sin(rads) * dist    dy = np.cos(rads) * dist    #    n = len(bearing)    N = [N, n][n>1]  # either the number of lines or bearings‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

 

has to be reformatted to read

 

rads = np.deg2rad(bearing)    
dx = np.sin(rads) * dist    
dy = np.cos(rads) * dist    
#    
n = len(bearing)    
N = [N, n][n>1]  # either the number of lines or bearings;

 

 

 

 


... sort of retired...
0 Kudos
LanceKirby2
Occasional Contributor II

Thanks @DanPatterson. You are always very helpful.

That explains it all. Very unfortunate that happened in the transition as some code isn’t as simple to reformat as your example above.

0 Kudos
DanPatterson
MVP Esteemed Contributor

Tell me about it... I have over 100 blog posts that got de-formatted 😉

 


... sort of retired...
0 Kudos