Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

NOOP (No Operation)


  • Please log in to reply
6 replies to this topic
jballi
  • Members
  • 1029 posts
  • Last active:
  • Joined: 01 Oct 2005
Although I've given this some thought, I'm sure I haven't considered everything so... I'm running it up the flag pole to see if it waves.

It would nice to have a command that does nothing. NOOP (short for No OPeration) might be a good name for this command. The syntax for this command might be the following:

NOOP
NOOP {Whatever the heck you want to enter here}Although the number of uses for this command is many, my intended use for this command is to programmatically replace other AHK code (obsolete, debug, etc.).

Although commenting out or replacing AHK code with brackets {} will work a majority of the time, some syntax cannot be programmatically accounted for unless I want to write a 1000-line script to evaluate all possibilities. Replacing the code with low-cost dummy statement (a simple assignment statement for example) will also work there is still some cost involved. A NOOP command would provide the best bang without the buck.

Thank you for your consideration.

PhiLho
  • Moderators
  • 6850 posts
  • Last active: Jan 02 2012 10:09 PM
  • Joined: 27 Dec 2005
Sorry, but I fail to see "the many uses for this command"...
And I still don't see why a simple ; can't do the job... You can even some special comment, like ;~ used in SciTE, to activate / deactivate the lines (eg. for OutputDebug).
Posted Image vPhiLho := RegExReplace("Philippe Lhoste", "^(\w{3})\w*\s+\b(\w{3})\w*$", "$1$2")

Veovis
  • Members
  • 389 posts
  • Last active: Mar 17 2009 12:24 AM
  • Joined: 13 Feb 2006
i think he means having something like

NOOP
{
   msgbox, these lines wont get run
   msgbox, i dont know why...
}

but that doesnt make sense.... whats wrong with:

/*
   msgbox, these lines wont get run
   msgbox, i do know why! they are a comment!
*/

Posted Image
"Power can be given overnight, but responsibility must be taught. Long years go into its making."

SAbboushi
  • Members
  • 165 posts
  • Last active: Dec 27 2014 06:38 AM
  • Joined: 18 Sep 2004

I was looking for a NOOP action today too.  In my case, I am debugging and trying to follow program flow.  e.g. I have been totally confused about when to use %, so I fired up SciTE4AutoHotkey and wanted to single-step through the following:

if x = x
{
}
else
{
}

if x = 
{
}
else
{
}

BUT AHK/SciTE4AutoHotkey skips over empty actions (i.e. { } )

 

So, next I would have wanted to do something like:

if x = x
{
	NOOP
}
else
{
	NOOP
}

if x = 
{
	NOOP
}
else
{
	NOOP
}

But there is no NOOP...

 

So I instead have to do something like 

if x = x
{
	sleep , 1
}
else
{
	sleep , 1
}

if x = 
{
	sleep , 1
}
else
{
	sleep , 1
}

I started programming in 1971 when the concept of NOOP was in vogue for stuff like this...

 

So how would you youngsters (or maybe, you more sophisticated programmers) approach this today?



Coco
  • Members
  • 697 posts
  • Last active: Oct 31 2015 07:26 PM
  • Joined: 27 Jul 2012

"pass" is nice alternative name for NOOP - similar to Python's "pass" statement

Here's a poor workaround:

; Dummy loop
Loop 1 {
	if (x == 1)
		continue
	else if (x == 2)
		continue
	else continue
}


SAbboushi
  • Members
  • 165 posts
  • Last active: Dec 27 2014 06:38 AM
  • Joined: 18 Sep 2004

Thanks for your post



Raccoon
  • Members
  • 178 posts
  • Last active: Oct 06 2014 05:58 PM
  • Joined: 02 Jan 2008

I started programming in 1971 when the concept of NOOP was in vogue for stuff like this...

 

So how would you youngsters (or maybe, you more sophisticated programmers) approach this today?

 

That is interesting to know.  I happen to be the person who got Khaled, author of mIRC, to add noop to his scripting language too.  This was about 8 years ago.  It is perversely useful :D  And yes, I have typed noop in AHK code in error while framing a script.

I would recommend that the command be treated as noop [, expression] in the same syntax as return.

Really, to all the naysayers, it's just a programming aid.   People use it and it's easy to search for in your code when you go to remove all noops.

 

Loop, Array.MaxIndex()
  noop

Posted Image

Need help right away? Get live support on IRC.
Already have an IRC client installed? /join #ahk