It is currently Wed Jun 19, 2019 5:56 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: 5.62: Macro bug if colons are used
PostPosted: Thu Apr 18, 2019 6:45 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 11, 2006 12:07 am
Posts: 484
Location: Germany / one of the fishheads
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:
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:
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:
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:
Macro M(a,b):Macro a:b:EndMacro
M(C,"world"):EndMacro
sText.s = "Hello " + C
MessageRequester("", sText)


Image

Kind regards
Kurzer

_________________
PB 5.62, OS: Windows 7 Pro x64, Desktopscaling: 125%, CPU: I7 6500, RAM: 16 GB, GPU: Intel Graphics HD 520, User age: 51y
"Happiness is a pet." | "Never run a changing system!"


Top
 Profile  
Reply with quote  
 Post subject: Re: 5.62: Macro bug if colons are used
PostPosted: Fri Apr 19, 2019 2:13 am 
Offline
Addict
Addict
User avatar

Joined: Thu Jun 07, 2007 3:25 pm
Posts: 3574
Location: Berlin, Germany
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:
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.

_________________
Please excuse my flawed English. My native language is PureBasic.
Search
RSBasic's backups


Top
 Profile  
Reply with quote  
 Post subject: Re: 5.62: Macro bug if colons are used
PostPosted: Fri Apr 19, 2019 4:00 pm 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 13, 2010 3:45 pm
Posts: 840
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


Top
 Profile  
Reply with quote  
 Post subject: Re: 5.62: Macro bug if colons are used
PostPosted: Fri May 24, 2019 8:49 am 
Offline
Administrator
Administrator

Joined: Fri May 17, 2002 4:39 pm
Posts: 13590
Location: France
Nested macros was never supported, dunno why it worked at all :D


Top
 Profile  
Reply with quote  
 Post subject: Re: 5.62: Macro bug if colons are used
PostPosted: Fri May 24, 2019 9:09 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Jun 22, 2003 7:43 pm
Posts: 371
Location: Germany, Saarbrücken
It is maybe not a bug but a glitch. :D

_________________
Electronics, Crazy & Interesting Stuff, all that with text, image and sound? Click here!

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.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 8 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye