![Crazy :crazy:](./images/smilies/icon_crazy.gif)
THANK YOU IN ADVANCE!!!!! I would love and greatly appreciate anyone's help. I could very well be comparing things in my if-statements with the wrong operators or something else, but I believe the problem does have to do with the way I've set up my if-statements.
Code: Select all
^G:: ;Ctrl + G to activate it.
;Retrieving the clipboard data, and splitting it up.
ClipboardData := Clipboard
WordArray := StrSplit(ClipboardData, A_Space)
ArrayLength := WordArray.length()
Outer := 1 ;Finding the array length, and creating an iterator variable.
FinalStr := "" ;Resetting the final string for multiple uses.
While Outer < (ArrayLength + 1) {
PunctArray := [ ".", "," , ":", ";", "?", "!", """" ]
Prepunct := "" ;Makes Prepunct empty each time through the outer loop. If there is no pre-punctuation, PrePunct will not be triggered in the if-statement down where FirstLettersArray is created.
Inner := 1
PArrayLength := PunctArray.length() ;Starting the inner loop, and determining the length of the punctuation array.
;Creating the first character for pre-punct:
FirstCharacter := Substr(WordArray[Outer],1,1) ;Creates a new string with only the first character of each word.
While (Inner < (PArrayLength + 1)) { ;Looping through each element in PunctArray.
;Looping through PunctArray to match to FirstCharacter,
;and looping through if (InStr) to see if more punct is there.
if (FirstCharacter := PunctArray[Inner]) {
PrePunct := PunctArray[Inner] . PrePunct . "" ;Forcing a string with the "".
}
if (Instr(WordArray[Outer], PunctArray[Inner], 2)) ;Searching for any other matches for punctuation, starting at the second position to exclude the first character.
PostPunct := PunctArray[Inner] . PostPunct . ""
Inner := Inner + 1 ;Looping through each punctuation.
}
if !(Prepunct="") {
WordArray[Outer] := PrePunct . Substr(WordArray[Outer], 2,1) . PostPunct ;If there is pre-punctuation, it takes the second letter of the substring assuming there is only one pre-punctuation character (other alternatives are super unlikely so I'm not gonna code it in).
MsgBox, prepunct
}else{
WordArray[Outer] := Substr(WordArray[Outer],1,1) . PostPunct ;If no pre-punctuation, it just uses the first letter and then attaches the punctuation to it.
}
FinalStr := FinalStr . " " . WordArray[Outer] ;Finally, it prints the final string, appending the newest FirstLettersArray set of characters each time.
MsgBox, %FinalStr%
PrePunct := ""
PostPunct := "" ;Clearing both of the punctuations for the next iteration.
Outer := Outer + 1 ;Looping the outer while loop to loop through each word in the paragraph.
}
Clipboard := FinalStr ;Re-assigning the string to the clipboard to be copied.
return