youtuber Posted July 5, 2016 Share Posted July 5, 2016 How do I find a number of variables random $test0 = "yılınız: 0" $test1 = "yılınız: 1" $testrand = Random($test0,$test1) $year = StringRegExp($testrand, '(?i)z:\s(\d+)(.*?)', 3) if not $year=1 then Msgbox(0, "Target", "test 0: " & $year) Else Msgbox(0, "Target", "test 1: " & $year) EndIf Link to comment Share on other sites More sharing options...
Synapsee Posted July 5, 2016 Share Posted July 5, 2016 hi i have find multiple problem : - your usage of random seems bad. - StringRegExp return a array, so u need use $aYear[0] #include <Array.au3>; for _ArrayDisplay $sStart = "yılınız: " $iRandom = Random(1950, 2050, 1); return 1950-2050 integer $sString = $sStart & $iRandom ; Return "(.*?)" in a array $aYear = StringRegExp($sString, '(?i)z:\s(\d+)(.*?)', $STR_REGEXPARRAYGLOBALMATCH) If @error then Msgbox(0, "$iRandom=" & $iRandom, "Year not found") Else Msgbox(0, "$iRandom=" & $iRandom, "Year found : " & $aYear[0]) EndIf ;_ArrayDisplay($aYear); for help to understand youtuber 1 Link to comment Share on other sites More sharing options...
iamtheky Posted July 5, 2016 Share Posted July 5, 2016 $test0 = "yılınız: 0" $test1 = "yılınız: 1" $testrand = Random(0, 1 , 1) $testrand = eval("test" & $testrand) msgbox(0, "Target" , $testrand) youtuber 1 ,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-. |(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/ (_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_) | | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) ( | | | | |)| | \ / | | | | | |)| | `--. | |) \ | | `-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_| '-' '-' (__) (__) (_) (__) Link to comment Share on other sites More sharing options...
jguinch Posted July 5, 2016 Share Posted July 5, 2016 Use an array : Local $aTest = ["yılınız: 0", "yılınız: 1"] $testrand = $aTest[ Random(0, UBound($aTest) - 1 , 1) ] $year = StringRegExp($testrand, '\d+$', 1) If @error Then Exit MsgBox(16, "", "invalid string") MsgBox(0, "", $year[0]) youtuber 1 Spoiler Network configuration UDF, _DirGetSizeByExtension, _UninstallList Firefox ConfigurationArray multi-dimensions, Printer Management UDF Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now