When I work on code, I often like to get something working immediately and then make it bulletproof later.
To remind myself that some code needs additional attention, I used to include a line like this:


#pragma message("Fix this later")

When the compiler compiled this line, it would output a string reminding me that I had some more work to do.
This message was not that helpful, however. I decided to find a way for the compiler to output the name
of the source code file and the line number that the pragma appears on.
Not only would I know that I had additional work to do, but I could also locate the surrounding code immediately.

Above quote is from Jeffrey Richter's "Programming Applications for Microsoft Windows" excellent book.


How nice!
Why so simple idea didn't rush into my mind before?
I always used ToDo.txt files for this.
But it's much easier with the Fix helper macro



Fix MACRO txt
local line, pos, spos

line TEXTEQU %@Line
pos = 0
spos = 0

% FORC ch, @FileCur ;; Don't display full path. Easier to read.
pos = pos + 1
IF "&ch" EQ 5Ch ;; "/"
spos = pos
ENDIF
ENDM

ECHO *-------------------------------------------*
IF @SizeStr(<txt>)
% ECHO @CatStr(@SubStr(%@FileCur, spos+1,), <(line)>, < !<- >, <txt>)
ELSE
% ECHO @CatStr(@SubStr(%@FileCur, spos+1,), <(line)>, < !<- Fix this later!!>)
ENDIF
ECHO *-------------------------------------------*

ENDM


This helper macro displays at assembly time the file name and line number that it appears on.
You can pass to it an extra string or you can use it without parameters.


Fix

will output:

*-------------------------------------------*
MyCoolProject.asm(128) <- Fix this later!
*-------------------------------------------*

Fix I have much to do here

will output:

*-------------------------------------------*
MyCoolProject.asm(642) <- I have much to do here
*-------------------------------------------*


If you want to have full path simply comment out forc loop.
Posted on 2002-08-18 08:25:08 by Four-F
I will use it from here on...thank you! :)
Before I used comments, but they are easy to miss in a big listing.

@InStr would not work instead of FORC loop?
FixMe MACRO txt:=<Fix this later!!!!>

ECHO *-------------------------------------------*
% ECHO @CatStr(@FileCur, <(>, %@Line, <) !<- >, <txt> )
ECHO *-------------------------------------------*
ENDM
Posted on 2002-08-18 11:59:50 by bitRAKE
@InStr would not work instead of FORC loop?


The @InStr searches for the first occurrence of "\".
c:\masm32\projects\MyCoolProject.asm
But i want fetch out only file name.

txt:=<Fix this later!! >

Also doesn't work.
I mean i can't force it to understand that i want complete string with '!'.
It ingest '!' sign.
It's not so important here, but it should work as i want but not as it can ;-)

Always have troubles with unpredictable behaviour of some masm macros.
Posted on 2002-08-18 15:42:55 by Four-F
Sorry, my mistake - would still have to use INSTR in a loop - if it worked. ;) I have the same problem with macros and it only gets better with time. There is no good documentation and complex behaviour is hard to predict. That is what makes them so fun, imo.


These work as needed:
	pos = 1

WHILE pos NE 0
spos = pos + 1
pos INSTR spos,@FileCur,<!\>
ENDM
Your method is better imo.
FixMe MACRO txt:=<Fix this later!!!!>
Four ! are needed due to the double evaluation: first reduced to !!, then to !
Posted on 2002-08-18 16:11:19 by bitRAKE
Thanks for fixing up my Fix macro, bitRAKE :)
My current version:


Fix MACRO txt:=<Fix this later!!!!>
local pos, spos

pos = 0
spos = 0

% FORC ch, @FileCur ;; Don't display full path. Easier to read.
pos = pos + 1
IF "&ch" EQ 5Ch ;; "/"
spos = pos
ENDIF
ENDM

ECHO *-------------------------------------------*
% ECHO @CatStr(@SubStr(%@FileCur, spos+1,), <(%@Line) !<- txt>)
ECHO *-------------------------------------------*

ENDM
Posted on 2002-08-18 18:40:13 by Four-F
Thanks for the macro !
Posted on 2002-08-18 19:00:12 by JimmyClif

Thanks for fixing up my Fix macro, bitRAKE :)
:grin: Funny. Your welcome. Also, don't forget that ch is a register and might cause you problems if used for a variable name - you found your way around that one. ;)
Posted on 2002-08-18 19:44:28 by bitRAKE
Oooh :alright:

Very useful, thanks :)
Posted on 2002-08-18 19:51:15 by iblis
don't forget that ch is a register


OK. Fixed.
Posted on 2002-08-19 05:36:14 by Four-F
This is a great macro! Thanks!

Now all my code looks like this:



mov eax,edx
Fix This is wrong
xor eax,eax
Fix So is this
imul eax,eax
Fix Go get a bologna sandwich because you're hungry


;)
--Chorus
Posted on 2002-08-19 08:32:49 by chorus