5.62: Macro bug if colons are used

Just starting out? Need help? Post your questions and find answers here.
User avatar
Kurzer
Enthusiast
Enthusiast
Posts: 664
Joined: Sun Jun 11, 2006 12:07 am
Location: Near Hamburg

5.62: Macro bug if colons are used

Post by Kurzer »

Hello Fred,

in older versions of PB some tricks worked to shorten the source code using macros in a unusual way.
For example, I was able to replace macros with macros to save as much source code as possible. I remember the 20-line contest in 2009 here in the forum, where I used the following constellations in my sourcecode for example:

Code: Select all

Macro M(a,b):Macro a:b:EndMacr:EndMacro:M(H,"Hello world!")o:Debug H
This no longer works.

But apart from that the user #Null and I noticed some "crazy" things when using macros in the current PB version.

For example this code works. The MessageRequester pops up and show "Hello World" as expected:

Code: Select all

Macro M(a,b):Macro a
b:EndMacro: M(C,"world"):EndMacro
sText.s = "Hello " + C:MessageRequester("", sText)
But if you drag the last line to the penultimate line and concatenate it with a colon (:), the MessageRequester will display "Hello 0". :shock:
Something seems to be wrong when using a : after the last EndMacro.

Code: Select all

Macro M(a,b):Macro a
b:EndMacro: M(C,"world"):EndMacro:sText.s = "Hello " + C:MessageRequester("", sText)
And as a second effect, we found out this:
If you execute the following macro code, then the defined macro "C" is not inserted where it is placed in the source code, but one line below it. In addition, a syntax error is now displayed when compiling, even though the code is valid.

Code: Select all

Macro M(a,b):Macro a:b:EndMacro
M(C,"world"):EndMacro
sText.s = "Hello " + C
MessageRequester("", sText)
Image

Kind regards
Kurzer
PB 6.02 x64, OS: Win 7 Pro x64 & Win 11 x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age in 2023: 56y
"Happiness is a pet." | "Never run a changing system!"
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: 5.62: Macro bug if colons are used

Post by Little John »

kurzer wrote: But apart from that the user #Null and I noticed some "crazy" things when using macros in the current PB version.

For example this code works. The MessageRequester pops up and show "Hello World" as expected:

Code: Select all

Macro M(a,b):Macro a
b:EndMacro: M(C,"world"):EndMacro
sText.s = "Hello " + C:MessageRequester("", sText)
I would not have expected that code to work, since nested macro definitions are not supported by PB. That code seems to work just by chance.
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: 5.62: Macro bug if colons are used

Post by Josh »

I would rather classify such constructs in the artistic field than that what has to do anything with programming.

Not everything that someday worked and now does not work anymore is a mistake.
sorry for my bad english
Fred
Administrator
Administrator
Posts: 16623
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: 5.62: Macro bug if colons are used

Post by Fred »

Nested macros was never supported, dunno why it worked at all :D
User avatar
NicTheQuick
Addict
Addict
Posts: 1224
Joined: Sun Jun 22, 2003 7:43 pm
Location: Germany, Saarbrücken
Contact:

Re: 5.62: Macro bug if colons are used

Post by NicTheQuick »

It is maybe not a bug but a glitch. :D
The english grammar is freeware, you can use it freely - But it's not Open Source, i.e. you can not change it or publish it in altered way.
Post Reply