04-11-2020 07:27 PM
I'm trying to make VI that will remove every space from input (by user string ). After I run it and write any text into system string nothing happen.
Solved! Go to Solution.
04-11-2020 08:04 PM
It is difficult for us to edit a picture. Please attach your VI.
Look at the string function "Search and Replace Psttern VI". Combine that with a While Loop, a Shift Register, and one other function and you have a simple solution.
Bob Schor
04-11-2020 08:30 PM
04-11-2020 09:00 PM - edited 04-11-2020 09:10 PM
Your input terminal is outside the loop, so it will get read when the program starts and then never again. Similarly, your indicator will only get updated once the loop stops because it is after the main loop. (You need to understand the principles of dataflow! Start with some basic tutorials)
All you need is the following. Place it all inside a while loop, together with a stop control and a small wait.
There is no need for the FOR loop, of course. Since "replace all" has a True wired to it, all spaces will be replaced with an empty string.
04-12-2020 12:17 PM
What am i doing wrong, that it still doesn't work as it should?
04-12-2020 12:35 PM
Hi hearent,
@hearen123 wrote:
What am i doing wrong, that it still doesn't work as it should?
I don't know. Your VI works for me as it removes any SPACE chars from the input string…
(I just removed this silly WHILE loop running forever!)
04-12-2020 12:45 PM
Thanks for response, help and dedicated time.
How do you run and check this program? By 'run continuously, writing output text and clicking enter?
04-12-2020 01:19 PM - edited 04-12-2020 01:39 PM
@hearen123 wrote:
What am i doing wrong, that it still doesn't work as it should?
You need to tell us ...
Obviously there is a problem either with your action or your expectation. 😉
A loop with TRUE wired to the termination is useless and can be deleted with no change in functionality.
Not sure what you expect, but it will not remove spaces from the input control, but create an output that is identical to the input, but with all spaces removed. If you want to remove spaces from the input string control, remove the indicator and write to a local variable of the input instead.
If you would have a reasonable while loop*, It will also only process the string once you leave the string control and click elsewhere. This is as designed!
You should::
Configure the input to "update value while typing". Now it will process the string with each iteration.
Configure the input to "limit to single line". Now you can end the string input by hitting the enter button.
*or use run continuously, which is NOT recommended!.