My brain is having trouble understanding how to replace part of a string. Really, I want to remove a character from a string, but leave the rest of the string intact. So lets sat I have "COPY:ABCD", how would I remove "A" so it then becomes "COPY:BCD"?
It's confusing me...
Replacing Part of a String Topic is solved
Re: Replacing Part of a String Topic is solved
Code: Select all
OldStr = COPY:ABCD
StringReplace, NewStr, OldStr, a
MsgBox OldStr is %OldStr% `n NewStr is %NewStr%
Re: Replacing Part of a String
No, that isn't right. Here's what I'm trying to do:
I have a commandline switch that has multiple flags. I have a gui that allows you to add those flags to the switch, or take them away. Adding is easy, but taking away is tougher for me to grasp. So, the switch is /COPY:<flag><flag><flag><flag>. Here's an excerpt from the code I'm using:
Now, I have about 5 other flags that get added the same way. Easy. But say I want to (in the gui) change my mind and not set the "data" flag (shown above), but keep the other 5? Or say I select all 6, but want to change my mind on the third flag? How would I take the string with all 6 (/COPY:ABCDEF), decide I don't want the "D" flag, then make it "/COPY:ABCEF"? "data" in the above code represents the variable for the checkbox. 1 = checked, 0 = unchecked. You can see with it being checked, I just concatenate the string. Now, how would I take that string and remove the "D" flag I just put there, but keep the later coded in flags intact? The rest of the code is the same as the excerpt, just different letters for different flags.
If it is StringReplace (which I'm familiar with), I don't see how it will work.
I have a commandline switch that has multiple flags. I have a gui that allows you to add those flags to the switch, or take them away. Adding is easy, but taking away is tougher for me to grasp. So, the switch is /COPY:<flag><flag><flag><flag>. Here's an excerpt from the code I'm using:
Code: Select all
Copy := "/COPY:"
Gui, Submit, NoHide
If ( data = 1 )
{
IfNotInString, Copy, D
Copy .= "D"
}
If it is StringReplace (which I'm familiar with), I don't see how it will work.
Re: Replacing Part of a String
I need to break these down into separate subroutines. That could help me immensely. Let me do that and step back and take a look.
Re: Replacing Part of a String
Rindis is correct. I apologize. My code wasn't right at first--I needed to break it down into multiple subroutines (you'd understand if you saw both incorrect and correct code). Thanks for the help. Sorry for being dense.