Jump to content

Stringsplit replacing between 2 strings


yehia
 Share

Recommended Posts

this func should return the ss2 replacing the $dah string with strings from $ss2

i did set the dah to 0 then it should return ")" dont know whats the mistake i did but it stops and never gives the msg box

can anyone help me to make this work thanks

Call("AA")
Func AA()
    $dah = 0
    $ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
    "|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
    Dim $c=0
    
    For $dah in $ss
        $c+=1
            
    Return $ss2[$c-1]
    MsgBox(0,"",$ss2)
    Next
    
EndFunc
Link to comment
Share on other sites

this func should return the ss2 replacing the $dah string with strings from $ss2

i did set the dah to 0 then it should return ")" dont know whats the mistake i did but it stops and never gives the msg box

can anyone help me to make this work thanks

Call("AA")
Func AA()
    $dah = 0
    $ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
    "|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
    Dim $c=0
    
    For $dah in $ss
        $c+=1
            
    Return $ss2[$c-1]
    MsgBox(0,"",$ss2)
    Next
    
EndFunc
It can't get to the MsgBox because you are exiting the function with Return the first time the loop runs.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

this func should return the ss2 replacing the $dah string with strings from $ss2

i did set the dah to 0 then it should return ")" dont know whats the mistake i did but it stops and never gives the msg box

can anyone help me to make this work thanks

Call("AA")
Func AA()
    $dah = 0
    $ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
    "|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
    Dim $c=0
    
    For $dah in $ss
        $c+=1
            
    Return $ss2[$c-1]
    MsgBox(0,"",$ss2)
    Next
    
EndFunc
AA()
Exit

Func AA()

    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
    
    For $i=1 To (UBound($ss2) - 1)
        MsgBox(0,"", $ss2[$i])
    Next
EndFunc

PS: A little confused with your code. Test this code.

Link to comment
Share on other sites

u got me wrong Josbe

i need to translate the nums to the marks so if $dah = 0 return should be ")"

if $dah = 1 then return "!"

but of course using stringsplit to if :mellow:

im testing can i get more suggestions for fixing the func?

Ok. With a little of math logic, you could fix it easily.
Link to comment
Share on other sites

thats where i got so far

$aaa = Call("AA")
MsgBox(0,"",$aaa)
Func AA()
    $dah = 1
    $ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
    "|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
   
    For $dah=1 To (UBound($ss) - 1)
        Return $ss2[$dah + 1]
    Next
EndFunc

but its still not linked returns from ss2 but not the correct entry sellected in $dah

Link to comment
Share on other sites

thats where i got so far

$aaa = Call("AA")
MsgBox(0,"",$aaa)
Func AA()
    $dah = 1
    $ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
    "|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
   
    For $dah=1 To (UBound($ss) - 1)
        Return $ss2[$dah + 1]
    Next
EndFunc

but its still not linked returns from ss2 but not the correct entry sellected in $dah

MsgBox(0,"",aa())
Func AA()
    $dah = 1
    $ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
    "|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|")
   
    For $dah=1 To (UBound($ss) - 1)
        Return $ss2[$dah]
    Next
EndFunc
Edited by Glyph

tolle indicium

Link to comment
Share on other sites

You are still not catching on.

Return $ss2[$dah] will exit the loop and "RETURN" you to the point in the script where the function was called. For example.

$Val = AA()

Now the first thing you have in that function is $dah = 1.

Then you are telling it to return $ss2[$dah +1] the value of which will be 2 (1+1) at which point it exits the function and sets $Val to "!"

Therefore $Val will always equal "!"

Test this and you will see what I mean

MsgBox(0, "TEST", AA())

If you want it to return a given value for 1 to 32 (0+1 = 1 to 31+1 = 32) then that function will have to be called with a parameter.

For $i = 0 To 31
   MsgBox(0, "TEST", AA($i), 3)
Next

Func AA($dah)
   ;$dah = 1
   ;$ss = StringSplit("0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15" & _
   ;"|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31","|")
   
    $ss2 = StringSplit(')|!|@|#|$|%|^|&|*|(|<|>|?|:|"|}|{|~|_|+|1|1|1|1|1|1|1|1|1|1|1|1', "|", 2)
   
   ;For $dah=1 To (UBound($ss) - 1)
        Return $ss2[$dah]
   ;Next
EndFunc

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...