Results 1 to 6 of 6

Thread: function StrToFloatDef(s: string; def: extended): string;

  1. #1
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default function StrToFloatDef(s: string; def: extended): string; + function StrToBoolDef(s:

    SCAR Code:
    function StrToFloatDef(s: string; def: extended): extended;
    begin
      try
        Result := StrToFloat(s);
      except
        Result := def;
      end;
    end;

    SCAR Code:
    function StrToBoolDef(s: string; def: boolean): boolean;
    begin
      try
        Result := StrToBool(s);
      except
        Result := def;
      end;
    end;

    Edit: Also anything that is a string conversion should have a default... there's a lot more in ArrayLoader.scar in SRL

  2. #2
    Join Date
    Jun 2006
    Location
    USA
    Posts
    1,828
    Mentioned
    1 Post(s)
    Quoted
    0 Post(s)

    Default

    Nice, but shouldn't it be:

    SCAR Code:
    try
        Result:=StrToBool(s);
      except
        Result := def;

    SCAR Code:
    try
        Result:=StrToFloat(s);
      except
        Result := def;
      end;

  3. #3
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yes, I changed it right after I posted. I guess you didn't refresh in time

  4. #4
    Join Date
    Jan 2007
    Location
    Kansas
    Posts
    3,760
    Mentioned
    1 Post(s)
    Quoted
    3 Post(s)

    Default

    Lol I thought I would never use a StrToBool but I did a few days ago.


  5. #5
    Join Date
    Dec 2006
    Location
    Houston, TX USA
    Posts
    4,791
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yea It's pretty useful when it comes to loading data files or saved settings.

  6. #6
    Join Date
    Dec 2006
    Location
    Copy pastin to my C#
    Posts
    3,788
    Mentioned
    8 Post(s)
    Quoted
    29 Post(s)

    Default

    YUp

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replies: 5
    Last Post: 03-30-2008, 01:40 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
  •