Page 1 of 1

What is this type of code called?

Posted: Wed May 18, 2011 7:51 pm
by Nituvious
I asked a programming friend of mine what this is that I made and he said it sounded like self modifying code, however he didn't really understand what it was I had even done. Maybe some of you guys know and can tell me.

I call it useless, but I would really like to know.

Code: Select all

Macro CreateConstant(ConstantName, Value)
	#ConstantName = Value
EndMacro

CreateConstant(MyConstant, 1)
CreateConstant(MyButton, 2)

OpenWindow(#MyConstant, 0, 0, 200, 200, "Useless code in action!", #PB_Window_ScreenCentered | #PB_Window_SystemMenu)
ButtonGadget(#MyButton, 5, 5, 100, 50, "Some Button")

Repeat
	Delay(10)

	If WaitWindowEvent(1) = #PB_Event_Gadget
		Select EventGadget()
			Case #MyButton
				MessageRequester("Message","Useless, I know")
		EndSelect
	EndIf

Until WaitWindowEvent(1) = #PB_Event_CloseWindow

Re: What is this type of code called?

Posted: Wed May 18, 2011 8:08 pm
by Trond
It's just normal use of macros, it doesn't have a special name.

Re: What is this type of code called?

Posted: Wed May 18, 2011 8:15 pm
by Nituvious
Figured :mrgreen:

Re: What is this type of code called?

Posted: Thu May 19, 2011 6:05 am
by JackWebb
The code you posted does not appear to be self modifying, but if it were it would be called PolyMorphic.

http://en.wikipedia.org/wiki/Polymorphic_code