Home AMX General Discussion

How to post code with formatting in place

zasadatzasadat Junior MemberPosts: 24

I pasted several lines of code, from a .AXS file, into a comment box on this forum. All the tabs were removed, making it hard to read. How do I keep the formatting in place. Additionally/alternatively, how can I upload a .AXS file?

Answers

  • HARMAN_ChrisHARMAN_Chris Harman Integrated Technologies Group (ITG) Posts: 332
    edited February 2019

    The trick is the "~" Use 3 x ~ to create and end a code block. It does require a carriage return after the ~~~

    code here 
    

    To attach a file to your post, look at the formatting and edit options at the top of your typing dialog box. The Folder Paper icon is the file attach option.

  • zasadatzasadat Junior Member Posts: 24

    I do not see the Attachment icon.
    I also do not see how the triple tildes create the "code here" box.
    FWIW, I am using Google Chrome.

  • HARMAN_ChrisHARMAN_Chris Harman Integrated Technologies Group (ITG) Posts: 332

  • zasadatzasadat Junior Member Posts: 24

    The triple tilde trick is doing the trick.
    I do not have the file upload icon that you have highlighted.
    Thanks, Chris.

  • richardhermanrichardherman not-so-junior member Posts: 268

    @zasadat said:
    I do not have the file upload icon that you have highlighted.

    Neither do I.

  • viningvining X Member Posts: 4,368
    edited February 2019

    Just highlight your code, press the format tab and press code.

    Just highlight your code, press the format tab and press quote.

    Just highlight your code, press the format tab and press spoiler.

  • fogled@mizzou[email protected] h4x354x0r Posts: 549
    edited February 2019

    Thank you! This is what I was looking for. I'd seen the tilde in some of the markdown docs, but never tried the triple tilde. Now, I'm hooked!

    monospace 
     monospace 
      monospace 
       monospace 
        monospace
    
  • viningvining X Member Posts: 4,368
    edited February 2019

    Tilde test:

     WHILE(nCnt != nCnt2 || nBegin)
          {
          nBegin = 0;
          nFBS = find_string(iStr,iTagPairs[1][1],nFBS);
          nFBS2 = find_string(iStr,iTagPairs[1][2],nFBS2);
          if(nFBS && (nFBS < nFBS2))
               {
               nCnt++;
               if(nCnt == 1)
                {
                nIndxs[1] = nFBS;
                }
               nFBS = nFBS + length_string(iTagPairs[1][1]);
               nFBS2 = nFBS;
               }
          else if((nFBS2 && !nFBS) || (nFBS2 && nFBS2 < nFBS))
               {
               nCnt2++;
    
               if(nCnt == nCnt2)
                {
                nIndxs[2] = nFBS2;
                if(iInclTags)
                 {
                 nIndxs[2] = (nIndxs[2] + length_string(iTagPairs[1][2]));
                 }
                else if(nIndxs[2])
                 {
                 nIndxs[2] = nIndxs[2]-1;
                 nIndxs[1] = (nIndxs[1] + length_string(iTagPairs[1][1]));
                 }
                fnFunctions_Debug("'GetTag_n_EndTag_Indxs, nCnt-[ ',itoa(nCnt),' ], nFBS-[ ',itoa(nFBS),' ], nIndxs-[ ',itoa(nIndxs[1]),',',itoa(nIndxs[2]),' ] :DEBUG<',ITOA(__LINE__),'>'");
    
                RETURN nIndxs;
                }
               else
                {
    

    Didn't know about the triple tilde use.

  • richardhermanrichardherman not-so-junior member Posts: 268

    Don't know if you're indenting like advised in the 'AMX style guide*', but if so, it still looks wrong.

    *

    INDENTATION
    Use the default NetLinx Studio indentation. Viewing someone else's code that uses different indentation can be very messy.
    - Set tab stops to every 8 characters (default).
    - Indent before text with 4 characters (default).
    - Enable auto-indentation.
    Matching braces should always line up.
    Statements within the same encapsulation should always line up.

  • viningvining X Member Posts: 4,368

    I tninks it’s the way the forum renders the code cuz my indents are all the same, might be 8 but don’t remember. I line up my braces too but most coder here don’t from what I’ve seen over the years, they follow the norm for other languages which isn’t readable to me. I like a lot of space and put braces where they’re not needed just to create more space. I’ve never bothered to make my code pleasing to anyone but myself since I’m the only one who ever sees it and has to deal with it and these days its not often.

  • fogled@mizzou[email protected] h4x354x0r Posts: 549

    @vining said:
    I’ve never bothered to make my code pleasing to anyone but myself

    Nice to hear someone else say that. My code is lots of comments, extra spaces, but I still don't know why I don't put the opening curly bracket on the next line. Modifying portions of the code would be easier that way.

    But I'm fairly certain the code I write is "end of line" - it's not ever going to be modified or really looked at by anyone but me, and if/when it inevitably gets redone it gets waxed and completely replaced from scratch.

    I don't always put away all my laundry either, sometimes I just leave it in a pile on the floor and use it from there.

Sign In or Register to comment.