John Lokanis Posted September 23, 2008 Report Share Posted September 23, 2008 This set of VIs implements a standard text search prompt as seen in most text editors. To use it, all you need to do is pass it a reference to the text control you wish to search. The following features are provided: 1. Search in both directions. 2. Remembers past search strings from each session. 3. Can choose to match case or not. 4. Opens centered on caller. (Can override if necessary) There are some issues with this version. I could use help in improving in these areas: 1. Speed (it is slow for large amounts of text). By using the Get Nth Line function, I can support a text control with any font. I think this could be improved by doing a binary search algorithm, but I would need to know how many lines a text control contains. This is not easy and requires counting <CR> and word wraps. 2. To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically. So, when it first appears, you must click in the window before you can type anything. 3. In order to make the text in the original control appear highlighted, that window must be front most. So, after it finds something, it has to set the caller's window front most. This means each time you wish to do another search, you must select the dialog window again. Any ideas on this? 4. I am using a combo box to allow it to remember past searches. For some reason, if you type the very first entry into the combo box and then press return to toggle the find button, it will not see this entry when it reads the string from the combo box. So, instead, I had to force the user to click on the Find button. I hope this incarnation is useful to you and with help, we can make this even better. -John Download File:post-2411-1222064807.zip Quote Link to comment
John Lokanis Posted September 23, 2008 Author Report Share Posted September 23, 2008 QUOTE (jlokanis @ Sep 21 2008, 11:29 PM) I think this could be improved by doing a binary search algorithm, but I would need to know how many lines a text control contains. Solved the speed issue. Check out the code to see how! Remaining issues: 2. To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically. So, when it first appears, you must click in the window before you can type anything. 3. In order to make the text in the original control appear highlighted, that window must be front most. So, after it finds something, it has to set the caller's window front most. This means each time you wish to do another search, you must select the dialog window again. Any ideas on this? 4. I am using a combo box to allow it to remember past searches. For some reason, if you type the very first entry into the combo box and then press return to toggle the find button, it will not see this entry when it reads the string from the combo box. So, instead, I had to force the user to click on the Find button. Check out the new version attached to this post. -John http://lavag.org/old_files/post-2411-1222119951.zip'>Download File:post-2411-1222119951.zip Quote Link to comment
Yair Posted September 24, 2008 Report Share Posted September 24, 2008 QUOTE (jlokanis @ Sep 23 2008, 12:48 AM) To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically. I haven't tried, but what happens if you make the window modal and then programmatically change it to be floating? Quote Link to comment
John Lokanis Posted September 24, 2008 Author Report Share Posted September 24, 2008 QUOTE (Yair @ Sep 23 2008, 09:49 AM) I haven't tried, but what happens if you make the window modal and then programmatically change it to be floating? I didn't try that but I did find that it would work as required by letting it be floating but not hiding it when LabVIEW was not the active window. I didn't know you chould change a dialog from modal to floating while it was running. I will look into this as well. Thanks for the idea. Quote Link to comment
John Lokanis Posted September 25, 2008 Author Report Share Posted September 25, 2008 QUOTE (jlokanis @ Sep 21 2008, 11:29 PM) There are some issues with this version. I could use help in improving in these areas:1. Speed (it is slow for large amounts of text). By using the Get Nth Line function, I can support a text control with any font. I think this could be improved by doing a binary search algorithm, but I would need to know how many lines a text control contains. This is not easy and requires counting <CR> and word wraps. 2. To make sure it does not get lost, I need to make it floating. But, for some reason, you cannot bring a floating window to the front programmatically. So, when it first appears, you must click in the window before you can type anything. 3. In order to make the text in the original control appear highlighted, that window must be front most. So, after it finds something, it has to set the caller's window front most. This means each time you wish to do another search, you must select the dialog window again. Any ideas on this? 4. I am using a combo box to allow it to remember past searches. For some reason, if you type the very first entry into the combo box and then press return to toggle the find button, it will not see this entry when it reads the string from the combo box. So, instead, I had to force the user to click on the Find button. 1. Speed fixed. Uses binary search. One caveat: it will only work with single font string controls. So, no mixing fonts or adding modifiers (bold, etc). If you can find a way around this, please let me know. 2. By setting it to float and always visable (do not hide when LV not active), I was able to make it be the top window when it is activated. 3. Still no improvment here. 4. Needed to set the button to both toggle and grab focus when <CR> pressed. This way, the data being entered into the combo box becomes 'active'. Thanks to everyone who helped improve this code. If you have any other ideas or suggestions, please post them and I will see if I can improve it more. -John http://lavag.org/old_files/post-2411-1222277716.zip'>Download File:post-2411-1222277716.zip Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.