BlackBerry Forums Support Community               

Closed Thread
 
LinkBack Thread Tools
Old 04-15-2009, 03:57 AM   #1 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default how to use preprocessor?

Please Login to Remove!

hi, my application differs a little for JDE lower than 4.7 and equal or higher than 4.7. i know i must use preprocessor for that. i modified my *.jdp file and added:

Options=-quiet -define=VERSION_4_2_1;PREPROCESSOR

then i wrote a simple code just to check if it works:
Code:
//#preprocess
import java.util.*;
import net.rim.device.api.system.*;

public class PreprocessorTest extends Application{

	public PreprocessorTest(){
		
//#ifdef VER_4_5_0
		Dialog.inform("this is 4.5");
//#else
		Dialog.inform("other than 4.5");
//#endif		
		
	}
	
	public static void main(String[] args){
		PreprocessorTest _pt = new PreprocessorTest();
		_pt.enterEventDispatcher();
	}
	
}
and what i got is both alerts: "this is 4.5" and "other than 4.5". and under properties->BlackBerry Project Properties->Compile->Preprocessor defines i added PREPROCESSOR

What is wrong, how can i use it?
Offline  
Old 04-15-2009, 07:48 AM   #2 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Hm, that is strange. From what I see it should work and just give you the "other than 4.5" dialog.
Offline  
Old 04-15-2009, 07:52 AM   #3 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

i use eclipse-plugin in and i'm wondering if everything is ok with my eclipse.. maybe i should set smth in properties?
Offline  
Old 04-16-2009, 03:20 AM   #4 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok, it seems that there is smth wrong with eclipse complier. i downloaded JDE from RIM and when i use that, everything works, except that i do not get the message that i should. i mean with this simple code:

Code:
//#preprocess
import net.rim.device.api.ui.UiApplication;

public class PrepTest extends UiApplication{  
  
  public PrepTest()    { 
  
  //#define abc
  
     //#ifdef abc 
 
            System.out.println("there is abc");
    
     //#elseif
  
        System.out.println("no abc");
        
                   //#endif    
                   } 
     
       public static void main(String[] args)    {
           
               PrepTest x = new PrepTest();     
                x.enterEventDispatcher();    
                }
                
          }
i'm getting 'no abc'.. but why?? it is written that //#define abc

in *.jdp file the only thing i changed is:

Options=-quiet -define=PREPROCESSOR

i did not define 'abc' there. cause i do not want to define anything in any file. i want to use preprocessor to define things when i need (in the source of my application). i thought that
//#define abc

works like that and that then it will be visibile in application that abc is defined so that i can go to the proper conditions..
Offline  
Old 04-16-2009, 07:12 AM   #5 (permalink)
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
Post Thanks: 20
Thanked 77 Times in 68 Posts
Default

Ah, yes Eclipse may be different, or may not support preprocessing. Preprocessing is not part of the Java standard so implementations will vary. I have never seen anything that indicates the JDE accepts //#define constructs. There are two ways to define preprocessor constants:
1) in the .jdp file -define=CONST1;CONST2;CONST3
2) in the JDE right click on the project, Properties, select the Compile tab, add to the Preprocessor defines section
Offline  
Old 04-16-2009, 07:34 AM   #6 (permalink)
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default

//#define works in j2me so i thought it will also work for bb. but it doesn't.

anyway, thx for help.

kind regards
Offline  
Closed Thread


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On





Copyright 2004-2014 BlackBerryForums.com.
The names RIM and BlackBerry are registered Trademarks of BlackBerry Inc.