Results 1 to 4 of 4

Thread: Case OF

  1. #1
    Join Date
    Feb 2006
    Location
    Aussie
    Posts
    937
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default Case OF

    ok, so in my absence i have completely forgotten cases.. i cannot dl tutorial.exe as teh site is down.. anyone wanna go through it with me please?

  2. #2
    Join Date
    Feb 2006
    Location
    Amsterdam
    Posts
    13,692
    Mentioned
    146 Post(s)
    Quoted
    130 Post(s)

    Default

    SCAR Code:
    Case Boolean Of

    True : Begin Wait(1) End;
    False : Begin Wait(1) End;

    End; // end the case

    SCAR Code:
    Case Integer Of :

    0: Begin Wait(1) End;
    1: Begin Wait(1) End;
    2: Begin Wait(1) End; // etc

    End;

    SCAR Code:
    Case String Of

    'hi' : Begin Wait(1) End;
    'lol' : Begin Wait(1) End;

    End;

    Boolean can be any boolean, same for integer and string



    The best way to contact me is by email, which you can find on my website: http://wizzup.org
    I also get email notifications of private messages, though.

    Simba (on Twitter | Group on Villavu | Website | Stable/Unstable releases
    Documentation | Source | Simba Bug Tracker on Github and Villavu )


    My (Blog | Website)

  3. #3
    Join Date
    Aug 2006
    Location
    London
    Posts
    2,021
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    theres also this lesser known method. normally case statments only suppost a value being the same as the variable, in other words, using the =. but with this you can use < and >

    Code:
    program New;
    const check=2;
    
    begin
      case true of
        check=5:writeln('check is equil to 5')
        check>5:writeln('check is bigger then 5')
        check<5:writeln('check is smaller than 5')
      end
    end.
    Join the Official SRL IRC channel. Learn how to Here.

  4. #4
    Join Date
    Feb 2006
    Location
    Australia, NSW.
    Posts
    1,461
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    or instead of doing:
    Code:
    case s of
      'we': i:= 1;
      're': i = 1;
    end;
    (As you can see they result in the same values.)
    You can use commers to make it alot nicer.

    Code:
    case s of
      'we', 're': i:= 1;
    end;

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Case help
    By Aser in forum OSR Help
    Replies: 3
    Last Post: 11-22-2008, 05:21 AM
  2. Case..Of Help
    By Drew_Dawg in forum OSR Help
    Replies: 7
    Last Post: 02-02-2008, 11:47 PM
  3. Using Case and Of
    By Fourscape in forum Outdated Tutorials
    Replies: 3
    Last Post: 08-18-2007, 08:40 PM
  4. Case - Else
    By stylen in forum OSR Help
    Replies: 0
    Last Post: 05-30-2007, 11:54 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
  •