Macro parameters inside of nested procedure are shared?

Everything else that doesn't fall into one of the other PB categories.
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Macro parameters inside of nested procedure are shared?

Post by Nituvious »

I was playing around with macro's and wondered if I could create a function on the fly, I found that a function nested within a macro shared parameters with the macro, regardless of being declared shared, static, protected or not.

Also, I think my use of the term "nested" may be wrong?

Code: Select all

param = 0

Macro confuse_me(funcname, param)
	Procedure funcname()
		;Protected param.l
		;param = 1
		If param = 10
			Debug "param equal to 10."
		Else
			Debug "param not equal to 10."
		EndIf
	EndProcedure

	funcname()

EndMacro

confuse_me(nested, 10)
I don't think there is any use in this, I am just curious as to what is actually happening here I guess.
▓▓▓▓▓▒▒▒▒▒░░░░░
User avatar
idle
Always Here
Always Here
Posts: 6238
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Macro parameters inside of nested procedure are shared?

Post by idle »

there's nothing really confusing about it a macro is simply prepossessed
you told it to create a procedure and then call it

Code: Select all

Procedure nested()
  If 10 = 10
    Debug "param equal to 10."
  Else
    Debug "param not equal to 10."
  EndIf
EndProcedure


what you see is what you get!

but you can surely get confused when you macro macros
Windows 11, Manjaro, Raspberry Pi OS
Image
Nituvious
Addict
Addict
Posts: 1033
Joined: Sat Jul 11, 2009 4:57 am
Location: United States

Re: Macro parameters inside of nested procedure are shared?

Post by Nituvious »

Ah I get it(Maybe, I'm probably lying to myself though, haha). I totally had macro figured completely wrong.
I had partially confused a macro parameter with a variable or something.
▓▓▓▓▓▒▒▒▒▒░░░░░
User avatar
idle
Always Here
Always Here
Posts: 6238
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Macro parameters inside of nested procedure are shared?

Post by idle »

If your trying to get your head around macros just put an illegal character before the end it and then
you can examine it in the error window.
Windows 11, Manjaro, Raspberry Pi OS
Image
Post Reply