Problem extracting value from a string

Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.

A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.

Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!

Clickteam.
  • Right im having trouble using val to extract a value from a string.

    Val(GetSelection$( "Parser_MAIN" ))

    The selection in Parser_Main is currently "Aftermath_00244"
    But returns a 0 value? i just want it to get 244.
    The strings pretxt and subnumber are both variable sizes so i cant use left$/right$ extraction.

    Im stumped as i know i have used this functions alot of times before.
    Dont it allow to feed text, and then it just skips text and just grabs the numbers?

  • If string pretext and number are variable in sizes, but you have the underscore always between, why don't you use extension (String Tokenizer, for example) to split that string to text & number, using the underscore (_) as splitter

  • Use String Tokenizer object and retrive element 1 as suggested above, or use the String Parser, set one of your delimiters to the underscore and extract element 2 (string parser is 1-based)

    EDIT: didn't see you said the underscore was unique to that string. Is there always a separating character between the text and numbers? If there is, the string parser does allow to use more than 1 delimiter

  • I woke up. Here is your solution

    * Start of Frame
    Special : Start loop "loop" Len(string$( "String" )) times

    * On loop "loop"

    + Val(Mid$(string$( "String" ), loop_n( "String" ), 1)) > 0
    + Val(Mid$(string$( "String" ), loop_n( "String" ), 1)) <= 9
    OR
    + Mid$(string$( "String" ), loop_n( "String" ), 1) = "0"
    String : Set temp_num to temp_num( "String" ) + Mid$(string$( "String" ), loop_n( "String" ), 1)

    + Always
    String : Add 1 to loop_n

    + LoopIndex("loop") = Len(string$( "String" )) - 1
    String 2 : Set alterable string to Str$(Val(temp_num( "String" )) / 1)

  • Some context. So, i parse each symbol from left to right using "loop". If current symbol is 1-9 (value) or "0" (string) I add it into alterable string value "temp_num". So, now I got only numbers in "temp_num". Like 00244. To get 244 just divide 00244 by 1

    "0" should be checked as string not as value, because any letter as value is equal to 0.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!