I am using a macro to simplify the includeing of files.

here is what I have so far(it works fine)

-----------------------------------------------------
INCH MACRO y
exitm <include \masm32\include\y>
endm

INCL MACRO y
exitm <includelib \masm32\lib\y>
endm

INCH(Windows.inc)
INCH(user32.inc)
INCL(user32.lib)

------------------------------------------------------
the problem is that i need to hardcode the macro to /masm32/include , etc

the ideal thing would be to have a macro that can set the path to the files on the fly, ie
INCPATH("\masm32\include\")
then all calls to INCH would use this path

does anyone have any idea how to pull this off?
the INCH macro will need access to whatever the INCPATH macro sets up

thanx

P.S. just doing this to clutterness the bloat in the code - Macros are the greatest thing Masm has to offer in my opinion so I'd like to use them to simplify and clarify coding where possible

P.S. 2 , hehe

i would also like a way to do this INCH(Windows.inc, User32.inc, kernel32.inc)

that would make this whole macro idea worth while for sure

any help appreciated
Posted on 2002-12-23 20:27:42 by compucoder
Sure:


INCPATH MACRO apath
MASM_Inc_Path TEXTEQU <&apath>
ENDM

INCH MACRO var:VARARG
IFNB <var>
FOR c, <var>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<c>,<.inc>)
ENDM
ENDIF
ENDM

INCL MACRO var:VARARG
IFNB <var>
FOR c, <var>
@CatStr( <includelib >,%MASM_Inc_Path,<\lib\>,<c>,<.lib> )
ENDM
ENDIF
ENDM

-------------------
Example usage
-------------------
INCPATH D:\masm32
INCH kernel32, user32, windows
INCL kernel32, user32


That should do it... ;)
This is a *very* good idea.. Its nice have people come by with such insparation. I would equal it to the CTEXT(" ") that Huh dreamt up a while ago..

Thanx, and i hope you can follow it. Any questions feel free to ask.

:alright:
NaN
Posted on 2002-12-23 21:38:57 by NaN
Heres another (since i like to play around with COM ;) )
INCC MACRO var:VARARG

IFNB <var>
FOR c, <var>
@CatStr( <include >,%MASM_Inc_Path,<\COM\include\>,<c>,<.inc> )
ENDM
ENDIF
ENDM


:alright:
NaN
Posted on 2002-12-23 22:02:25 by NaN
Hi Jameyson its actually Rockinronstar under a new name, heh

we started that IDE quite some time ago

I was stuck on this , thank you

you made this usable.

My original idea was good but required that you use a hard coded path. I am going to add your improvements to my macro library.

I believe that ASm programming becomes more appealing when you can simplify. And things like this I believe simplify monotanous tasks as including files.

Its really just a step towards the HLL - add some of the nice features we all come to love but still have an ASM base to tweak that last bit of efficiency / speed

thanx again.,

P.S. I know since you started working again you have been very busy.... Have you had time to work on your OOP designs. Brilliant stuff you and Thomas devised for sure.

Things like this in my opinion make ASM more appealing to those than are loyal to HLL or just havent given any time to learn / understand ASM programming. Thanx for shedding light on methods that bringing cool aspects to what we do
Posted on 2002-12-23 22:19:27 by compucoder
No problem ;)

Keep in touch (you should have my ICQ still?)...

Anywho, i did come across a bug with this macro.
Microsoft (R) Macro Assembler Version 6.14.8444

Copyright (C) Microsoft Corp 1981-1997. All rights reserved.

Assembling: D:\masm32\_ACTIVE\calndr\Project.asm
D:\masm32\include\masm32.inc(7) : fatal error A1016: Internal Assembler Error
_
Assembly Error


After some playing around, i figured out that its caused by the above MACRO code. (Internal Assembly Error! Wow, never thought i could achive such a feat!).

If you place an include file into the above macros that also have macros in that file, you will get this response right away. Im not too sure how to get around this bug... better call in the heavy hitters for this one...

Posted on 2002-12-23 22:26:30 by NaN
sorry to bug ya again.

I cant seem to get this to work

I get internal assember error
and thats all it says

prob a syntax problem somewhere.

I'll wait for you to look it over

thanx
Posted on 2002-12-23 22:32:05 by compucoder
no, dont have it NaN - do you have a MSN email

just PM me with it if you got it

bye
Posted on 2002-12-23 22:33:34 by compucoder
You saw the above listing right? About the Interal Assembly Error?

:nAn:
Posted on 2002-12-23 22:40:51 by NaN
yep - guess we gotta wair for the big guns to look at it..



Where is Bitrake at midnight when you need him, heh
Posted on 2002-12-23 22:42:37 by compucoder
I've gotten the problem tracked even closer now.

Its due to the FOR loop. If somehow the 'include' string was acted upon by MASM *after* the loop is finished it will work fine (exiting the for loop first). However, it negates the processing of the array of input params. Give me more time on this...

:NaN:
Posted on 2002-12-23 22:59:21 by NaN
i've tried many different approaches to this too.

I'll leave it in the big guns hands for now.

I encounter errors every way I attwmpt :(

thanx NaN
Posted on 2002-12-23 23:07:12 by compucoder
Ya. I tried a handful of approaches and they all failed.

Indirectly: Outputing a macro with the name in it (ie nesting to another macro with no loops) but the major loop still resides and fails. Guess MASM is recursive.

I tried using IRP instead of FOR..

I tried using WHILE / ENDM loops instead of for loops.

All of which fails every time.

The Quick and dirty solution is if you have an include with macros in it use this:


INCPATH MACRO apath
MASM_Inc_Path TEXTEQU <&apath>
ENDM

INCHH MACRO var:REQ
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<var>,<.inc> )
ENDM

