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?
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.
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.
-
-
if input is not a number, return 0, or convert as much as possible, e.g., 146L = 146, but start witn non number will fail at start.
-
if input is not a number, return 0, or convert as much as possible, e.g., 146L = 146, but start witn non number will fail at start.
Ah so because the text is before the number it wont work?
Can you think of a workaround other than having the text in the end? -
Val(right$(string,3)) This will work
UPD i was sleepy. Didn't understand they are different in sizes. Sorry
-
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
-
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
I would, but it aint always there only in this particular string
-
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 would, but it aint always there only in this particular string
Damn. If you are building Windows only, you could use Regular Expressions Object (regex) to extract number from that string.
-
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) -
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.
-
Alternatively, there's this monstrosity with String Parser:
-
Ty all for the solutions I went with Ikko's (kinda did it before reading it) fastloop and extract until it hit the number. And then grab the rest of the string as val()
Its so nice how fast you can get help inhere
Again ty
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!