Does the "case" statement support a DEFAULT value?

Discussion in 'C-Touch/HomeGate/SchedulePlus/PICED Software' started by greig, May 1, 2010.

  1. greig

    greig

    Joined:
    Aug 3, 2004
    Messages:
    72
    Likes Received:
    3
    Location:
    Petersham - Sydney
    Hi All,


    I've had some code misbehaving for a while and now I've bothered to debug it the problem is quite obvious.

    At the top of every hour (once minute = 0) I'm doing a "case hour of" test to pluck out certain hours of the day, but it seems that if the hour = a time I'm not interested in, it crashes and I end up with runaway code!

    My log file reports "Error : Logic Run-time Error R107 at line 235:0 - Value out of range" when it gets to the end at the bottom of my "CASE" block.

    Logic.pdf reports that "If none of the CaseLists has the same value as SelectorExpression, then a Run Time Error will occur." which would suggest everything's working as expected.

    In other programming languages I have the luxury of a "default" command that will match on any 'SelectorExpression' that's not listed above and my code won't crash.

    Any chance there's a non-documented one for the PICED? (I've tried the command "default" but alas, "That identifier is not declared").

    I don't want to write 20 more lines of code to pluck out the remaining 20 hours of the day, but of course I will if there's no other solution.

    Tks.


    G.
     
    greig, May 1, 2010
    #1
  2. greig

    NickD Moderator

    Joined:
    Nov 1, 2004
    Messages:
    1,420
    Likes Received:
    62
    Location:
    Adelaide
    Unfortunately, the logic engine doesn't support a default case...

    darren probably told me once upon a time why this was the case.... I can only guess it must have been really really really really really really really difficult.

    Or he just forgot.

    If you don't have too many cases, the workaround is to use

    if (case1)..
    else if (case2)..
    else if (case3)..
    (etc)
    else (default)

    Nick
     
    NickD, May 1, 2010
    #2
  3. greig

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    It has been on the list of things to do for a long time. Hopefully I will find time to get it done soon :)
     
    Darren, May 3, 2010
    #3
  4. greig

    greig

    Joined:
    Aug 3, 2004
    Messages:
    72
    Likes Received:
    3
    Location:
    Petersham - Sydney
    No sweat Darren. In my case I've resolved the issue with a VERY long line that says "0, 1, 2, 3, 4, 10, 11 <etc> 23: begin", but it WOULD be handy to have a "default" command (or at least for it to not crash if it encounters a value not handled).

    But at least I know for next time.

    On the subject of PASCAL and the wonderful things I can do with my PACA, is there any hope for an upgrade to the text editor someday that might add support for the usual control/shift + arrow key combinations for navigating around the code??


    G.
     
    greig, May 3, 2010
    #4
  5. greig

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Some of these are supported. See the logic help file topic "keyboard shortcuts"
     
    Darren, May 4, 2010
    #5
  6. greig

    greig

    Joined:
    Aug 3, 2004
    Messages:
    72
    Likes Received:
    3
    Location:
    Petersham - Sydney
    Thanks Darren.


    I see those, but in my dreams I use the control-arrows to navigate...

    When I raised this back in '06 you said it was because the editor(?) came from a third party.

    I was hoping that there might have been a review or update of the editor in the ensuing period that would bring the overlooked shortcuts.

    I just thought I'd ask.


    G.
     
    greig, May 4, 2010
    #6
  7. greig

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    That is true (I didn't just make it up as an excuse).

    We actually have replaced the editor, but there are still some limitations. Which particular shortcuts do you require?
     
    Darren, May 5, 2010
    #7
  8. greig

    greig

    Joined:
    Aug 3, 2004
    Messages:
    72
    Likes Received:
    3
    Location:
    Petersham - Sydney
    Hi Darren,


    Oh I never doubted you - it made commercial sense to just buy a text editor (but also meant it was fixed/unchangeable). :-(

    Control left/right arrow to move a word left/right is probably THE addition I crave.

    ...and I suppose just for balance, ^Home to go to the top of the page (because ^End already takes you to the bottom).

    The rest seem to be there now:
    • Shift+arrow to select a character
    • ^Shift+arrow to select a word
    • ^Backspace to delete a word to the Left.

    Does your question imply that CIS has the ability to add these shortcuts?? Shall I have Haighs send some dark chocolate frogs around??


    G.
     
    greig, May 5, 2010
    #8
  9. greig

    Darren Senior Member

    Joined:
    Jul 29, 2004
    Messages:
    2,361
    Likes Received:
    0
    Location:
    Adelaide, South Australia
    Yes. The new editor has customisation available, although we had a few problems last time we tried.

    I definitely approve of your choice of bribe, I mean incentive :)
     
    Darren, May 5, 2010
    #9
  10. greig

    ashleigh Moderator

    Joined:
    Aug 4, 2004
    Messages:
    2,391
    Likes Received:
    24
    Location:
    Adelaide, South Australia
    Sadly, Darren has no scruples at all.

    Send him some Cadbury White Chocolate (also known as Yak Fat, because its not actually chocolate at all). He'd like that much more.

    Send ME the dark chocolate :)
     
    ashleigh, May 6, 2010
    #10
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.