Diana (Cda) Posted June 10, 2013 Share Posted June 10, 2013 (edited) Hi, everyone! Something new for me which is why I'm stumped I guess. I envision some sort of GUI that has an input box of some sort for user input. The user will input 1 to 3 words and then hit enter. After each enter, a new blank input box would appear but the previous text got appended with a text bridge in between. I'm not sure how AI would handle storing the data in between Enters but outputting to an INI file on the desktop might work - updating the INI after the Enter key was pressed each time, appending the user input and extra syntax each time (???) - would that be do-able? At any rate, here below is the type of output text string needed - with the user's input going in between the 2 asterisks. I've used just some random company names as an example. Last Thursday i built this type of text string manually which included about 57 companies, if memory serves, so the GUI should work until user kits an OK or DONE key when all entries are done. Not Like "*Philips*" AND Not like "*Sony*" AND Not Like "*Texaco*" AND Not Like "*Microsoft*Corporation*" AND Not Like ... (etc.) The only reason I used *Microsoft*Corporation* above as an example using 2 words is because even though something like just *Microsoft* is often the more desirable input, there are, however, a handful of companies in our db that are extremely similar. The only way to ensure we deal reliably with them is by including more than one word so that that company is completely filtered out without affecting any others with a nearly identical name with slight differences that must remain in. Anyway, any ideas? I'm drawing a bit of a blank on how to begin coding for this case. Thanks! Edited June 10, 2013 by Diana (Cda) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 11, 2013 Moderators Share Posted June 11, 2013 Diana (Cda),Here is a very simple way to do what you want: expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUICtrlCreateLabel("Current string", 10, 40, 200, 20) $cLabel = GUICtrlCreateLabel("", 10, 60, 480, 200) GUICtrlSetFont(-1, 10, Default, Default, "Consolas") $cButton = GUICtrlCreateButton("Done", 10, 280, 80, 30) GUICtrlCreateLabel("Final string", 10, 320, 200, 20) $cResult = GUICtrlCreateLabel("", 10, 340, 480, 150) GUICtrlSetFont(-1, 10, Default, Default, "Consolas") GUISetState() ; Clear the data $sData = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cInput ; Read the input and replace the spces with "*" $sInput = StringReplace(GUICtrlRead($cInput), " ", "*") ; Add the new content to the stored data $sData = $sData & 'Not like "*' & $sInput & '*" AND ' ; Show what we have GUICtrlSetData($cLabel, $sData) ; And clear the input GUICtrlSetData($cInput, "") Case $cButton ; Remove the trailing " AND " $sData = StringTrimRight($sData, 5) ; Clear the top label GUICtrlSetData($cLabel, "") ; Show the final result GUICtrlSetData($cResult, $sData) EndSwitch WEndDo you actually want to limit the input to a certain number of words? That could be done fairly easily with an EN_CHANGE message handler. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Diana (Cda) Posted June 18, 2013 Author Share Posted June 18, 2013 Good Afternoon! I just wanted to come back and say how wonderful this script has been and should done so long before now. I've been at this new job now a bare 3 weeks yet have already put in a lot of overtime even coming in one Saturday for all afternnoon already <g>. You get thrown into jobs nowadays with no training whatsoever so you have to figure a way to make things work and that takes time. At any rate, re the maximum number of characters - I asked in another forum this very question at the same time I posted the original message here but have still not had a response to that. I also googled around as much as I could and did find that it _might_ be 1,000, as per 1 website. So that's the only change I'd make as it would make life easier if the script did make a truncation. But thanks so very much once again. I've used the script twice already for filtering out companies in the program and it worked perfectly. And the only reason why I haven't used it more is because my colleagues were out of the country presenting. So we'll be going back to twice per week very soon now that they've returned. Cheers! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 18, 2013 Moderators Share Posted June 18, 2013 Diana (Cda),I am delighted you found the code useful. My comment about limiting the input referred to each separate instance - not the entire string. You had initially mentioned "The user will input 1 to 3 words" - it was that limit I was suggesting the EN_CHANGE message could action. If you want to limit the total string to a maximum of 1000 entries then that could also be done very simply by counting the entries and forcing completion when the limit was reached. Which, or both, would you like to see incorporated? M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Diana (Cda) Posted June 18, 2013 Author Share Posted June 18, 2013 (edited) Diana (Cda), I am delighted you found the code useful. <grin> Ditto! My comment about limiting the input referred to each separate instance - not the entire string. You had initially mentioned "The user will input 1 to 3 words" - it was that limit I was suggesting the EN_CHANGE message could action. If you want to limit the total string to a maximum of 1000 entries then that could also be done very simply by counting the entries and forcing completion when the limit was reached. Which, or both, would you like to see incorporated? Oh, well, that's even better! Thanks for that, but I'm thinking that the # of words isn't too critical, which is good, but it would be grand if the "forcing completion" of the total number of characters would be enforced - in this case, the limitation being 1,000 characters. As long as AI handles the text in the same order it was entered (which it should, right?), it should hopefully be easy enough to see at the end exactly where AI had to stop the process. I'd then go back and manually deal with those entries that were beyond the 1,000 character limitation after the export is done - which should be completely do-able since most of the companies should be dealt with by 1,000 characters by my estimates. Thank you! Edited June 18, 2013 by Diana (Cda) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted June 19, 2013 Moderators Share Posted June 19, 2013 Diana (Cda),Here is some amended code which limits the code to 1000 charaters or thereabouts. As soon as the length of the string goes over 1000 characters, it is as if the "Done" button were pressed automatically - look for the ; ~~~~~~~~ delimited lines:expandcollapse popup#include <GUIConstantsEx.au3> $hGUI = GUICreate("Test", 500, 500) $cInput = GUICtrlCreateInput("", 10, 10, 200, 20) GUICtrlCreateLabel("Current string", 10, 40, 200, 20) $cLabel = GUICtrlCreateLabel("", 10, 60, 480, 200) GUICtrlSetFont(-1, 10, Default, Default, "Consolas") $cButton = GUICtrlCreateButton("Done", 10, 280, 80, 30) GUICtrlCreateLabel("Final string", 10, 320, 200, 20) $cResult = GUICtrlCreateLabel("", 10, 340, 480, 150) GUICtrlSetFont(-1, 10, Default, Default, "Consolas") GUISetState() ; Clear the data $sData = "" While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $cInput ; Read the input and replace the spces with "*" $sInput = StringReplace(GUICtrlRead($cInput), " ", "*") ; Add the new content to the stored data $sData = $sData & 'Not like "*' & $sInput & '*" AND ' ; Show what we have GUICtrlSetData($cLabel, $sData) ; And clear the input GUICtrlSetData($cInput, "") ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ; Check the 1000 character limit If StringLen($sData) > 1000 Then ; If over then act as if the "Done" button had been pressed ContinueCase EndIf ;~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Case $cButton ; Remove the trailing " AND " $sData = StringTrimRight($sData, 5) ; Clear the top label GUICtrlSetData($cLabel, "") ; Show the final result GUICtrlSetData($cResult, $sData) EndSwitch WEndI hope that suffices - come back if not. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now