Macros !!!!!

Share your advanced PureBasic knowledge/code with the community.
npath
User
User
Posts: 74
Joined: Tue Feb 15, 2005 5:15 pm

Post by npath »

@Jack,

Thanks for the link!
El_Choni
TailBite Expert
TailBite Expert
Posts: 1007
Joined: Fri Apr 25, 2003 6:09 pm
Location: Spain

Post by El_Choni »

Fasm macros are cool, but I think they're not very useful if you want to deal with PB's code (variables and stuff). I would wait for PB's macros, those will be useful, I'm sure.
Last edited by El_Choni on Sun Apr 03, 2005 12:57 pm, edited 1 time in total.
El_Choni
Xombie
Addict
Addict
Posts: 898
Joined: Thu Jul 01, 2004 2:51 am
Location: Tacoma, WA
Contact:

Post by Xombie »

If I knew how Japbe plugin stuff works, I'd play around with a hack. Have some way to define a macro (using special comment lines) and then when it goes to compile the program, drop in the code in it's place. Unfortunately, I know nothing about working with Japbe plugins :)
Dreglor
Enthusiast
Enthusiast
Posts: 759
Joined: Sat Aug 02, 2003 11:22 pm
Location: OR, USA

Post by Dreglor »

isn't macros like c++ inline?
maybe pb should implment something like that
~Dreglor
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Post by Psychophanta »

Froggerprogger wrote:- you shouldn't use 'test' as a name for the macro, because TEST is a keyword in FASM

Code: Select all

!macro bla
!{
  MessageRequester("test","hello")
!}
!bla
!bla
Hey. From Fasm preprocessor doc:
You can also "overload" instruction with macro, because preprocessor doesnt' know about instructions, it allows macro name to be instruction mnemonics.
macro pusha
{
push eax ebx ecx edx ebp esi edi
}
macro popa
{
pop edi esi ebp edx ecx ebx eax
}
:wink:
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
traumatic
PureBasic Expert
PureBasic Expert
Posts: 1661
Joined: Sun Apr 27, 2003 4:41 pm
Location: Germany
Contact:

Post by traumatic »

Dreglor wrote:isn't macros like c++ inline?
Well, sort of. AFAIK 'inline' is processed by the compiler while macros are
handled by the preprocessor. Inline supports typechecking for arguments,
macros are only literally copied into the caller's location.
In nowadays programming, inlined functions are considered better, there're
still some cases 'inline' won't help.
Good programmers don't comment their code. It was hard to write, should be hard to read.
User avatar
waffle
Enthusiast
Enthusiast
Posts: 129
Joined: Mon May 12, 2003 1:34 pm
Location: USA
Contact:

Post by waffle »

I ran into a minor problem ...
If you declare a macro in an external include file,
You will get an error that the symbol is already defined.

I was hoping to place all my debugging code ...
compilerif #TestMode
if tracemode
calldebugger
endif
compilerendif

as a macro instead of a procedure in an include file.
Oh, I'm using PB3.91
It would help in making code more readable.
I really like this in procedures that return a value because I can ...

!CheckTestMode
Debug Reply
procedurereturn reply
endprocedure

That way, I can press the continue button and the debugger will
pause at the procedure end so I can read the return value.


Oh, it works fine in the main file, just not when the macro is defined
in the include.

UPDATE:
in the includefile, the macro was used inside a procedure ...
when removed from the procedure, everything worked ... Odd :?
Code is good... Its an international language.
Post Reply