Showing results for 
Search instead for 
Did you mean: 

String Control / Indicator Maximum Length (FIFO)

Go to solution

Hello All;


Maybe this is a silly question (maybe not)... how does one go about setting the length of a string such that the characters at the front drop off when the max number has been reached and there's more data coming in?  For example, I want to:

(i) Set max Control / Indicator string length to 255;

(ii) Set up a property or routine such that when character 256 is input, character 1 drops off (kind of like a FIFO).

(iii) Strings can be either typed in or added programatically (i.e. via the Properties --> Value function.


Please advise.  Bear in mind, this needs to happen actively (xcontrol?).


Thanks in advance...

0 Kudos
Message 1 of 7

(i) You can't. (Although there is an actual limit, having to do with the max value of 4 btyes used to store the length of the string.)

(ii) You would need to monitor the Value change event and if the length exceeds, use the string functions to chop it off. A string control can be set to update its value while typing (right-click on control). See e.g: Limiting the Length of a String Control.

(iii) I don't understand this. Is this a statement or a question. Seems like a (true) statement to me. Please elaborate/clarify.

0 Kudos
Message 2 of 7

thanks, smercurio...


I didn't think I could, but always better to ask.


Basically, my application is a serial COM port terminal, with RX/TX string windows.  User inputs commands into the TX window and responses are displayed in the RX window.  The application is set up to work with other applications (via queues), so other applications can send commands to the serial application to send on to whatever device I am taking to.


This being the case (a long way to answer item (iii) you asked about), the serial app can be used directly, with the user entering commands and reading the responses.  For this, I have a "Clear: toggle that clears the contents of each window.  However, when a secondary application is using the serial app to send/receive data, there is no "clear".  As a result, the contents can grow incredibly large over time.


I do know that I can use the Split Array function, by transferring the contents using "Spreadsheet String to Array", and splitting out the unwanted rows... perhaps this is the easiest way (since none of the commands used are more than a dosen or so characters each)... I will try to use your examples and see if I can quickly utilise that to chop off unwanted chars in a given line.  Once I have something useful, I will post it.  Otherwise, I'll probably use the approach I just mentioned (arrays).


In the meantime, if anyone already has a solution to this (and before I come up with one), please let me know!

0 Kudos
Message 3 of 7
You can always create a special "clear" command for your VI. Since your VI looks at the queue it need not automatically send whatever it sees out the serial port. The queue can be used to receive instructions as well.
0 Kudos
Message 4 of 7

I've thought of that also... or simply disabling the string GUI altogether if the serial app is being used from another app (since it only operates in the background anyway); but I digress.


I've made progess, and I have a VI that mostly does what I want, although I'm running into the issue of updating the script control as I'm typing.  Not quite sure what is happening, since I do not (ever) use event cases in this way.  I'll post what I have so far, and hopefully someone will be able to modify it (*hint, hint*) to correct the issue... or at least let me know where I can look...


I have a VI that I can update when I SEND something to it, just not for the active typing (see attachment), so I'm most of the way there...

0 Kudos
Message 5 of 7
Accepted by Hannamon

Solved it!


Turns out, I was going about it in the wrong way... I was using the "Key Down" event when I should have been using the "Value Changed" event, coupled with the String control set to "Update While Typing".  Anyway, I'll post my code for the event-driven solution.  Hopefully it will help someone else out, down the line.



0 Kudos
Message 6 of 7
I was just looking at your VI when I got the email notification of a follow-up. Glad to hear you found the solution yourself. Smiley Wink
0 Kudos
Message 7 of 7