Home AMX User Forum NetLinx Studio

Multi-Line Commenting out of code - Easy Question

I learned this in P1, but I've forgotten: what are the keystrokes used to comment out multiple lines of code? I thought it was an ALT+ command, but I can't figure it out!

Comments

  • jjamesjjames Posts: 2,908
    Setup Dependent?

    On my machine I've been using F2 for a while, but I don't know if that's the default.

    Typically though when I want to comment out a block of code, I use /* and */ to comment out a block.
    /*
    DEFINE_FUNCTION INTEGER	fnGET_PANEL
    (INTEGER nROOM)
    {
    	STACK_VAR INTEGER nCOUNTER;
    	
    	FOR(nCOUNTER = 1;nCOUNTER <= LENGTH_ARRAY(nPNL_AV); nCOUNTER++)
    	{
    		IF(nROOM == nPNL_AV[nCOUNTER])
    		{
    			RETURN nCOUNTER;
    			BREAK;
    		}
    	}
    }
    */
    
  • HedbergHedberg Posts: 671
    It's an edit menu item -block comment and uncomment. Keystrokes alt+E, then o. Or, you can assign any hotkey sequence you desire. I like alt+/
  • vegastechvegastech Posts: 369
    Nice!

    Thanks! Now that I know where to look, the keystroke combo Ctrl+B does it. I don't care what anyone else says about you guys, you're Awesome! ;-)
  • the8thstthe8thst Posts: 470
    You can also use wrap the code like so:
    (*
    DEFINE_FUNCTION INTEGER	fnGET_PANEL
    (INTEGER nROOM)
    {
    	STACK_VAR INTEGER nCOUNTER;
    	
    	FOR(nCOUNTER = 1;nCOUNTER <= LENGTH_ARRAY(nPNL_AV); nCOUNTER++)
    	{
    		IF(nROOM == nPNL_AV[nCOUNTER])
    		{
    			RETURN nCOUNTER;
    			BREAK;
    		}
    	}
    }     
    
    *)
    
  • ericmedleyericmedley Posts: 4,177
    Old Dog - New Tricks

    I've been doing this a long time and never knew this was available. Ha!

    I just did the old
    (*
    
    a whole bunch of code
    
    *)
    
    thiing myself.
  • DHawthorneDHawthorne Posts: 4,584
    I didn't know about the /* ... */ thing either. I just highlight the block and hit the comment button on the tool bar ... it pre-pends a // to every line, and removes them just as readily.
  • jjamesjjames Posts: 2,908
    DHawthorne wrote: »
    I didn't know about the /* ... */ thing either. I just highlight the block and hit the comment button on the tool bar ... it pre-pends a // to every line, and removes them just as readily.

    The *only* thing I don't care for about that way of it is if there's already comments a the line, it can get a finicky (at least it has for me), which is why I've always done the /* */ (and in the past (* *) ).

    As always - a million ways to skin the cat. ;)
Sign In or Register to comment.