Jump to content
Sign in to follow this  
bairacdn2005

Array

Recommended Posts

Posted Image

I have always encounter this message when trying to test my tool with a long string(It does some string translation)

Here's my script ( the component I reckon where the error comes from)

;This function do the convert to Normal----------------------------------
Func ConverttoNormal ($Inputtext)

    $Inputtext = GUICtrlRead ($Input)
    $StringLen = StringLen ($Inputtext)

;Break the text into one single char
    $ArrayofChar = StringSplit ($Inputtext, "")

;Convert chars in the array made of splitted text
    $Outputtext = ""
    For $i = 1 to $StringLen
    Select
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "\" And $ArrayofChar[$i+2] = "["
            $ArrayofChar[$i] = "n"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+3
        Case $ArrayofChar[$i] = "/" And $ArrayofChar[$i+1] = "v" And $ArrayofChar[$i+2] = "\"
            $ArrayofChar[$i] = "m"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+3
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "<"
            $ArrayofChar[$i] = "k"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "_"
            $ArrayofChar[$i] = "l"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = ")"
            $ArrayofChar[$i] = "d"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "º"
            $ArrayofChar[$i] = "p"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "" And $ArrayofChar[$i+1] = "|"
            $ArrayofChar[$i] = "h"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "v" And $ArrayofChar[$i+1] = "V"
            $ArrayofChar[$i] = "w"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "C" And $ArrayofChar[$i+1] = "l"
            $ArrayofChar[$i] = "a"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "(" And $ArrayofChar[$i+1] = "¬"
            $ArrayofChar[$i] = "g"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "1" And $ArrayofChar[$i+1] = "2" And ($ArrayofChar[$i-1] = " " Or $ArrayofChar[$i-1] = "t")
            $ArrayofChar[$i] = "r"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "F" And $ArrayofChar[$i+1] = "_"
            $ArrayofChar[$i] = "e"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2

        Case $ArrayofChar[$i] = "3"
            $ArrayofChar[$i] = "b"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "("
            $ArrayofChar[$i] = "c"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "f"
            $ArrayofChar[$i] = "f"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "]"
            $ArrayofChar[$i] = "i"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "j"
            $ArrayofChar[$i] = "j"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "º"
            $ArrayofChar[$i] = "o"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "¶"
            $ArrayofChar[$i] = "q"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "§"
            $ArrayofChar[$i] = "s"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = ""
            $ArrayofChar[$i] = "t"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "µ"
            $ArrayofChar[$i] = "u"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "v"
            $ArrayofChar[$i] = "v"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "×"
            $ArrayofChar[$i] = "x"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "¥"
            $ArrayofChar[$i] = "y"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "z"
            $ArrayofChar[$i] = "z"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case Else
            $ArrayofChar[$i] = $ArrayofChar[$i]
            $Outputtext = $Outputtext & $ArrayofChar[$i]
    EndSelect
    Next
;This is to clean up the string (eliminate superfluous space)
    If StringInStr ($Outputtext, "  ") <> 0 then
    For $j = 1 to 2
    $Processing = $Outputtext
    $StringLen = StringLen ($Processing)
    $ArrayofChar = StringSplit ($Processing, "")
    $Outputtext = ""
    For $i =  1 to $StringLen
        If  $ArrayofChar[$i] = " " And  $ArrayofChar[$i+1] <> " " Then
            $i = $i+1
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Else
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        EndIf
    Next
    Next
    EndIf
    $ArrayofChar = 0

;This is to display the outcome
    _GUICtrlEdit_SetText ($Output, $Outputtext)
EndFunc

;This function do the convert to Normal----------------------------------
Func ConverttoNormal ($Inputtext)

    $Inputtext = GUICtrlRead ($Input)
    $StringLen = StringLen ($Inputtext)

;Break the text into one single char
    $ArrayofChar = StringSplit ($Inputtext, "")

;Convert chars in the array made of splitted text
    $Outputtext = ""
    For $i = 1 to $StringLen
    Select
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "\" And $ArrayofChar[$i+2] = "["
            $ArrayofChar[$i] = "n"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+3
        Case $ArrayofChar[$i] = "/" And $ArrayofChar[$i+1] = "v" And $ArrayofChar[$i+2] = "\"
            $ArrayofChar[$i] = "m"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+3
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "<"
            $ArrayofChar[$i] = "k"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "_"
            $ArrayofChar[$i] = "l"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = ")"
            $ArrayofChar[$i] = "d"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "]" And $ArrayofChar[$i+1] = "º"
            $ArrayofChar[$i] = "p"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "" And $ArrayofChar[$i+1] = "|"
            $ArrayofChar[$i] = "h"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "v" And $ArrayofChar[$i+1] = "V"
            $ArrayofChar[$i] = "w"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "C" And $ArrayofChar[$i+1] = "l"
            $ArrayofChar[$i] = "a"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "(" And $ArrayofChar[$i+1] = "¬"
            $ArrayofChar[$i] = "g"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "1" And $ArrayofChar[$i+1] = "2" And ($ArrayofChar[$i-1] = " " Or $ArrayofChar[$i-1] = "t")
            $ArrayofChar[$i] = "r"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2
        Case $ArrayofChar[$i] = "F" And $ArrayofChar[$i+1] = "_"
            $ArrayofChar[$i] = "e"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
            $i = $i+2

        Case $ArrayofChar[$i] = "3"
            $ArrayofChar[$i] = "b"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "("
            $ArrayofChar[$i] = "c"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "f"
            $ArrayofChar[$i] = "f"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "]"
            $ArrayofChar[$i] = "i"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "j"
            $ArrayofChar[$i] = "j"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "º"
            $ArrayofChar[$i] = "o"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "¶"
            $ArrayofChar[$i] = "q"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "§"
            $ArrayofChar[$i] = "s"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = ""
            $ArrayofChar[$i] = "t"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "µ"
            $ArrayofChar[$i] = "u"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "v"
            $ArrayofChar[$i] = "v"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "×"
            $ArrayofChar[$i] = "x"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "¥"
            $ArrayofChar[$i] = "y"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case $ArrayofChar[$i] = "z"
            $ArrayofChar[$i] = "z"
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Case Else
            $ArrayofChar[$i] = $ArrayofChar[$i]
            $Outputtext = $Outputtext & $ArrayofChar[$i]
    EndSelect
    Next
;This is to clean up the string (eliminate superfluous space)
    If StringInStr ($Outputtext, "  ") <> 0 then
    For $j = 1 to 2
    $Processing = $Outputtext
    $StringLen = StringLen ($Processing)
    $ArrayofChar = StringSplit ($Processing, "")
    $Outputtext = ""
    For $i =  1 to $StringLen
        If  $ArrayofChar[$i] = " " And  $ArrayofChar[$i+1] <> " " Then
            $i = $i+1
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Else
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        EndIf
    Next
    Next
    EndIf
    $ArrayofChar = 0

;This is to display the outcome
    _GUICtrlEdit_SetText ($Output, $Outputtext)
EndFunc
Edited by bairacdn2005

Share this post


Link to post
Share on other sites

try this

For $i = 1 To $StringLen -1 ; lower the last count due to the [$i + 1] below 
                If $ArrayofChar[$i] = " "  And $ArrayofChar[$i + 1] <> " "  Then ; $i + 1 will make the error
                    ;$i = $i + 1 ; not needed
                    $Outputtext = $Outputtext & $ArrayofChar[$i] ; this line is the same 
                Else
                    $Outputtext = $Outputtext & $ArrayofChar[$i] ; as this one ??????
                EndIf
            Next

????

8)

Edited by Valuater

Share this post


Link to post
Share on other sites

For $i = 1 To $StringLen -1 ; lower the last count due to the [$i + 1] below 
                If $ArrayofChar[$i] = " "  And $ArrayofChar[$i + 1] <> " "  Then ; $i + 1 will make the error
                    ;$i = $i + 1 ; not needed
                    $Outputtext = $Outputtext & $ArrayofChar[$i] ; this line is the same 
                Else
                    $Outputtext = $Outputtext & $ArrayofChar[$i] ; as this one ??????
                EndIf
            Next

????

8)

