Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Other Discussions
  3. The Weird and The Wonderful
  4. if .... else case

if .... else case

Scheduled Pinned Locked Moved The Weird and The Wonderful
comhelp
11 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Colin Mullikin

    if (FileType = 0) then
    FileSaveAs(Sender)
    else begin
    case FileType of
    1:SaveCDL(FileName,List);
    2:SaveDXF(FileName,List);
    3:SaveFile(FileName,List);
    end; {case FileType}
    end; {if (FileType = 0) else ...}

    I came across this in some code (written by someone else) that I am looking through to find the cause of a save/load error. :sigh:

    The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

    B Offline
    B Offline
    BobJanova
    wrote on last edited by
    #2

    Nice one!

    1 Reply Last reply
    0
    • C Colin Mullikin

      if (FileType = 0) then
      FileSaveAs(Sender)
      else begin
      case FileType of
      1:SaveCDL(FileName,List);
      2:SaveDXF(FileName,List);
      3:SaveFile(FileName,List);
      end; {case FileType}
      end; {if (FileType = 0) else ...}

      I came across this in some code (written by someone else) that I am looking through to find the cause of a save/load error. :sigh:

      The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

      L Offline
      L Offline
      Lutoslaw
      wrote on last edited by
      #3

      Is it about

      FileType=0

      being an assignment instead of comparison?

      Greetings - Jacek

      T 1 Reply Last reply
      0
      • L Lutoslaw

        Is it about

        FileType=0

        being an assignment instead of comparison?

        Greetings - Jacek

        T Offline
        T Offline
        TorstenFrings
        wrote on last edited by
        #4

        no, this is the VB way of comparison

        L 1 Reply Last reply
        0
        • T TorstenFrings

          no, this is the VB way of comparison

          L Offline
          L Offline
          Lutoslaw
          wrote on last edited by
          #5

          It seems to be Pascal, not VB. But, in Pascal = is also a comparison, AFAIR. Frankly, I don't see where the horror is.

          Greetings - Jacek

          T C 2 Replies Last reply
          0
          • L Lutoslaw

            It seems to be Pascal, not VB. But, in Pascal = is also a comparison, AFAIR. Frankly, I don't see where the horror is.

            Greetings - Jacek

            T Offline
            T Offline
            TorstenFrings
            wrote on last edited by
            #6

            omg yes it's PASCAL ... guess the horror is the fact, that there is no need for the outer IF, because it could be handled inside the CASE as well

            C 1 Reply Last reply
            0
            • T TorstenFrings

              omg yes it's PASCAL ... guess the horror is the fact, that there is no need for the outer IF, because it could be handled inside the CASE as well

              C Offline
              C Offline
              Colin Mullikin
              wrote on last edited by
              #7

              TorstenFrings wrote:

              no need for the outer IF, because it could be handled inside the CASE

              Yeah, that's it. Having the if instead of just case 0 seems a bit like someone wasn't actually thinking about what they were coding.

              The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

              1 Reply Last reply
              0
              • L Lutoslaw

                It seems to be Pascal, not VB. But, in Pascal = is also a comparison, AFAIR. Frankly, I don't see where the horror is.

                Greetings - Jacek

                C Offline
                C Offline
                Colin Mullikin
                wrote on last edited by
                #8

                Jacek Gajek wrote:

                It seems to be Pascal, not VB.

                It's Delphi. So, you were almost right.:thumbsup:

                The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

                V 1 Reply Last reply
                0
                • C Colin Mullikin

                  if (FileType = 0) then
                  FileSaveAs(Sender)
                  else begin
                  case FileType of
                  1:SaveCDL(FileName,List);
                  2:SaveDXF(FileName,List);
                  3:SaveFile(FileName,List);
                  end; {case FileType}
                  end; {if (FileType = 0) else ...}

                  I came across this in some code (written by someone else) that I am looking through to find the cause of a save/load error. :sigh:

                  The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

                  V Offline
                  V Offline
                  Vladimir Svyatski
                  wrote on last edited by
                  #9

                  Oh, shit, Pascal :) Haven't seen it for several years. Is Delphi still alive? Anyway wouldn't it be easier to write something like

                  case FileType of
                  0:FileSaveAs(Sender);
                  1:SaveCDL(FileName,List);
                  2:SaveDXF(FileName,List);
                  3:SaveFile(FileName,List);
                  end;

                  Or religion doesn't allow? Sorry for possible syntax mistakes. But like I said: I haven't seen it for several years.

                  C 1 Reply Last reply
                  0
                  • C Colin Mullikin

                    Jacek Gajek wrote:

                    It seems to be Pascal, not VB.

                    It's Delphi. So, you were almost right.:thumbsup:

                    The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

                    V Offline
                    V Offline
                    Vladimir Svyatski
                    wrote on last edited by
                    #10

                    Colin Mullikin wrote:

                    It's Delphi. So, you were almost right.

                    He was absolutely right. Delphi is not a programming language, it's IDE just like Visual Studio. Object Pascal is used as a programming language inside. I know what I'm talking about. I had the pleasure of working with Delphi/C++ Builder. It was more than 5 years ago though. I still remember C++ Builder 6. But Borland is dead now:( .

                    1 Reply Last reply
                    0
                    • V Vladimir Svyatski

                      Oh, shit, Pascal :) Haven't seen it for several years. Is Delphi still alive? Anyway wouldn't it be easier to write something like

                      case FileType of
                      0:FileSaveAs(Sender);
                      1:SaveCDL(FileName,List);
                      2:SaveDXF(FileName,List);
                      3:SaveFile(FileName,List);
                      end;

                      Or religion doesn't allow? Sorry for possible syntax mistakes. But like I said: I haven't seen it for several years.

                      C Offline
                      C Offline
                      Colin Mullikin
                      wrote on last edited by
                      #11

                      Yep, you hit the nail on the head with that one. I have no clue why the original programmer didn't do that in the first place. I changed it to that, since it looks much cleaner.

                      The United States invariably does the right thing, after having exhausted every other alternative. -Winston Churchill America is the only country that went from barbarism to decadence without civilization in between. -Oscar Wilde Wow, even the French showed a little more spine than that before they got their sh*t pushed in.[^] -Colin Mullikin

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups