2

I got a problem with setting a path to image within the resource file (.rc).

For some reasone it was not possible to concatenate defined string and the text.

e.g.

File1:  
#define Path "Brand_1"

File2:  
#include File1

Logo BITMAP Path "\Logo.bmp"

Borland resource compiler (5.4) throws error message: 39: Cannot open file: Brand_1

EDIT: My question would be: Is is possible to combine the path for loading image using resource string variable and a string (file name).

Also, project I'm working on relates to a file (Logo.bmp) being present in two locations. I would like to have a switch (.bat file) to generate a different resouce file depending on requirements.

Thanks.

3
  • 2
    Thank you for stating those facts. What is your question? If you'd like to file a bug report, please visit Embarcadero Quality Central. Commented Jun 22, 2012 at 17:07
  • So far as I can tell, neither brcc32 not rc support any form of string literal concatenation Commented Jun 22, 2012 at 19:40
  • My question is: Is it possible to combine a path for loading image from it's name and a resource string variable holding a path. Commented Jun 25, 2012 at 16:58

2 Answers 2

2

BRCC32 accepts -i as search path seperated by semicolon, so you could create a bat file like this

compile_res.bat

brcc32 -ic:\mypath1;c:\mypath2 resource_script

and you define your resource_script as normal, for ex:

resource_script.rc

myImg BITMAP Logo.bmp
myDOC RCDATA mydoc.doc

when you run the compile_res.bat, it will run the brcc32.exe with the search path, and having the bat file saves you from retyping the search path every time.

Sign up to request clarification or add additional context in comments.

3 Comments

+1, that's right but what if the Logo.bmp will be, in the worst case, in all included paths and each Logo.bmp will be a different image ?
Yeah, that's the limitation of this aproach, i.e. each filename must be unique. BTW, having multiple logo.bmp files refering to different images just add confusion. I rather have unique name for each.
@Hendra That's pretty much what the problem is. Logo.bpm is in two different location and I would like to have a .bat switch.
1

You're not concatenating anything. You're compiling to Logo BITMAP "Brand_1" "\Logo.bmp", and "Brand_1" isn't a valid path to a bitmap file.

#define in the resource compiler acts sort of like find/replace in a text processor - not exactly, but close enough in this case.

You might get by (untested) with removing the quotes and space between them, as long as there are no space characters in either the path or filename; otherwise, you're probably out of luck. (Not sure what you're trying to accomplish, anyway.)

5 Comments

In C and C++, adjacent string-literal tokens are automatically combined at compile time. I'm sure that was the intention here, too. I don't know whether Microsoft's resource compiler supports that.
You can even make a helper concatenation function like #define Concat(a,b) a##b and use it like Logo BITMAP Concat(Brand_1, \Logo.bmp) but it's for nothing since you cannot pass there quoted strings (it would produce Brand_1""\Logo.bmp what would limit you for spaces) or what is worse, defined constants.
@Rob: I'm not sure the resource compiler preprocessor is that refined.
@TLama I've been experimenting with your suggestion and so far made a little bit of progress. I've expanded your function to take three parameters: #define Concat(a,b,c) a##b##c <code><br/>; LOGO BITMAP Concat (Temp,/,splash.bmp) The Temp is a string. If I'll put string into a variable e.g.#define VariableTemp Temp LOGO BITMAP; Concat (VariableTemp,/,splash.bmp) Then compiler throws an error: Cannot open file: Temp Any suggestions?
@Rob, that's what I've mentioned like what is worse, defined constants. If you pass a define constant in such Concat function as the first parameter, you'll get the result same as in your question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.