Converting String to boolean not working

Hello there - I am having a bit of trouble - I am trying to write a program to evaluate boolean expressions (fully parenthesized) As StringTokenizer goes through the expression, the boolean values are being pushed (as Boolean objects) and popped (converted to String) correctly, but the expression I am using to evaluate them is evaluating false (see my debug below)
In my current code, I have op1 and op2 coming off of the stack as Strings but am not sure if Boolean.getBoolean() is the right method to use to convert them to boolean values. The Sun docs weren't very helpful and there wasn't anything that I could find on the Sun forum about converting Strings to boolean (vs. Boolean). This is what my evaluate code looks like:
if (operation.equals("||")) {
opB1 = Boolean.getBoolean(op1);
opB2 = Boolean.getBoolean(op2);
test = (opB1 || opB2);
System.out.println("test = (opB1 || opB2) " + (opB1 || opB2)); //debug
System.out.println("opB1 = " + opB1 + " opB2 = " + opB2); //debug
In the above example - using the expression "( ( 1 < 2 ) && ( 2 > 1 ) )" my debug reads like this:
Operator added to stack is (
Operator added to stack is (
Operand added to stack is 1
Operator added to stack is <
Operand added to stack is 2
Operation removed from stack is <
Operand removed from stack is 2
Operand removed from stack is 1
Boolean operand added to stack is true
Operation removed from stack is (
Operator added to stack is &&
Operator added to stack is (
Operand added to stack is 2
Operator added to stack is >
Operand added to stack is 1
Operation removed from stack is >
Operand removed from stack is 1
Operand removed from stack is 2
Boolean operand added to stack is true
Operation removed from stack is (
Operation removed from stack is &&
Operand removed from stack is true //NOTE: values are both true
Operand removed from stack is true
test = (opB1 && opB2) false //NOTE: expression is evaluating as false
opB1 = false opB2 = false //NOTE: converted String went from true to false!!
Boolean operand added to stack is false
Operation removed from stack is (
When I changed the type of opB1 & opB2 to type Boolean, and use:
if (operation.equals("||")) {
opB1 = Boolean.valueOf(op1);
opB2 = Boolean.valueOf(op2);
test = (opB1 || opB2);
System.out.println("test = (opB1 || opB2) " + (opB1 || opB2)); //debug
System.out.println("opB1 = " + opB1 + " opB2 = " + opB2); //debug
I get an error that || and && can't be used on type Boolean.
I've spent several hours on this boolean part alone - any suggestions? (BTW - sorry for the long message!)

You're a genius!! Wow I never would have figured that one out in a million years!! BTW - can you tell me how you got your code to be so nicely formatted in the post?
Everytime I cut and paste - it looks aweful and all of the indentations are gone...
Thanks again!!!

Similar Messages

  • CRIO: Unflatten from string into lvclass not working in deployment

    Hello,
    I am working on a problem for some hours now and I need some help.
    I am using a cRIO-9022. I need to do some tasks, and I created a couple of classes which contain the parameters and the methods. They contain using dynamic dispatch VIs. I have an array of these classes (all derived from a parent class) which is my "configuration". I am using "flatten to string" and saving those file on disk. "Unflatten from string" is working fine. These file is created on a LV WIndows Application.
    I need to use this file on my cRIO: Unflatten from string, and then work with the array of my classes. When running the cRIO Main VI it's working fine. But when building the application and deploying it as startup, it's not working. I am getting:
    Error 1403 occurred at Unflatten From String in Gantry CommEngine.vi->RT Main.vi
    Possible reason(s):
    LabVIEW:  Attempted to read flattened data of a LabVIEW class. The data is corrupt. LabVIEW could not interpret the data as any valid flattened LabVIEW class.
    What I tried so far:
    - Added the whole lvlib containing the classes and also every single class to "Source files / always included".
    - Created constants of the array (containing the classes) to the VI (forcing LV to include the classes?)
    - Loaded the file from cRIOs flash and also by shared variable
    What else can I do?
    Thanks a lot for support!

    I tried to reproduce the matter, but couldn't. 
    I attached my example to the post. 
    What it does:
    It creates a class with only a string a bool and a number. This class oblect is saved to C:/somename.xml. The number is a random number.
    In the second case the same file is read and the number broadcasted to a variable.
    It worked quite fine building it as a startupexe.
    Nothing else was necessary. Does it work for you?
    Attachments:
    class exe.zip ‏45 KB

  • Why String Search in not working in ADF.?

    Hi,
        I've created application in ADF with Search Options. Search Operation is working for all the Integer Values in that page but its not working for String Values.
    I dont know why its not able to search String Values.
    My AppModule bean Code :
                    package model.portfolio.portfolio.am;
    import model.portfolio.portfolio.am.common.PortfolioAppModuleAM;
    import model.portfolio.portfolio.view.ResourceViewChildObjImpl;
    import oracle.jbo.VariableValueManager;
    import oracle.jbo.ViewCriteria;
    import oracle.jbo.server.ApplicationModuleImpl;
    import oracle.jbo.server.ViewLinkImpl;
    import oracle.jbo.server.ViewObjectImpl;
    public class PortfolioAppModuleAMImpl extends ApplicationModuleImpl implements PortfolioAppModuleAM {
         * This is the default constructor (do not remove).
        public PortfolioAppModuleAMImpl() {
        public void applyVCforGlobalSearchPortfolios(String theString){
            ViewObjectImpl vo = getPortfolio1();
            ViewCriteria vc = vo.getViewCriteria("PortfolioVOCriteria");
            System.out.println("On Criteria");
            vc.resetCriteria();
            VariableValueManager vvm = vc.ensureVariableManager();
            System.out.println("On String");
            vvm.setVariableValue("globalSearchString", theString);
            System.out.println("After String");
            vo.applyViewCriteria(vc,true);
            vo.executeQuery();
    *All Getters and Setter of all VO and VLs****
    My Query created in View Criteria :
    ( (UPPER(SHORTNAME) LIKE UPPER( :globalSearchString || '%') ) OR (UPPER(DESCRIPTION) LIKE UPPER( :globalSearchString || '%') ) AND (PROGRAMMES_COUNT = :globalSearchString ) OR (KK_COUNT = :globalSearchString ) OR (KPI_KRA_VALUE = :globalSearchString ) )
    One more interesting thing in After Creating the View Criteria If i try to Test this Query, Its giving me error msg as
    "Cannot complete query to determine the view attributes.  Either the query is invalid or timeout occurs.  Please revise the query or create the view attributes manually.
    "com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':globalSearchString || '%') ) OR (UPPER(QRSLT.DESCRIPTION) LIKE UPPER( :globalSe' at line 1"
    I don know why... Can somebody please help me?
    Im using Jdev 12C

    Binding variables will be different from oracle database and My Sql database.
    Oracle database use this (:) for defining bindVariable but in My Sql use this (?)
    Try to remove the view criteria which you define in View Object and you can make it programmatically like this:
        ViewObject vo = getPortfolio1();
        ViewCriteria vc = vo.createViewCriteria();
        ViewCriteriaRow vcr = vc.createViewCriteriaRow();
        vcr.setAttribute("Attribute1", value);
        vcr.setAttribute("Attribute2", value);
        vc.add(vcr);
        vo.applyViewCriteria(vc);
        vo.executeQuery();

  • I bought Smart Photo Converter which do,s not work but i can't get any refund , i have contacted the company but no reply and that was two weeks ago...so do you talk to someone at the App store?

    I bought Smart Photo Converter which does not work but i can't get any refund , i have contacted the company but no reply and that was two weeks ago...so do you talk to someone at the App store?

    Mac App Store Support -
    http://www.apple.com/support/mac/app-store/

  • Trying to use string tokenizer but not working as expected

    Hello friends,
    In the following code, I am trying to acheive an output like this:
    Manju Nambiar
    Mini Nambiar
    -variable mc stands for the maximum number characters allowed in a line.
    -variable wb stands for wordbreak allowed i.e if set to false, a word should be printed as it is without splitting even if the maxchar limit is crossed, but then the next word should come on the next line.
    String input = "Manju Nambiar Mini Nambiar";
    String token;
    String wb = "f";
    String newlineop = System.getProperty("line.separator");
    int mc = 10;
    if(wb.equalsIgnoreCase("f"))
    StringTokenizer splitip = new StringTokenizer(input," ");
    while(splitip.hasMoreTokens())
    token = splitip.nextToken();
    System.out.println("length is:"+newlineop.length());
    if((newlineop.length())<mc)
    newlineop = newlineop.concat(token+" ");
    else
    newlineop = newlineop.concat(newline+token);
    System.out.println(newlineop);
    The output I am getting is:
    Manju Nambiar
    Mini
    Nambiar
    I know it is because of the length of the newlineop variable that I am checking in the loop - but I am not able to see how to circumvent this??? :-(
    Please Help,
    Thanks,
    Manju

            String input = "Manju Nambiar Mini Nambiar";
            String token;
            boolean wb = false; // as Nasch pointed out, use boolean here
            String newlineop = System.getProperty("line.separator");
            int tokenLength = 0; // variable to check length of line
            int mc = 10;
            if (!wb)
                StringTokenizer splitip = new StringTokenizer(input, " ");
                while (splitip.hasMoreTokens())
                    token = splitip.nextToken();               
                    if (tokenLength < mc)
                        tokenLength += token.length();
                        newlineop = newlineop.concat(token + " ");
                    else
                        tokenLength = token.length(); //new line, reset length
                        newlineop = newlineop.concat("\n" + token + " ");
            System.out.println(newlineop);
        ram.

  • All strings virtual instruments not working!

    everything was working great in my song, but all the strings virtual instruments randomly stopped working. the notes cut off after a quarter of a measure. if i change that track to any non string instrument, the notes play out the way they're supposed to. i've tried creating new string instruments and i have the same problem, i have no idea how i caused this or how to fix it. help please

    never mind, the problem stopped after i restarted my computer again. thanks to everyone who didn't help!

  • Converting to PDF is not working

    I pay a monthly fee to be able to convert documents to PDF, but it has not been working.  The 1st 3 documents I converted several months ago were a breeze, but since then going through the same procedure is completely unsuccessful.  All it does is say "uploading" and never goes any further.  Is there any way to get this fixed, or if not how on earth do I find a way to contact this company to cancel my subscription/license?  I can't keep paying for something that does not work.

    Hi jkreed2,
    We would like to help!
    1) What type of doc are you converting to PDF? How large is the document?
    2) Here is how to manage your subscription:
    *Sign in <, in the top right corner using your Adobe.com credentials
    *Click on your name (same location) and select ‘My products and services’
    *From there you can check on your status, log in/account info, update/cxl, etc.
    Looking forward to hearing back from you!
    Regards, Stacy

  • Not equal to operator in KQL i.e. for string comparison is not working. Is there any other approach for this?

    In KQL my query is like this,
    refinablestring05<>9c460541-5979-44ec-b0ab-63d1823f922f
    but looks like operator <> not working. It is not throwing error at all and always shows result.
    Any one can help me out for this?

    use NOT operator so it would be "NOT refinablestring:something"
    kashif

  • LSMW For Converting Open Sales Orders (not working for more than 1 item)

    Hi,
    I am using following standard object for Open sales orders .
    Object               0090   Sales documents                   
    Method               0000                                     
    Program Name         RVINVB10                                 
    Program Type         D   Direct Input                         
    Its not working for more than 1 line item.
    For more than 1 line item its giving Error saying that
    '102122                         V1                   845
    Print parameter SAPML2 1 is not defined
    Can anybody help me out in this regard.
    Thanks in advance.
    Nitin.

    hello, friend.
    i will still research the subject.  but the first thing that comes into my mind is t-code VA05.  with this, you have the option to change the Plant en masse.  so a possible workaround is for you to list a number of sales orders using VA05.  you then sort the line items by Plant.  choose all items with the same plant, change the plant via mass change... then change back to the original plant.  hopefully, the new settings should apply.
    do test a few sales orders by doing this for a larger scope.
    regards.

  • Trying to implement variable into a string...not working

    Hey guys,
    I am fiddling with a Cocoa app of mine, and for some really odd reason this is not working. I cannot find a solution, but maybe you will be able to pinpoint what is going on.
    NSString * studentReply;
    studentReply = @"%@ says okay.", studentsName;
    All it returns in Interface Builder is - "%@ says okay."
    I'd appreciate any help you can offer.
    Ricky.

    You weren't calling a formatting method.
    Besides separating arguments, a comma can also separate statements, so what your code was essentially saying to the computer was:
    First do: studentReply = @"%@ says okay." and then do: studentsName The first statement is a simple assignment (which is why you are seeing "%@ says okay." as the output). The second statement doesn't really do anything (just tells the computer to "evaluate" the variable) but it won't complain.
    Hope that helps.

  • Convert PDF to WORD not working

    Just purchased ExportPDF - can't convert PDF file to WORD document. the "CONVERT" button on screen not activated.

    Hi Nolan,
    I check the subscription status under the email Id you provided also for security reason i delete the Email id from your previous post.
    I wasn't able to find any subscription under that email id. Please provide me the other email id if you have choose the other one while subscribing for ExportPDF service
    Please visit below mentioned forum thread to send private message to send your personal Information.
    http://forums.adobe.com/thread/1184148
    Regards,
    Ajlan Huda.

  • String CDF functions not working in business rules

    Working with EPM 11.1.2. I created a calc script on the planning cube and it works perfectly. I then put the same code in a business rule and it will not validate. Please see the code below.
    1) created udf folder in following directory
    essbase/Oracle/Middleware/EPMSystem11R1/products/Essbase/EssbaseServer/java
    2) modified udf policy to grant access to all
    3) saved CDF_String.jar file to new udf folder on server
    4) registered functions via maxl
    5) stop/start application
    6) stopped/started EAS services
    I get the following error in the message window (line 9 is the JGetStringFromDouble statement):
    "Encountered " "-> " "-> "" at line 9, column 35.
    Was expected one of:
    What do I need to do to get this code working as a business rule since I want to use RTPs in this routine?
    FIX("No_Profit_Center", FY07:&CapAppEndYr, "Working Plan", "Current", "Manual_Input", "LOC", @Relative("Period",0), @Relative("Project",0), @Relative("Entity",0))
    "AC_Unappr_Fcst_Depr"
      IF ( "AC_Unappr_Fcst_Depr"  == #Missing)
         IF ("FY07"->"No_Period"->"AC_Depr_CC" != #Missing)
              "AC_Unappr_Fcst_Depr"->(@MEMBER(@CONCATENATE("EN_",@JgetStringFromDouble("FY07"->"No_Period"->"AC_Depr_CC",@_False,@_False))))  = "AC_Unappr_Fcst_Depr_Temp";
        ELSE
              "AC_Unappr_Fcst_Depr" = "AC_Unappr_Fcst_Depr_Temp";
        ENDIF
      ENDIF
    ENDFIXEdited by: jjdubb on Jun 11, 2012 9:10 AM

    I've had this issue with a different string function. Business Rules does not like the boolean parameters (@_FALSE) used in these CDF's. I had a similar issue and had to rewrite my CDF without the parameters. You basically need to hardcode the "with quotes" and "with decimals" parameters in the java code.
    Hope this helps,
    - Jake

  • Hyperlinks from converted excel file are not working after pdf file is moved

    I have created a pdf file from an excel file that has hyperlinks in it. The hyperlinks work fine if the files are all kept in the same exact location as the time they were created. Once the files are moved (i.e. emailed to another user) the hyperlinks no longer work. An error message pops up that the file can not be found. Is there a setting or something that I'm missing in acrobat that allows for the files to be moved, so that the hyperlinks still function properly, after creation

    No settings adjustments.
    The issue is that links, once made, have a specific path (as shown when you view the link's text string).
    When you email the files the person who recieves the email and downloads the attachments would have to have the same layout of files/folders you have.
    Without that links are "broken"
    You email a zip file that, when extracted, would create the folders/files in the required layout to reflect what you have.
    Be well...

  • Downloading DNG converter and it's not working

    I've downloaded, reinstalled, and tried several different versions of DNG converter to download my 2nd shooters Nikon D7100 RAW .NEF files, but it's not finding any images once I have it installed. I've downloaded version 7.4 for Windows, which contains the D7100 update...and I've tried installing the newer version 8.6 as well. Nothing seems to be working. What am I doing wrong?

    If you are new to the DNG converter, it's possible you are getting caught by the prompt where the converter is asking you to locate your raw files. It's only asking for the folder. Don't open the folder containing your raw images or you will get the message that there are no images to convert.

  • Canon 5d MkII converted to ProRes - Effects not working in FCP sequence?

    I am trying to figure out why I can't get any of my effects to show up in the viewer or the canvas when working with 5D Mark II converted footage.
    I converted all my files to ProRes and now nothing but my transitions are working. No Color Correction, no filters, nothing.
    Has anyone else come across this problem?
    Thanks.

    I have been working with 5D files and have not experienced this problem.
    Please note that the 5D will typically record at 30.00 frames per second, not 29.97 fps required by typical TV standards. Canon supposedly has new firmware that "may" correct for this when recording. You should correct for this when converting to Pro Res by forcing the frame rate to 29.97.
    Check the detailed information on the individual clips (Control-click on the clip and check file info)
    If the frame rate is indeed correct, try trashing your FCP preferences and see if that corrects the problem.

Maybe you are looking for

  • E2 no longer holding a charge

    I have had my E2 since 2005 or 6 and though its old, it is still in great shape.  Lately, it seems to show only 50% battery power after 8 hours or so of using it on and off.  I tried leaving it to charge for 36 hours but it still drained very quickly

  • My iphone 4s is no longer making sound when i have an incoming call or message after installing ios7.... any help?

    My iphone 4s is no longer making sound when i have an incoming call or message after installing ios7.... any help? It still vibrates but no calling sounds or message sounds. It's not on mute and the speakers are working... I can hear music etc. Oh ye

  • How To Edit Quicktime Files

    Hi, I just bought a Panasonic still-shot camera with "Movie Mode". This little camera shoots 20 minutes of letterbox video at 30fps in Quicktime format! My question is: what settings should I use in FCP so that I don't have to render the clips as I d

  • Unable to login to My Cloud Dashboard

    can't  enter my dashboard forget my password, where can i  get my password

  • What do you think of my applet game

    Over the last couple days, I made a java applet game. It is all complete except for the highscores. I am planning on doing some sort of global highscores and since I have little experience with internet programming, it is going to take a little while