Results 1 to 5 of 5

Thread: Case Statement Failsafe

  1. #1
    Join Date
    Nov 2006
    Location
    Location, Location
    Posts
    1,126
    Mentioned
    6 Post(s)
    Quoted
    41 Post(s)

    Default Case Statement Failsafe

    Im trying to add a failsafe to my case statements, and 'otherwise' doesnt work, neither does 'else'

    my code:
    SCAR Code:
    case Lowercase(RuneToCraft) of
      'air':
      begin
        ExpPerEss := 5;
        if (RCLevel = 99) then
          RunesPerEss := 10
        else if (RCLevel >= 88) then
          RunesPerEss := 9
        else if (RCLevel >= 77) then
          RunesPerEss := 8
        else if (RCLevel >= 66) then
          RunesPerEss := 7
        else if (RCLevel >= 55) then
          RunesPerEss := 6
        else if (RCLevel >= 44) then
          RunesPerEss := 5
        else if (RCLevel >= 33) then
          RunesPerEss := 4
        else if (RCLevel >= 22) then
          RunesPerEss := 3
        else if (RCLevel >= 11) then
          RunesPerEss := 2
        else if (RCLevel < 11) then
          RunesPerEss := 1;
      end;
      'earth':
      begin
        ExpPerEss := 6.5;
        if (RCLevel >= 78) then
          RunesPerEss := 4
        else if (RCLevel >= 52) then
          RunesPerEss := 3
        else if (RCLevel >= 26) then
          RunesPerEss := 2
        else if (RCLevel < 26) then
          RunesPerEss := 1;
      end;
      else begin
        WriteLn('You didnt enter a correct rune.');
        Players[CurrentPlayer].Loc := 'No Rune';
        LogOut;
        NextPlayer(False);
      end;
      end;

  2. #2
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    um, the "default" case will be called if none of the others ones are. assuming that it exisits
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  3. #3
    Join Date
    Nov 2006
    Location
    Location, Location
    Posts
    1,126
    Mentioned
    6 Post(s)
    Quoted
    41 Post(s)

    Default

    well supposedly the default case is either 'else' or 'otherwise', atleast thats what they showed on some Pascal reference guides :P

  4. #4
    Join Date
    Apr 2007
    Location
    Texas
    Posts
    1,668
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    oh crap!
    this isnt java anymore...

    yeah, my souces tell me that you should use "otherwise" keyword.

    :/ so thats not an option.

    you could always do this.

    in each of your case areas, add
    SCAR Code:
    found:=true;

    and then after the case you could do
    SCAR Code:
    if(NOT found)
    begin...

    i sure hope that is the right language :/
    [IMG]http://farm3.static.flickr.com/2120/2052732965_348f3629d0_o.jpg[/IMG]

  5. #5
    Join Date
    Nov 2006
    Location
    Location, Location
    Posts
    1,126
    Mentioned
    6 Post(s)
    Quoted
    41 Post(s)

    Default

    well i was hoping not to use an if statement :P but if its the only choice then I will, thank you

    **EDIT**
    OMG I MAY HAVE BEEN A MORON >.> I may have been doing something in the wrong order i'll edit again if im stupid :P

    ***EDIT***
    Well I am officially stupid turns out I was calling one of my statements before RuneToCraft got a value lol. So, the 'default' for 'case' is 'else'

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What is wrong here? (if- statement)
    By marpis in forum C/C++ Help and Tutorials
    Replies: 3
    Last Post: 12-06-2008, 01:26 AM
  2. help with if-then else statement
    By OwnedPl0x?!?! in forum OSR Help
    Replies: 3
    Last Post: 11-17-2007, 12:42 PM
  3. heey case statement
    By ShowerThoughts in forum OSR Help
    Replies: 3
    Last Post: 09-09-2007, 05:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •