Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930

Reprocessor Directives!

Hi,

I'm trying to put the reprocessor Directives code in my app project. The first problem that I'm facing is

that I can't follow up with the steps that this link is providing. I'm not sure but I think that the information

is kind of dated, because I'm not able to find Blackberry Project Properties under properties.

 

http://berrytutorials.blogspot.com/2009/11/coding-for-multiple-blackberry-devices.html

 

Waiting for your help.

 

Thanks.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Reprocessor Directives!

using a three year old guide from another site is a bit problematic i guess.

you can set preprocessing directives in the "Build" tab of the application descriptor.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930

Re: Reprocessor Directives!

Thanks Simon,

You are always here with your great responses. Yes, I know the site is kind of old :smileysad:.

Is there like a link with more information about that?

 

Thank you again.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Reprocessor Directives!

try this:
http://docs.blackberry.com/en/developers/deliverables/12002/Specifying_preprocessor_directives_65763...
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930

Re: Reprocess Directives!

Thank you so much again Simon. Actually, I tried the code that the blackberry website providing, it didn't work. I'm not sure I did it in the right way. They didn't explain it in a good way. Did you work with the Reprocesses Directives (RD) before? I will explain to you what I understood and then it would be great if you can correct my understanding.

 

I wrote an app and compile it with JRE 7, which is normally won't work with JRE 6 or 5. But if we use the (RD) that would make the eclipse skip the lines of code that is not supported by JRE 6,5 and compile it normally.

 

 My questions are :

 

 1- when we compile it with 7 are we going to use the same Lax file with BB devices that runs JRE 5,6... Or vise versa, I mean we compile it with 5,6 and use the same Lax file with 7.

 

 2-  As the BB site saying that we should

 

/#processes in the first line of the code.

/# implicit ( This was from another website)

//# of def tag ... # else

end if...

to surround the code that is not supported by the older JRE.

 

Is that right? I did it and when I put this on eclips it make it like a comment, and it won't let it compile.

 

I'm kind of confused... I hope that anyone  can explain more about that. And it would be great if there would be a code to support that.

 

 

Thank you so much.

 

 

 

 

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Reprocess Directives!

here is a sample from my code. first line of the file must be '//#preprocess'
//#ifdef VER_4_6_0_AND_ABOVE
private MessageFolderDaemon messageFolderDaemon;
//#endif

 



In the BlackBerry_App_Descriptor.xml on the Build tab you create the directive VER_4_6_0_AND_ABOVE using the add button. When you switch to 4.6 or higher you enable it by clicking the active checkbox. you can use similar conditions for 4.7, 5.0, 6.0 etc I think '#else' is problemativ, we avoid it at least, but '#ifndef' should work. sometimes i use boolean flags for more complicated constructs
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930

Re: Reprocess Directives!

Thank you Simon.

 

I went tothe Descriptor.xml --> Build and I found that BLACKBERRYSDK5.0.0

                                                                                  BLACKBERRYSDK6.0.0

                                                                                  BLACKBERRYSDK7.0.0

 

Are all here, but only Blackberry7.0.0 is checked. And it won't let me check the rest.

 

So, I first turn the preprosser

You can turn on preprocessing for your applications by updating the Eclipse® configuration file.
1. Browse to C:\Program Files\Eclipse\configuration, open the config.ini file.
2. Add the following line to the config.ini file:
• osgi.framework.extensions=net.rim.ejde

 

and then put the code

 

'//#preprocess' 

 

//#ifdef VER_4_6_0_AND_ABOVE

.........

//#endif

 

the other SDK would be available for me to check? or I should install other things?

Okay,  Let's say I clicked SDK5. That means I will have one file for JRE 5 and another one by clicking the SDK6 for 6. Or 5 file will work with all the versions.

 

 

Sorry for asking a lot.

 

I really appreciate your help Simon.

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: Reprocess Directives!

the existing defines are used by the system and checked automatically when you change the JDK used to compile.
You have to create your own to use with preprocessing. VER_4_6_0_AND_ABOVE is just an example (as i use this), you can use whatever you want, but you have to define it yourself by using "Add..." on the build tab.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Developer
paulkayuk
Posts: 133
Registered: ‎04-30-2010
My Device: Curve 8520

Re: Reprocess Directives!

I get by with the pre-defined defines just fine using #ifdef #elseif and #endif e.g.

 

//#ifdef BlackBerrySDK4.6.0 | BlackBerrySDK4.6.1

HomeScreen.updateIcon(TaskingResourceManager.getBitmapFromResource("tasking_icon_64.png"));

HomeScreen.setRolloverIcon(TaskingResourceManager.getBitmapFromResource("tasking_icon_64_ro.png"));

//#elseif BlackBerrySDK4.7.0 | BlackBerrySDK5.0.0 | BlackBerrySDK6.0.0 | BlackBerrySDK7.0.0 | BlackBerrySDK7.1.0

ApplicationDescriptor ad = ApplicationDescriptor.currentApplicationDescriptor();

HomeScreen.updateIcon(TaskingResourceManager.getBitmapFromResource("tasking_icon_64.png"), ad);

HomeScreen.setRolloverIcon(null, ad);

//#endif

 

maybe a bit long winded, but in place it tells the full story without referring to custom defines

New Developer
Sultan14
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930

Re: Reprocess Directives!

So, should I change the the build path on my project and let see JRE 5 and JRE6?  Because when I do that right now. It gives me an error. And it flag the project with red and showing me an error in line zero. I can't see what is going wrong on the Java files cause it shows no wrong with them. The only thing is red is the project folder and the project won't run on the simulator.