Results 1 to 3 of 3

Thread: String Question

  1. #1
    Join Date
    Dec 2007
    Location
    Wizzup?'s boat
    Posts
    1,013
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default String Question

    Hello Forumers,

    My question for you today is;

    How can I change my existing string 'Health: 90/100' into '90'?

    I've had an idea that you could take everything before the '/', then change the string to a number (thus removing 'health: '), but I'm not sure what the first half of the command is.

    Rep awarded as always.

    Thanks in advance,
    Project: Welcome To Rainbow

  2. #2
    Join Date
    Jun 2007
    Location
    Wednesday
    Posts
    2,446
    Mentioned
    3 Post(s)
    Quoted
    1 Post(s)

    Default

    hp := StrToIntDef(Between(':', '/', 'Health: 90/100'), 0);

    StrToIntDef is just like StrToInt, except it takes in an Integer as well, which it will return if it can't produce a valid integer from the conversion, ie StrToIntDef('moo', 10) will return 10 as moo can't be an integer. It primarily just stops it crashing.
    Between takes 3 strings: 1st string is where you want to start copying from and the 2nd string is where you want to end copying. The 3rd string is the string where it is to find the stuff to copy.
    I hope that works, though I must say that you should post scripting questions in the "Scripting Help" section in future rather than here, as this is meant for posting non-RS related scripts, rather than for help
    By reading this signature you agree that mixster is superior to you in each and every way except the bad ways but including the really bad ways.

  3. #3
    Join Date
    Feb 2006
    Location
    Belgium
    Posts
    3,137
    Mentioned
    3 Post(s)
    Quoted
    5 Post(s)

    Default

    Don't double post and post in the wrong section. Locked.

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
  2. Replies: 2
    Last Post: 05-28-2007, 05:00 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
  •