haha just some stupid ideas and short-thinking when trying to find a solution for my clean-up modules

I tried your one. The error didnt come up but the program doesnt work properly now T_T. It misses the last character while processing. Due to the last count are lower by 1 , I think

I'm trying to make a text with a space between each character to another, and a 3-spaces between words

thanks in advance Valuater :)

Share this post


Link to post
Share on other sites

;This is to clean up the string (eliminate superfluous space)
    If StringInStr ($Outputtext, "  ") <> 0 then
    For $j = 1 to 2
    $Processing = $Outputtext
    $StringLen = StringLen ($Processing)
  [b]  $ArrayofChar = StringSplit ($Processing, "") & " "[/b]
    $Outputtext = ""
    For $i =  1 to $StringLen
        If  $ArrayofChar[$i] = " " And  $ArrayofChar[$i+1] <> " " Then
            $i = $i+1
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        Else
            $Outputtext = $Outputtext & $ArrayofChar[$i]
        EndIf
    Next
    Next
    EndIf
    $ArrayofChar = 0

;This is to display the outcome
    _GUICtrlEdit_SetText ($Output, $Outputtext)
EndFuncoÝ÷ Ø!jxu«mæèÙbè­ßÛ0¢¹" èÀ6®¶­sc²b33c¶Òb33c¶²²æ÷BæVVFV@¢b33c´÷WGWGFWBÒb33c´÷WGWGFWBfײb33c´'&öd6%²b33c¶Ò²F2ÆæR2FR6ÖP¢VÇ6P¢b33c´÷WGWGFWBÒb33c´÷WGWGFWBfײb33c´'&öd6%²b33c¶Ò²2F2öæRóóóóóð

the $i = $i + 1 change the element in the array that doing the job

it looks stupid when "if something and else the same thing" haha ^_^

oh Saunder you has the same ideal with me:D

thanks you all :)

Share this post


Link to post
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
Sign in to follow this  

×
×
  • Create New...