INCH MACRO var:VARARG
IFNB <var>
FOR c, <var>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<c>,<.inc> )
ENDM
ENDIF
ENDM

INCL MACRO var:VARARG
IFNB <var>
FOR c, <var>
@CatStr( <includelib >,%MASM_Inc_Path,<\lib\>,<c>,<.lib> )
ENDM
ENDIF
ENDM

INCC MACRO var:VARARG
IFNB <var>
FOR c, <var>
@CatStr( <include >,%MASM_Inc_Path,<\COM\include\>,<c>,<.inc> )
ENDM
ENDIF
ENDM


------------
Examples
------------

INCHH debug ; Has MACRO's In it!
INCH ole32, advapi32, oleaut32, masm32,
INCL ole32, advapi32, oleaut32, masm32, debug


Enjoy..
:alright:
NaN
Posted on 2002-12-23 23:49:49 by NaN
Heres another solution that DOES work with macros in the files:
INCPATH MACRO apath

MASM_Inc_Path TEXTEQU <&apath>
ENDM

INCHDR MACRO arg1:REQ, arg2:=<>, arg3:=<>, arg4:=<>, arg5:=<>, arg6:=<>, arg7:=<>, arg8:=<>, arg9:=<>, arg0:=<>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg1>,<.inc> )
ifnb <arg2>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg2>,<.inc> )
endif
ifnb <arg3>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg3>,<.inc> )
endif
ifnb <arg4>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg4>,<.inc> )
endif
ifnb <arg5>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg5>,<.inc> )
endif
ifnb <arg6>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg6>,<.inc> )
endif
ifnb <arg7>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg7>,<.inc> )
endif
ifnb <arg8>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg8>,<.inc> )
endif
ifnb <arg9>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg9>,<.inc> )
endif
ifnb <arg0>
@CatStr( <include >,%MASM_Inc_Path,<\include\>,<&arg0>,<.inc> )
endif
ENDM

INCLIB MACRO var:VARARG
IFNB <var>
FOR c, <var>
@CatStr( <includelib >,%MASM_Inc_Path,<\lib\>,<c>,<.lib> )
ENDM
ENDIF
ENDM

-------------------
EXAMPLE USE
-------------------

INCPATH D:\masm32
INCHDR ole32, advapi32, oleaut32, masm32, debug
INCLIB ole32, advapi32, oleaut32, masm32, debug

This is probably your best solution. Your limited to a variable amount of arguments for the INCHDR macro. You can have up to 10 includes on one line. After this you need to used another 'instance' of the macro. The INCLIB however is a binary, without macros, so it is fully variable. Your only limitation is the 512 chars per line by the assembler itself...

:enjoy:
Im signing off, and considering this solved ;)
:alright:
NaN
Posted on 2002-12-24 00:03:40 by NaN
that kinda sucks - forces the programmer to be aware if a file has macros in it.

I have even tried forc as well

doesnt seem to be a way...yet


on a clear brain, perhaps tomorrow will spark an idea to make it possible

thanx for the effort NaN!!
Posted on 2002-12-24 00:04:10 by compucoder
As you posted you reply 1 minute after my last one, i sugest you look again ;)
Posted on 2002-12-24 00:08:16 by NaN
wonder why masm is having trouble with the 'for' iteration of the arguments.

guess we will just have to put it rest as a bug in the masm compiler

thanx again NaN!
Posted on 2002-12-24 08:18:28 by compucoder
NaN:

I did alot of playing with this and might be into something


I started testing files with macros and also embedding macros inside iterations

things seemed to work for me....But Windows.inc always failed

I copied that first macro from Windows.inc into my test macro and as expected it failed

then I thought of something....the exitm - where does that return to now as things
are nested inside other macros and also inside iterations

i removed the exitm.....now it worked

maybe you could verify this - guess either way it doesnt matter - cant remove the exits from all the inc's :)
Posted on 2002-12-24 11:40:42 by compucoder
nevermind...I was wrong


seems like a scope issue

quite the puzzle, heh
Will I ever give up, lol
Posted on 2002-12-24 11:49:43 by compucoder
Currently, I'm using:
incAPI MACRO files:VARARG

;; make adding APIs easier: All APIs should consist of an INC file that
;; defines the interface and LIB file of supporting code (wrapper).
FOR file, <files>
include file&.inc
includelib file&.lib
ENDM
ENDM
...use it like...
incAPI  kernel32,user32,gdi32,winmm,comdlg32,comctl32,shell32,advapi32
The path is set by RadASM or a makefile (environment). With the way stuff moves around on the hard drive, the last thing I want to do is hardcode a path. :) If you still want to use the other macro, try this:
INCC MACRO var:VARARG

IFNB <var>
FOR c, <var>
% INCLUDE MASM_Inc_Path&\\COM\\include\\&c&.inc
ENDM
ENDIF
ENDM
/me takes a bough... :grin: Happy Holidays!
Posted on 2002-12-24 17:32:29 by bitRAKE
I tried both of your above solutions, and while they are obviously more steamlined than mine ( experience is showing here ;) ), they both still cause the internal assembly error.. :(

Anywho, there is still something to be learned from this: I dont need to use CatStr() to get the same job done ;)

Thanx bitRAKE :alright:
NaN
Posted on 2002-12-26 10:38:05 by NaN