Taking out IF's and returning a boolean expression

I thought a better way to implement this later method might be to remove the IF's and just return a boolean expression true or false if one date object is later than another date object. I almost have it correct but one case is still not outputting correctly.
Heres the return statement:
return ((year > otherDate.year)||(year==otherDate.year)&&(month > otherDate.month)&&
                    (day > otherDate.day));

someone told you that the code looked right? humm... don't look right to me.
basically if the years are different you are done and know the answer but if the years are the same you must look to the month
So why don't you have exactly the same situation to deal with the case where you only look at the day if the months are equal? You need an extra set of parens, and another || condition and a term involving == months.
Nope, your code just mixes together the code for checking days and checking months.
You CAN do this all in a single boolean expression, but it is nested two levels deep and too long to fit on a line. And you got it wrong. (this is a hint that the person reading the code will also not be sure that the code is correct)
You have done no one a favor by removing the IFs and using a single complicated boolean expression.

Similar Messages

  • Sometimes when I am texting the screen freezes.  I have to go out of messages and return and then I can send.

    Sometimes when I am texting the screen freezes.  I have to go out of messages and return and then I can send.

    Hello mdcrab1,
    Thank you for participating in the Apple Support Communities.
    If your screen freezes sometimes when you're texting until you quit and re-launch Messages, try these troubleshooting steps first:
    Restart your device and check for updates
    Restart your device.
    Check for a carrier settings update.
    Check for an iOS software update.
    You can find these steps and more troubleshooting tips at this link:
    If you can't send or receive messages on your iPhone, iPad, or iPod touch - Apple Support
    If the issue continues, and it only happens in the Messages app, I recommend trying the rest of the steps in the above article.
    If the screen freezes sometimes when you're using other apps, the steps in this article can help:
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Sincerely,
    Jeremy

  • Honeycomb some time navigating in tabs does not work. if i select tab a from tab b, the header changes but not the page. It does if i move out of app and return

    using samsung p6200.
    If i open multiple tabs (say more than 14) so say ifi am on 14 tab and back to 12th then it will switch properly but if i go back to first tab it wont show the webpage. some tabs will show and some wont. sometime the tab will show a type of progressive image of tab which wont get more clear. But tab switches if i move out of application and return. example i am not tab 14 say gizmodo.com and i return to tab 2 say wikipedia then it wont change the page. if i go to task manager and return back to firefox then it will show the page.

    I agree that it cant be as smooth but this issue is replicable in much less tabs as well.. around 4. Also i dont see any reason not to open 14 tabs as when i run Ubuntu on sam tablet parallel to Android, i can open tabs in firefox in Ubuntu. I understand the architecture difference of green bot and ubuntu for which i hate android. i wanted to hilight that firefox is working fine but somewhere it is unable to fetch data from its cache, while when OS reloads the app from background to foreground, the cache is retrieved.

  • Exit out of video and return to stage frame 1

    Ive manged to create a flash player that incorporates a video
    using a online
    tutorial with the code below.
    All is working well but at the end of the video I want to
    exit out of the
    video and return to the stage at frame 1. The reason being
    is; before a user
    hits play an interface image (containing info) is displayed.
    When they hit
    the play button the video appears and plays over the
    interface image.
    problem is at the end of the video the layer containing the
    image is still
    covered by the video. when the video finishes I need a line
    of code to exit
    and return the player to the original state without the
    presecence of the
    video layer.
    any ideas? thanks in advance
    Brett
    var nc:NetConnection = new NetConnection();
    nc.connect(null);
    var ns:NetStream = new NetStream(nc);
    theVideo.attachVideo(ns);
    rewindButton.onRelease = function() {
    ns.seek(0);
    ns.play();
    playButton.onRelease = function() {
    ns.play("modular.flv");
    pauseButton.onRelease = function() {
    ns.pause();
    var videoInterval = setInterval(videoStatus,100);
    var amountLoaded:Number;
    var duration:Number;
    ns["onMetaData"] = function (obj) {
    duration = obj.duration;
    function videoStatus() {
    amountLoaded = ns.bytesLoaded / ns.bytesTotal;
    loader.loadbar._width = amountLoaded * 200;
    loader.scrub._x = ns.time / duration * 200;
    var scrubInterval;
    loader.scrub.onPress = function(){
    clearInterval(videoInterval);
    scrubInterval = setInterval(scrubit, 10);
    this.startDrag(false,1,this._y,198,this._y);
    loader.scrub.onRelease = loader.scrub.onReleaseOutside =
    function () {
    clearInterval(scrubInterval);
    videoInterval = setInterval(videoStatus,100);
    this.stopDrag();
    function scrubit() {
    ns.seek(Math.floor((loader.scrub._x/200)*duration));

    Inside the videoStatus() function Check the Current Time and
    Total time for video completion. Some time the Video doesn't have
    exact Time when comparing to the Total duration so use Math.floor
    to compare. if you still facing problem also check the Buffer
    status and Video status too.

  • Frequent random software crashes taking out files, applications and OS

    We are a small niche publishing company with a network of 9 Macs of various ages - some very new running 10.6.3 and others older (mini macs running 10.5). We run MS Office (2004,2008 and 2011), Extensis Suitcase (Fusion) and QuarkXpress v8.
    About 6 months ago one of the Mac users (running OS 10.5) complained that his Microsoft User Data folder had moved. I moved it back but everything then went downhill from then on. One by one all the Macs became corrupted in some way, and they nearly always followed the same pattern. Firstly files or folders on the desktop go missing (not in trash) then Extensis Suitcase and QuarkXpress become corrupted. Quite often Word or Entourage fails too. On many occasions the OS has also become corrupted so I have to reinstall everything.
    This now happens on a daily basis, although 2 or 3 of the Macs seem to have settled down and have not played up for some weeks. As you can imagine we have wasted a tremendous amount of time and energy on this. We employed the services of an IT specialist who cannot work out what the problem is. He thought it was a file-sharing problem and installed a Mac Server but it has made no difference.
    Someone in an online IT forum suggested that if we have a Quark document that keeps getting over-written (which is the case with us) then it has probably become corrupted and it corrupts whatever is stored near it on the hard drive, so could quite easily take down applications and the OS. This seemed logical and I asked the department to build new pages from scratch and banned them from opening the old pages. This has made no difference.
    QuarkXpress themselves said that Quark can crash if you edit and save a document which was created in an earlier version of Quark. Well, Quark crashes all the time and seems to be the worst piece of software ever written in my opinion, but it shouldn't wipe out your whole computer, should it??
    I had also suspected a virus and put Kaspersky on a couple of the most-used Macs for a while but it didn't find anything so I didn't bother reinstalling it again when I next had to do a re-install of the Macs.
    I am now suspecting it could be something to do with MS Office 2004. I have some older Mac Minis which should be running it fine (but don't) but it has also been loaded on a few of the more modern iMacs running 10.6. I notice the two Macs running 10.6 which have "settled down" and haven't played up for weeks run Office 2008 and 2011.
    I am also posting this problem to Microsoft and Quark in the hope that someone somewhere has experienced this before and can come up with a solution.

    The theories that best fit your description are (1) sabotage and (2) defective third-party software.
    As for (1), check your logs carefully for evidence of unauthorized access, either remote or local.
    As for (2), look for anything you installed on all the affected hosts that runs as root or includes a kernel extension. Commercial "anti-virus" software would be a prime suspect.
    Verify the directory of the startup volume of each client in Disk Utility (you can do this via a remote shell with diskutil.)
    +QuarkXpress themselves said that Quark can crash if you edit and save a document which was created in an earlier version of Quark. Well, Quark crashes all the time and seems to be the worst piece of software ever written in my opinion, but it shouldn't wipe out your whole computer, should it?+
    No, it shouldn't and it can't.

  • 7373 wont boot after taking out mini sd and puttin...

    I rencently purchased a nokia 7373 everything was ok untill i took the mini sd out. when i put it back in and turned my phone on it would start up then the screen would go white and the wallpaper would appear and a white screen again then the phone turned off completley!! i took it back got a new 7373 and the same thing happened with that!! does anyone know why and how to fix!!???? cheers.

    that sux man... same thing happened to my nokia 7390 as well...
    so now i just use the phone without sd card....

  • SQL statement to compare dates and return boolean (yes/no)

    I am looking for a SQL statement that can compare 2 dates and return a boolean. 1 (yes) if date 1 is => date2-threshold or 0 (No) if date < date2-threshold
    Ie
    date1=20130603
    threshold=2 days
    date2=sysdate-threshold
    if [ 20130603 > sysdate-$threshold ]
    then
    return 1
    else
    return 0
    fi
    Thanks to all that answer.

    Assumming I want to get "date1" from some other table instead of from
    dual will this syntax be valid
    I was going to invoke another SQLPLUS from my shell script and pass it in
    as a variable but if I can do it on one shot it would be better.
    In addition, if "no rows" are found for date1 from the below query, would
    I need code to handle that
    with xx as
        select TO_DATE(last_date','yyyymmdd') date1, from dba_audit_table where ...;
         select TO_DATE('20130603','yyyymmdd') date1, sysdate date2  from dual;
    Thanks to all who answer
    [/code1]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Dynamic boolean expression evaluation

    Hey everyone,
    We have a table that consists of a couple key columns and a column containing a boolean expression. We want to select a number of rows based on the key columns and evaluate the boolean expression in the expression column for each, only returning the first row wherein the boolean expression evaluates to true.
    We are using a context to inject the test variables into the boolean expressions and currently we are selecting all the key rows in a PL/SQL procedure and going through the cursor evaluating each of the boolean expressions with an execute immediate.
    The expressions are currently formated in the columns as anonymous PL/SQL blocks that, when called, will either return true or false to the PL/SQL procedure. Upon returning true, the procedure stops looping and returns true to the caller.
    Psuedo-code would be:
    - set-up sys_context with condition variables
    - create cursor for: select * from expression_tbl et where <key matches>
    - begin loop through cursor
    - execute immediate cursor_row.expression using out :out_is_true
    - if out_is_true = 'Y' then return true
    - loop
    - return false
    The expressions (anonymous PL/SQL blocks) from the table look something like this:
    begin if ((''||sys_context('ctx', '1')||'' = 'FL') AND (''||sys_context('ctx', '3')||'' BETWEEN 1619 AND 4598) ) then :1 := 'Y'; end if; end;
    This works, but it seems like I should be able to do this another way and potentially extract more performance.
    So...a couple questions:
    1) I have read on ask Tom that a dynamic select statement (rather than an anonymous PL/SQL block) can evaulate the boolean expressions. I.E. rather than use an execute immediate clause on an anonymous PL/SQL block contained in the expression column, I would make the expression column compatible with a where clause and create this dynamic SQL query: 'select count(*) from dual where ' || expression. I would then execute that query and if it returns a row then the expression is true, otherwise it is false. My question is, does anyone think the performance of parsing the SQL and executing it would be better than that of executing an anonymous PL/SQL block for every row? Tom said that the SQL could incur a lot of hard-parses and kill performance, but how deathly is the constant compilation of anonymous PL/SQL blocks as shown above in comparison?
    2) Would there be any benefit to pulling the execute routines out of the PL/SQL block and issuing a query such as the following:
    select * from expression_tbl et where <key matches> AND pkg.eval_routine(et.expression) = 'Y' AND rownum <= 1.
    I realize that the evaulating routine would then need to either perform an execute immediate on et.expression (if we keep the current method in place) or formulate the dynamic SQL statement and execute it. But, could this be faster than doing the same loop through rows explicitely in PL/SQL?
    Doing this would trim my PL/SQL down to:
    - set up sys_context
    - execute the above select statmenet
    - if a row is returned then return true otherwise return false
    Seems more elegant, but the peformance is all that matters.
    3) Is there any built-in routine that I may be able to replace pkg.eval_routine from 2 with that would evaulate boolean expressions for me? Or any other way to inline the idea from 1 with 2? I can't think of one given the dynamic nature of the beast, but...maybe there's something I missed.
    Thanks everyone! Hopefully I've expressed myself clearly.

    Brian - According to Tom Kyte Doing PL/SQL inside Execute Immediate should be faster as you are already within the context of a PL/SQL engine. If we choose to do it in SQL then the PL/SQL engine has to hand it over to the SQL Engine for executing the dynamic Select statements and so might be a little slower. But I am not sure if the difference can be quantifiable unless u do your own test of both evaluators and run them for like a few thousand times in a loop.
    If you are using 10g R2 - you might want to look into DBMS_RLMGR package which is the API for the Oracle's version of the embedded business rule manager.
    I looked into it but it didn't fit our needs as its deficient with respect to rule versioning and effective and until date based business rule enforcement/ validation.
    After taking a shot at designing something home grown I feel its not that difficult to construct one that fit our needs inclusive of the features( rule versioning, effective and until dates) that I listed above as deficiencies in the Oracle embedded rule engine.
    If you don't have those requirements may be using the Business Rule manager API of 10g R2 might not be a bad anticipating it will be improved in future versions.
    Regards
    -Suren

  • Complex Boolean Expressions in FrameMaker

    I have a complex document set with multiple conditions to support brand and output, and now I want to add roles.
    Prior to the roles, I had it set up with the following conditions:
    BrandA
    BrandB
    Help
    PDF
    BrandA Help
    BrandA PDF
    BrandB Help
    BrandB PDF
    etc.
    When I build my documents, I would just use the Show/Hide functionality and come up with something like:
    Show: Brand A, PDF, BrandA PDF
    This worked OK, but has been getting more complex as I have now added two more brands.
    Now the business wants to add Roles... for example "Read Only" and "Update"
    I know I can set up additional conditions for the roles, and then append those roles to each of the above conditions as well, but this number of conditions is really starting to get unmanageable.
    I was wondering if I could cut down the number of conditions and use complex Boolean Expressions to represent what I need.
    So I'd have something like:
    (("BrandA" and "PDF") or "BrandA" or "PDF")
    This would give me the same result as my previous
    "BrandA PDF" or "BrandA" or "PDF"
    But allows me to significantly decrease the number of conditions that I need to achieve it. It just means that I have to add multiple tags to some text.
    It would then allow me to just add just two conditions for my roles, and I can build the expressions as needed:
    (("BrandA" and "PDF" and "Read Only") or "Read Only" or "BrandA" or "PDF" or ("BrandA" and "PDF") or ("BrandA" and "Read Only") or ("PDF" and "Read Only"))
    I know the expression is a monstrosity, but it keeps the number of conditions down.
    Is this possible? (I can't get it to work.)
    If not, do you have any other ideas for managing Brand, Output, and Role effectively?
    Thanks for any advice!

    Hi Amy,
    It's no simple matter, so I don't mean to casually suggest that you'll be able to do it in an afternoon. It is a long term process to understand the structured mindset and build the architecture to support it. I couldn't possible estimate an effort from here because there are so many variables involved. Typically, though, you are looking at months to pull off any kind of substantial transition.
    That said, a structured document set is the only way you'll be able to realize your goals. Unstructured content, whether in FrameMaker, Word, or wherever, lacks the metadata to engage the computer for the type of automation that you want. For the computer to do work for you, you'll need to make your content look like data to the computer. This doesn't have to be structured Frame, as there are many avenues to this destination. It is a convenient option, though, for those already using FrameMaker and are satisfied with the authoring platform and publishing options.

  • CC 2014 trial. MPEG MOVIE clips flickering on my time line! after render, and after export. tried all kinds of sequence settings,taking out transitions and effects ,even the audio tracks.....still flickering. They play fine outa the project files!?  HELLL

    CC 2014 trial. MPEG MOVIE clips flickering on my time line! after render, and after export. tried all kinds of sequence settings,taking out transitions and effects ,even the audio tracks.....still flickering. They play fine outa the project files!?  HELLLLLPPPPP!!!!

    We can not see your computer, your settings or even know what your source files are because we are not in the same room as you are!
    We cant see what you are doing wrong ...so you will have to tell us a lot more and show us some screen grabs of your settings.

  • Pinterest was taking up 13 GB on my phone. I deleted it, it ran out of battery and when i plugged it back in- i cant get it to start off of the apple logo screen. Help!!

    My phone had been telling me i did not have enough storage- and i finally found out that pintrest was taking up 13 GB! When i found out, i deleted it. Soon my phone ran out of battery, and it was a while before i could plug it back in. Once i could plug it in it stayed on the Apple logo- and will not start. I can hold the power and start button and it will go black, but thats it. I have plugged it in but itunes wants me to restore it- we just got back from vacation and all our photos are on my phone!! I dont want to lose them!! GRRR PLEASE HELP!!!

    Here's how to perform the restore:
    HT1414
    If you can actually get to restore, maybe (I estimate a 0.01% chance) you'll be able to do a backup before the restore.  Actually, from the symptoms you describe, I suspect a restore won't work either and you'll need to do a recovery.
    Just in case, if you need to recover (restore fails), here's how.  Note you may have to try to get into recovery mode more than once.
    http://support.apple.com/kb/HT1808

  • Can I make a form that could be emailed filled out and returned

    I'd like to create a form that I can email my students and that they could fill out and return.
    Is there a site or video that could help me learn this?
    Perhaps create a template?

    Not in Pages, except to create the basic form itself.
    The best method is create a pdf form, using Acrobat Pro to fill in the data fields of the form.
    The students can use the free Acrobat Reader to fill in the fields, which you can have sent electronically back to you or whatever database you want, or as a simple dumb form that accepts their typing.
    To have a quiz style multiple choice document, that even corrects and sums up results use iBooks [free], very similar to Pages, or a dedicated application for this style of work.
    Peter

  • I have a trial version of Photoshop and Lightroom installed with a view of taking out a subscription. Some of the features in this trial version do not work is this just because it is a trial version.

    I have a trial version of Photoshop and Lightroom installed with a view of taking out a subscription. Some of the features in this trial version do not work is this just because it is a trial version.

    BOILERPLATE TEXT:
    Note that this is boilerplate text.
    If you give complete and detailed information about your setup and the issue at hand,
    such as your platform (Mac or Win),
    exact versions of your OS, of Photoshop (not just "CS6", but something like CS6v.13.0.6) and of Bridge,
    your settings in Photoshop > Preference > Performance
    the type of file you were working on,
    machine specs, such as total installed RAM, scratch file HDs, total available HD space, video card specs, including total VRAM installed,
    what troubleshooting steps you have taken so far,
    what error message(s) you receive,
    if having issues opening raw files also the exact camera make and model that generated them,
    if you're having printing issues, indicate the exact make and model of your printer, paper size, image dimensions in pixels (so many pixels wide by so many pixels high). if going through a RIP, specify that too.
    etc.,
    someone may be able to help you (not necessarily this poster).
    a screen shot of your settings or of the image could be very helpful too.
    Please read this FAQ for advice on how to ask your questions correctly for quicker and better answers:
    http://forums.adobe.com/thread/419981?tstart=0
    Thanks!

  • When I open an app, it exits out of the app and returns to the home screen.

    When I open up apps, it exits out and returns to the home screen.

    That's not true. In most cases this is a memory issue and in some cases simply a bug. Most often it can be corrected by either resetting the iPad or closing all other apps and restarting the app in question.
    You can try resetting your iPad by simultaneously pressing and holding the Home and Sleep/Wake buttons until you see the Apple Logo. This can take up to 15 seconds so be patient and don't release the buttons until the logo appears.

  • I am planning on buying an iPad 4 16GB, So I wanted to ask that after taking out the storage consumed by the system and system apps, How much storage will I be left with?

    I am planning on buying an iPad 4 16GB, So I wanted to ask that after taking out the storage consumed by the system and system apps, How much storage will I be left with?

    16GB vs 32GB vs 64GB: Which new iPad storage capacity should you get?
    http://www.imore.com/2012/03/08/16gb-32gb-64gb-ipad-capacity/
    How much content will fit on my iPod or iPhone?
    http://support.apple.com/kb/HT1867
     Cheers, Tom

Maybe you are looking for