The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Sergiu FUNIERU on February 24, 2010, 01:06:30 AM

Title: How to set the path for the include files?
Post by: Sergiu FUNIERU on February 24, 2010, 01:06:30 AM
I want to do something like this in my index.asm file

set include_path = c:\masm32\include
include %include_path%\windows.inc

Is it possible? What is the correct syntax?

Title: Re: How to set the path for the include files?
Post by: dedndave on February 24, 2010, 01:59:44 AM
set INCLUDE=C:\masm32\include
set LIB=C:\masm32\lib
set MASM=C:\masm32\bin
set PATH=C:\masm32\bin;%PATH%

those are the paths
but, if you want them to stay that way, you have to open the system icon and edit the system environment variables

http://www.masm32.com/board/index.php?topic=13263.msg103078#msg103078
Title: Re: How to set the path for the include files?
Post by: Sergiu FUNIERU on February 24, 2010, 02:02:25 AM
Quote from: dedndave on February 24, 2010, 01:59:44 AM
set INCLUDE=C:\masm32\include
set LIB=C:\masm32\lib
set MASM=C:\masm32\bin
set PATH=C:\masm32\bin;%PATH%

those are the paths
but, if you want them to stay that way, you have to open the system icon and edit the system environment variables

http://www.masm32.com/board/index.php?topic=13263.msg103078#msg103078
Can I do this inside my asm file? That's my problem.
Title: Re: How to set the path for the include files?
Post by: jj2007 on February 24, 2010, 02:05:33 AM
You can do all sorts of manipulation, set environment variables, use makefiles, whatever. The more important question is "what happens if your code snippets posted here do not follow the forum habits"..

include \masm32\include\masm32rt.inc


After installation, Masm32 has a hardcoded tree structure. You may have it in C:\masm32\ or D\masm32\, for example. Using \masm32\ makes sure that a forum member who has it in Y:\masm32\ can assemble your code, too.

By the way: There are plenty of posts from newbies (not you) with a dozen lines of complex code but no proper headers such as includes, protos etc.; what these young friends implicitly say is "can one of you old fellas who have nothing else to do please construct a skeleton using my snippet and then test it for me?"
Title: Re: How to set the path for the include files?
Post by: Sergiu FUNIERU on February 24, 2010, 02:14:20 AM
Quote from: jj2007 on February 24, 2010, 02:05:33 AMThere are plenty of posts from newbies (not you)
You're kind with me. Thank you!


Quote from: jj2007 on February 24, 2010, 02:05:33 AMYou can do all sorts of manipulation, set environment variables, use makefiles, whatever. The more important question is "what happens if your code snippets posted here do not follow the forum habits"..
I completely agree with you in this matter. When I'll post the code, from now on, I'll use the relative paths, regardless of how my actual code looks. Of course, I'll test it first with relative paths.

I plan to write a small utility that will convert my code to the standard accepted format. This way, my code will be easier to read when I'll ask a question.
Title: Re: How to set the path for the include files?
Post by: japheth on February 24, 2010, 07:25:12 AM
Quote from: Sergiu FUNIERU on February 24, 2010, 02:02:25 AM
Quote from: dedndave on February 24, 2010, 01:59:44 AM
set INCLUDE=C:\masm32\include
set LIB=C:\masm32\lib
set MASM=C:\masm32\bin
set PATH=C:\masm32\bin;%PATH%

those are the paths
but, if you want them to stay that way, you have to open the system icon and edit the system environment variables

http://www.masm32.com/board/index.php?topic=13263.msg103078#msg103078
Can I do this inside my asm file? That's my problem.

Yes. The internal macro function @Environ will allow you access to environment variables:


.386
.model flat

% include @Environ(INCLUDE)/macros.inc


The % is required to enable "macro expansion" for the INCLUDE directive. Thus @Environ(INCLUDE) will be replaced by the value of environment variable INCLUDE. Also note the '/' instead of the backslash. This is a Masm quirk, needed when macro expansion is on - for JWasm its also ok, but unnecessary.

Title: Re: How to set the path for the include files?
Post by: Sergiu FUNIERU on February 24, 2010, 12:58:30 PM
Quote from: japheth on February 24, 2010, 07:25:12 AMYes. The internal macro function @Environ will allow you access to environment variables:
Thank you very much! This is what I was looking for.
Title: Re: How to set the path for the include files?
Post by: BlackVortex on February 24, 2010, 01:12:25 PM
Interesting functionality there.

If you're using only one assembler though, it's easier to have your include folder in the path.
Title: Re: How to set the path for the include files?
Post by: Sergiu FUNIERU on February 24, 2010, 01:17:29 PM
Quote from: BlackVortex on February 24, 2010, 01:12:25 PMIf you're using only one assembler though, it's easier to have your include folder in the path.
That's a nice idea. I'll stick to JWasm for the foreseeable future and I'll definitely try your suggestion. Thank you.

I have to read in the manual if JWasm will look in the path first.

On the other hand, it would not be risky if in the path there are some other include files, let's say from other libraries?
Title: Re: How to set the path for the include files?
Post by: BlackVortex on February 24, 2010, 01:22:49 PM
They won't have the same name. Besides, you'll have only one include folder in your path.
Title: Re: How to set the path for the include files?
Post by: Sergiu FUNIERU on February 24, 2010, 01:29:59 PM
Quote from: dedndave on February 24, 2010, 01:59:44 AM
set INCLUDE=C:\masm32\include
set LIB=C:\masm32\lib
set MASM=C:\masm32\bin
set PATH=C:\masm32\bin;%PATH%

those are the paths
but, if you want them to stay that way, you have to open the system icon and edit the system environment variables
For small programs, I use the same batch file to compile. The name of the program is always index.asm, and the paths are hardcoded inside that bat file. In this way, I'll not affect the system environment variables, not to mention that it's easier for me to edit the bat file.

The paths are set only for the time when the bat programs run.