Results 1 to 12 of 12

Thread: StringToInt?

  1. #1
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default StringToInt?

    How do i convert a string to an integer? I'm using tboxes in forms for integers. That's why.

  2. #2
    Join Date
    Feb 2007
    Location
    Alberta,Canada
    Posts
    2,358
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    StrtoInt()

  3. #3
    Join Date
    May 2007
    Location
    knoxville
    Posts
    2,873
    Mentioned
    7 Post(s)
    Quoted
    70 Post(s)

    Default

    i could have swore there was a strtoint() in SCAR. =o
    <TViYH> i had a dream about you again awkwardsaw
    Malachi 2:3

  4. #4
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Any idea how i use it?
    I did,

    SCAR Code:
    StrToInt(Problemo2);
      StrToInt(Problemo1);
    But it still says type mismatch.

    EDIT: Nevermind I'm stupid

  5. #5
    Join Date
    Apr 2007
    Location
    UK
    Posts
    2,295
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program New;
    var
    st1:string;
    begin
    st1 := '5';
    writeln(StrToInt(St1));
    end.

    Works here,.

    Rogeruk's Al-Kharid Tanner V1.1 [Released]
    Rogeruk's Barbarian Crafter [Coming Soon]
    Rogeruk's Guild Fisher [Coming Soon]
    !! - Taking Requests - !!

  6. #6
    Join Date
    Jan 2007
    Posts
    834
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Thanks people!
    Last edited by Mr. Doctor; 11-19-2009 at 11:33 PM.

  7. #7
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I recommend using radio buttons for that kind of selection over combo boxes. You won't have to deal with strings, or people typing in the combo box (although you could prevent that).
    If you use radio buttons just use something like this when the equals button is pressed:
    Code:
    if MultiplyRadioBtn.Checked then
      YourMultiplyFunc(InputBox1, InputBox2)
    else if DivideRadioBtn.Checked then
      YourDivideFunc(InputBox1, InputBox2)

  8. #8
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default

    Use Round(FloatToStr())
    I think ~.^

  9. #9
    Join Date
    Oct 2006
    Posts
    500
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    That would try to round a string. Should be
    FloatToStr(Round(i))

  10. #10
    Join Date
    Jan 2008
    Location
    NC, USA.
    Posts
    4,429
    Mentioned
    0 Post(s)
    Quoted
    4 Post(s)

    Default .

    Quote Originally Posted by r!ch!e View Post
    That would try to round a string. Should be
    FloatToStr(Round(i))
    He wants an int. THat would give a type mismatch (in java anyways, havent worked with SCAR lately)

    Do

    try
    s = IntToStr(x);
    except
    writeln('dsfdff');
    finally
    writeln('slol');
    end;

    Edit: Idk why I'm doing this. My posts get dumber every time :<

  11. #11
    Join Date
    Jan 2008
    Location
    Ontario, Canada
    Posts
    7,805
    Mentioned
    5 Post(s)
    Quoted
    3 Post(s)

    Default

    StrToIntEx(number: String; Default: Integer): Integer;

    That will catch if you try todo the conversion and it can't, following so, will set it to default.
    Writing an SRL Member Application | [Updated] Pascal Scripting Statements
    My GitHub

    Progress Report:
    13:46 <@BenLand100> <SourceCode> @BenLand100: what you have just said shows you 
                        have serious physchological problems
    13:46 <@BenLand100> HE GETS IT!
    13:46 <@BenLand100> HE FINALLY GETS IT!!!!1

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

    Default

    Quote Originally Posted by Nava2 View Post
    StrToIntEx(number: String; Default: Integer): Integer;

    That will catch if you try todo the conversion and it can't, following so, will set it to default.
    Line 7: [Error] (20638:1): Unknown identifier 'StrToIntEx' in script

    You mean StrToIntDef? StrToBoolDef, StrToFloatDef

Thread Information

Users Browsing this Thread

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

Posting Permissions

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