Jump to content
Sign in to follow this  
Solarlight27

Get Char Pos of Next Comma?

Recommended Posts

Solarlight27

Hey guys,

I'm working on a code which creates a drop down menu as the user is typing, the drop down updates and calls the lines included below.

$array = _GUICtrlRichEdit_GetSel($hRichEdit)

$iStart = _GUICtrlRichEdit_GetCharPosOfPreviousWord($hRichEdit, $array[0])
$iEnd = _GUICtrlRichEdit_GetCharPosOfNextWord($hRichEdit, $array[0])
$sText = _GUICtrlRichEdit_GetTextInRange($hRichEdit, $iStart, $iEnd)

What I want to do is instead of using the char positions of Spaces, I'd like to use Commas instead.

For example if I had a shopping list of (1% milk, cheese, red grapes) I want to be able to return each list item (by using the comma locations), instead of returning each individual word on that list (i.e. "red grapes" instead of "red" and "grapes").

 

Thank You!

Share this post


Link to post
Share on other sites
iamtheky

no you need stringsplit, or stringmid between two stringinstr returns, or use @czardas csv_splitter.  Those all make that task super easy.

EM_FindWordBreak does not look to have settable delimiters, but I am not an authority on the matter.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb788018(v=vs.85).aspx

 

Edited by iamtheky

,-. .--. ________ .-. .-. ,---. ,-. .-. .-. .-.
|(| / /\ \ |\ /| |__ __||| | | || .-' | |/ / \ \_/ )/
(_) / /__\ \ |(\ / | )| | | `-' | | `-. | | / __ \ (_)
| | | __ | (_)\/ | (_) | | .-. | | .-' | | \ |__| ) (
| | | | |)| | \ / | | | | | |)| | `--. | |) \ | |
`-' |_| (_) | |\/| | `-' /( (_)/( __.' |((_)-' /(_|
'-' '-' (__) (__) (_) (__)

Share this post


Link to post
Share on other sites
kylomas

SolarLight27,

This sounds a little like autocomplete.  Is that what you are trying to do?  If so this may help...

;
;
;

#include <GuiComboBox.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Global $cCombo1, $cCombo2

_Main()

Func _Main()

    ; Create GUI
    GUICreate("ComboBox Auto Complete", 400, 296)
    $cCombo1 = GUICtrlCreateCombo("", 2, 2, 396, 296)
    GUICtrlSetData(-1, "Apple|Orange|Tomato|Angel|Antler")
    $cCombo2 = GUICtrlCreateCombo("", 2, 42, 396, 296)
    GUICtrlSetData(-1, "One|Two|Three")
    GUISetState()

    GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

    ; Loop until user exits
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE
    GUIDelete()
EndFunc   ;==>_Main

Func _Edit_Changed($cCombo)
    _GUICtrlComboBox_AutoComplete($cCombo)
EndFunc   ;==>_Edit_Changed

Func WM_COMMAND($hWnd, $iMsg, $iwParam, $ilParam)

    #forceref $hWnd, $iMsg, $ilParam

    $iIDFrom = BitAND($iwParam, 0xFFFF) ; Low Word
    $iCode = BitShift($iwParam, 16) ; Hi Word
    If $iCode = $CBN_EDITCHANGE Then
        Switch $iIDFrom
            Case $cCombo1
                _Edit_Changed($cCombo1)
            Case $cCombo2
                _Edit_Changed($cCombo2)
        EndSwitch
    EndIf
    Return $GUI_RUNDEFMSG
EndFunc   ;==>WM_COMMAND

kylomas 


Forum Rules         Procedure for posting code

"I like pigs.  Dogs look up to us.  Cats look down on us.  Pigs treat us as equals."

- Sir Winston Churchill

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.