BlackBerry Forums Support Community
              

Closed Thread
 
Thread Tools
Old 04-15-2009, 03:57 AM   #1
misty83
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
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
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
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
misty83
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
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
misty83
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
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
hrbuckley
BlackBerry Extraordinaire
 
Join Date: Jan 2006
Model: LEZ10
OS: 10.0.10
Carrier: Rogers CA
Posts: 1,704
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
misty83
Thumbs Must Hurt
 
Join Date: Jan 2009
Model: 7100T
PIN: N/A
Carrier: -
Posts: 73
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



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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


Grandstream GXP2160 VoIP IP Phone Color Gigabit Enterprise HD 6 Line PoE Black picture

Grandstream GXP2160 VoIP IP Phone Color Gigabit Enterprise HD 6 Line PoE Black

$37.98



Polycom VVX 410 VoIP IP Phone & Stand Warranty Reset VVX410 2201-46162-001 Lync picture

Polycom VVX 410 VoIP IP Phone & Stand Warranty Reset VVX410 2201-46162-001 Lync

$17.98



Polycom SoundStation IP 6000 VoIP Conference Phone - No cords, No Accessories picture

Polycom SoundStation IP 6000 VoIP Conference Phone - No cords, No Accessories

$18.00



Allworx 9212 VoIP IP Phone with Stand Warranty Paetec 9212P Business Office picture

Allworx 9212 VoIP IP Phone with Stand Warranty Paetec 9212P Business Office

$17.98



Polycom VVX 501 VoIP IP Phone & Stand Blem Warranty VVX501 2201-48500-001 picture

Polycom VVX 501 VoIP IP Phone & Stand Blem Warranty VVX501 2201-48500-001

$14.98



Polycom VVX 350 VoIP IP Phone NO STAND Warranty Reset VVX350 2201-48830-001 picture

Polycom VVX 350 VoIP IP Phone NO STAND Warranty Reset VVX350 2201-48830-001

$29.98







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