June 03, 2020, 12:40:34 pm

## News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!

## Quickest way to find a match for two words

Started by Andy, November 07, 2019, 04:02:18 am

0 Members and 1 Guest are viewing this topic.

#### Andy

##### November 07, 2019, 04:02:18 am
Hi,

I was wondering what opinions / examples you all might have to find a match of two words, where you could have around 1,000 words to check against.

Currently I'm using this method:

Sample of words stored in an array...

Code Select
'A
Words[470] = "ABS"
Words[471] = "ACOS"
Words[472] = "ACOSD"

'B
Words[498] = "BACKBUFFER"
Words[499] = "BACKPEN"
Words[500] = "BASELEN"

'C
Words[512] = "CALL"
Words[513] = "CASE"
Words[514] = "CASE&"

I've shorted this example somewhat.

Next, I take the first letter of a word I want to check for, say "B" for BACKPEN.

And use SELECT to find the first / last words beginning with "B" in the array...

Code Select
SELECT UCASE\$(MID\$(CheckWord,1,1))
CASE "\$"
From = 0
LoopTo = 7
CASE "@"
From = 10
LoopTo = 467
CASE "A"
From = 470
LoopTo = 495
CASE "B"
From = 498
LoopTo = 509
CASE "C"
From = 512
LoopTo = 556

Finally, I do a FOR / NEXT loop to check all the words beginning with "B" and detect when a match is found.

Is there a way matching words can be quicker?

Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

#### LarryMc

##### November 07, 2019, 09:04:20 am #1
See if you can glean any ideas from this code that I use in the IDE.

Code Select
string token2=" "+lcase\$(token)
settype p, CHILDWINDOW
int spos,epos
istring WordList[5000]=""

select mode
case 1 '@
'ebkeywords2
spos = instr(lcase\$(#<string>&ebkeywords2),token2)
while spos>0
epos = instr(#<string>&ebkeywords2," ",spos+1)
WordList+=mid\$(#<string>&ebkeywords2,spos+1,epos-1-spos)+" "
spos = instr(lcase\$(#<string>&ebkeywords2),token2,epos)
wend
case 2 '\$
'ebkeywords0
spos = instr(lcase\$(#<string>&ebkeywords0),token2)
while spos>0
epos = instr(#<string>&ebkeywords0," ",spos+1)
WordList+=mid\$(#<string>&ebkeywords0,spos+1,epos-1-spos)+" "
spos = instr(lcase\$(#<string>&ebkeywords0),token2,epos)
wend
case 3 'commands
'ebkeywords1 -types
'ebkeywords0 - commands
spos = instr(lcase\$(#<string>&ebkeywords1),token2)
while spos>0
epos = instr(#<string>&ebkeywords1," ",spos+1)
WordList+=mid\$(#<string>&ebkeywords1,spos+1,epos-1-spos)+" "
spos = instr(lcase\$(#<string>&ebkeywords1),token2,epos)
wend

spos = instr(lcase\$(#<string>&ebkeywords0),token2)
while spos>0
epos = instr(#<string>&ebkeywords0," ",spos+1)
WordList+=mid\$(#<string>&ebkeywords0,spos+1,epos-1-spos)+" "
spos = instr(lcase\$(#<string>&ebkeywords0),token2,epos)
wend
endselect
if wordlist<>"" then wordlist=left\$(wordlist,len(wordlist)-1)
_SendMessage(*p.hwndSci, SCI_AutoCShow,len(token), &WordList)
return
endsub

and this goes in an .inc file
Code Select
_asm
segment .data
ebkeywords0:
db " \$asm \$define \$elif \$elifdef \$elifndef \$else \$emit \$endasm \$endif \$endregion \$error \$if \$ifdef \$ifndef \$include \$macro \$main \$option \$region \$typedef "
db " \$undeclare \$undef \$use \$warning \$wheredefined __asm __delete __get __new __power __put __read __readmem __write __writemem _asm _dup\$ _endasm _wdupstr _wstrappend "
db " autodefine backpen baselen begininsertmenu beginmenu beginpopup break breakfor browsecmd byref byval calendarcontrol call callobjectmethod case case& catch cbeaddstring cbedeletestring cbegetselected "
db " cbegetstring cbegetstringcount cbeinsertstring cbesetimagelist cbesetindent cbesetselected ccgetcolor ccgetcursel ccgetfirstdayofweek ccgetminimumrect ccgetscrolldelta ccgettoday ccsetcolor ccsetcursel ccsetfirstdayofweek ccsetscrolldelta ccsettoday cdecl ceil centerwindow "
db " checkdropformat checkmenuitem chr\$ circle class closeconsole closedialog closefile closeprinter closescreen closewindow cls color colorrequest comboboxex comenumbegin comenumnext comgetlasterror const contextmenu "
db " control controlcmd controlex controlexists copyfile copyrgn cos cosd cosh coshd createcomobject createdialog createdir createmapdata createmenu createregkey createscreen createsprite data databegin "
db " dataend date\$ datetimepicker dbbinddate dbbinddateparam dbbindparameter dbbindtime dbbindtimeparam dbbindtimestamp dbbindtimestampparam dbbindvariable dbcardinality dbconnect dbconnectdsn dbcreatemdb dbdisconnect dbenumdrivers dbexecsql dbexecute dbfreesql "
db " dbget dbgetdata dbgetdate dbgeterrorcode dbgeterrortext dbgetfirst dbgetlast dbgetnext dbgetnumcols dbgetprev dbgettime dbgettimestamp dbisnull dblistcolumns dblisttables dbpreparesql debugprint declare def default "
db " define_guid delete deletefile deleteimage deleteregkey deletergn deletestring dictadd dictcreate dictfree dictgetkey dictgetnextassoc dictgetstartassoc dictgetvalue dictlookup dictremove dictremoveall dim do domodal "
db " drawaaline drawalphaline drawfilledrect drawline drawmap drawmode drawrect drawsprite drawspritexy dtpgetmccolor dtpgetsystemtime dtpsetformat dtpsetmccolor dtpsetsystemtime dxendtry dxtry dynamic_cast each ellipse else "
db " elseif enablecontrol enablemenu enablemenuitem enabletabs end endcatch endclass endenum endif endinterface endmenu endpage endpopup endselect endsub endtry endtype endunion endwhile "
db " endwith enum eof exp export extern facos facosd fadepalette fasin fasind fatan fatand fcos fcosd fcosh fcoshd filerequest fillpalette fillscreen "
db " findclose findnext findopen flip floodfill floor flt flushkeys fontrequest for freecomstring freeheap freelib freemap freemem freesprite frontpen fsin fsind fsinh "
db " fsinhd ftan ftand ftanh ftanhd get getbitmapsize getbrowserinterface getbufferheight getbufferpitch getbufferpointer getbufferwidth getcaption getcaretposition getclientsize getcomobject getcomproperty getcontrolhandle getcontroltext getdata "
db " getdefaultprinter getdragkeystate getdragpoint getdropdata getexceptioncode getexceptioninformation getfolderpath gethdc getjoystickaxiscount getjoystickbuttoncount getjoystickcount getjoystickname getjoysticktype getkey getkeystate getmapcount getmapdata getmapheight getmappixelheight getmappixelwidth "
db " getmapwidth getpalettecolor getpixel getposition getprogressposition getresourcelength getscreensize getscrollpos getscrollrange getselected getsize getspinnerbase getspinnerbuddy getspinnerposition getspinnerrangemax getspinnerrangemin getspritedelay getspriteframes getspriteheight getspritepitch "
db " getspritepointer getspritestate getspritetype getspritevelx getspritevely getspritewidth getstartpath getstartpathw getstate getstring getstringcount gettextsize getthumbpos gettrackbarlinesize gettrackbarpagesize gettrackbarposition gettrackbarrangemax gettrackbarrangemin global gosub "
db " goto hcdeleteitem hcgetitemcount hcgetitemdata hcgetitemrect hcgetitemtext hcgetitemwidth hcinsertitem hcsetimagelist hcsetitemdata hcsetitemjustify hcsetitemtext hcsetitemwidth headercontrol heapclear hex\$ if implements import inkey\$ "
db " joyy joyz jump keydown label lcase\$ leave left\$ len let line lineto listadd listaddhead listcreate listgetdata listgetfirst listgetnext listgetpos listremove "
db " menuitem menutitle messagebox mid\$ millisecs modifyexstyle modifystyle mousedown mousex mousey move movemap movesprite new newmap next not offsetof on oncontrol "
db " onexit onmenupick onmessage openconsole openfile openprinter openwindow opt or pagercontrol paletteindex pcforwardmouse pcgetbuttonstate pcgetpos pcrecalcsize pcsetbackcolor pcsetbordersize pcsetbuttonsize pcsetchild pcsetchildhwnd "
db " pcsetpos playmidi\$ playwave popheap print printwindow private progresscontrol progressstepit projectglobal protected prtdialog pset public pushheap put rand rastermode rbaddband rbsetbandbitmap "
db " rbsetbandchild rbsetbandchildhandle rbsetbandcolors rbsetbandtext rbshowband read readmem readpixel reallocheap rebarcontrol rect redrawframe reggetdword reggetstring registerdroptarget regsetdword regsetstring releasehdc removedir removedroptarget "
db " removemenuitem replace\$ restore return rgb rgba rgbtoscreen rgnfrombitmap right\$ rnd rtrim\$ s2w savemapdata scrollmap seedrnd seek select sendmessage separator set_interface "
db " setbuttonbitmaps setbuttonborder setbuttonrgn setcaption setcomproperty setcontrolcolor setcontrolnotify setcontroltext setcontroltextw setcursor setexitcode setfocus setfont sethorizextent sethtcolor seticon setid setjoystickdeadzone setjoystickrange setlbcolwidth "
db " setlinestyle setmapdata setmapviewport setmenu setpalettecolor setprecision setprogressbarcolor setprogressdelta setprogressmarquee setprogressposition setprogressrange setprogressstep setscrollpos setscrollrange setselected setsize setspinnerbase setspinnerbuddy setspinnerposition setspinnerrange "
db " setspritedelay setspritestate setspritetype setspritevelx setspritevely setstate settrackbarlinesize settrackbarpagesize settrackbarposition settrackbarrange settrackbarthumblength settrackbartickfreq settype setwindowcolor sgn showcontextmenu showdialog showimage showwindow sin "
db " sind sinh sinhd sizeof space\$ spinnercontrol spritealpha spriteangle spritecollided spritecollidedex spritedrawmode spriteframe spritemaskcolor spritescalefactor spriteshadowoffset spritetobuffer sqrt startdragdrop starttimer static "
db " static_cast stdmethod step stop stopmidi\$ stoptimer str\$ string\$ sub system tabcontrol tan tand tanh tanhd tcdeletealltabs tcdeletetab tcgetfocustab tcgetitemdata tcgetrowcount "
db " tcgetselectedtab tcgettabcount tcgettabtext tchighlighttab tchittest tcinserttab tcsetfocustab tcsetimage tcsetimagelist tcsetitemdata tcsetmintabsize tcsetselectedtab tcsettabtext tcsettip then this thread throw time\$ timer "
db " to tooltipcontrol trackbarcontrol try ttaddtool ttdeletetool ttrelaymessage ttsettoolrect tvdeleteallitems tvdeleteitem tvgetitemdata tvgetitemtext tvgetselecteditem tvinsertitem tvselectitem tvsetitemdata tvsetitemtext type typedef typeof "
db " ucase\$ union unlockbuffer unlocksprite until using val vec3add vec3cross vec3dot vec3length vec3lerp vec3normalize vec3sub vec4add vec4cross vec4dot vec4length vec4lerp vec4normalize "
db " vec4sub virtual void w2s wait waitcon waitkey waituntil wappend\$ wchr\$ wend whex\$ while winstr with wlcase\$ wleft\$ wltrim\$ wmid\$ wright\$ "
db " write writealphapixel writemem writepixel writepixelfast writeprinter writetext wrtrim\$ wspace\$ wstr\$ wstring\$ wucase\$ wusing wval ",0

ebkeywords1:
db "  anytype bfile char comref datablock dialog double file float guid heap int int64 istring itstring iwstring linkedlist logfont logpen memory nmhdr oem point pointer schar string sword tstring uint uint64 wheap window wintect word wstring",0

ebkeywords2:
db " lar@ry @alpha @autoscale @backenabled @blockcopy @bltalpha @bltcopy @blthflip @bltrotozoom @bltscaled @bltshadow @blttrans @blttransalpha @blttranshflip @blttransrotozoom @blttransscaled @blttransshadow @blttransvflip @bltvflip @border @browseload "
db " @browseprint @browsesearch @browsestop @button @cancelnav @caption @cben_beginedit @cben_deleteitem @cben_dragbegina @cben_dragbeginw @cben_endedita @cben_endeditw @cben_getdispinfo @cben_getdispinfoa @cben_getdispinfow @cben_insertitem @cbncloseup @cbndblclick @cbndropdown @cbneditchange "
db " @cbneditupate @cbnerrspace @cbnkillfocus @cbnselchange @cbnselendcancel @cbnselendok @cbnsetfocus @checkbox @class @code @combobox @controlid @csarrow @cscustom @csidl_admintools @csidl_altstartup @csidl_appdata @csidl_bitbucket @csidl_cdburn_area @csidl_common_admintools "
db " @csidl_common_altstartup @csidl_common_appdata @csidl_common_desktopdirectory @csidl_common_documents @csidl_common_favorites @csidl_common_music @csidl_common_oem_links @csidl_common_pictures @csidl_common_programs @csidl_common_startmenu @csidl_common_startup @csidl_common_templates @csidl_common_video @csidl_computersnearme @csidl_connections @csidl_controls @csidl_cookies @csidl_desktop @csidl_desktopdirectory @csidl_drives "
db " @csidl_favorites @csidl_fonts @csidl_history @csidl_internet @csidl_internet_cache @csidl_local_appdata @csidl_mydocuments @csidl_mymusic @csidl_mypictures @csidl_myvideo @csidl_nethood @csidl_network @csidl_personal @csidl_printers @csidl_printhood @csidl_profile @csidl_program_files @csidl_program_files_common @csidl_program_files_commonx86 @csidl_program_filesx86 "
db " @csidl_programs @csidl_recent @csidl_resources @csidl_resources_localized @csidl_sendto @csidl_startmenu @csidl_startup @csidl_system @csidl_systemx86 @csidl_templates @csidl_windows @cswait @ctcomboautohscroll @ctcombodropdown @ctcombodroplist @ctcombosimple @ctcombosort @cteditautoh @cteditautov @cteditcenter "
db " @cteditleft @cteditmulti @cteditnumber @cteditpass @cteditreturn @cteditright @cteditro @ctlbtnbitmap @ctlbtndefault @ctlbtnflat @ctlbtnmulti @ctlistcolumns @ctlistextended @ctlistmulti @ctlistnotify @ctlistsort @ctliststandard @ctlisttabs @ctlstcbitmap @ctlstcmulti "
db " @ctlstcsimple @ctlstctrans @ctscrollhoriz @ctscrollvert @dtn_closeup @dtn_datetimechange @dtn_dropdown @dtn_formata @dtn_formatquerya @dtn_formatqueryw @dtn_formatw @dtn_userstringa @dtn_userstringw @dtn_wmkeydowna @dtn_wmkeydownw @dts_appcanparse @dts_longdateformat @dts_rightalign @dts_shortdateformat @dts_shownone "
db " @dts_timeformat @dts_updown @edcanundo @edcharfromline @edcopy @edcut @eddeletesel @edemptyundo @edgetfirstline @edgetlimittext @edgetline @edgetlinecount @edgetlinelength @edgetmodified @edgetselection @edit @edlinefromchar @edpaste @edreplacesel @edsetlimittext "
db " @edsetmargins @edsetmodified @edsetselection @edundo @enchange @enenterkey @enerrspace @enhscroll @enkillfocus @enm_dropfiles @enm_protected @enmaxtext @enmchange @enmkeyevents @enmmouseevents @enmnone @enmrequestresize @enmscroll @enmselchange @enmupdate "
db " @enrequestresize @enselchange @ensetfocus @entabkey @enupdate @envscroll @exclientedge @excontrol @exleft @exright @exstaticedge @exwindowedge @falt @fcontrol @file_archive @file_compressed @file_device @file_directory @file_encrypted @file_hidden "
db " @file_normal @file_readonly @file_system @fixedsize @fnoinvert @forwardenabled @fshift @fvirtkey @getheaders @getnavurl @getpostdata @getstatustext @gettitle @goback @goforward @gohome @gostop @group @groupbox @hdn_begindrag "
db " @hdn_begintrack @hdn_begintrackw @hdn_dividerdblclick @hdn_dividerdblclickw @hdn_enddrag @hdn_endtrack @hdn_endtrackw @hdn_getdispinfo @hdn_getdispinfow @hdn_itemchanged @hdn_itemchangedw @hdn_itemchanging @hdn_itemchangingw @hdn_itemclick @hdn_itemclickw @hdn_itemdblclick @hdn_itemdblclickw @hdn_track @hdn_trackw @hds_buttons "
db " @hds_dragdrop @hds_fulldrag @hds_hidden @hds_horz @hds_hottrack @hflip @hidden @hitwindow @hscroll @idabort @idbeforenav @idcancel @idchangewindow @idchar @idclosewindow @idcontinue @idcontrol @idcreate @iddestroy @iddocumentcomplete "
db " @idmove @idmoving @idnavcomplete @idnavigateerror @idnewwindow2 @idnewwindow3 @idno @idok @idpaint @idprogresschange @idrbuttondblclk @idrbuttondn @idrbuttonup @idreqclear @idretry @idsetcursor @idsize @idsizechanged @idsizing @idstatustextupdate "
db " @idtimer @idtitlechange @idtryagain @idvscroll @idyes @imgbitmap @imgcursor @imgemf @imgicon @imgmapcolors @imgoem @imgscalable @ipn_fieldchanged @joytype_flightstick @joytype_gamepad @joytype_headtracker @joytype_rudder @joytype_traditional @joytype_unknown @joytype_wheel "
db " @lbndblclk @lbnerrspace @lbnkillfocus @lbnselcancel @lbnselchange @lbnsetfocus @listbox @listview @lparam @lsdash @lsdashdot @lsdashdotdot @lsdot @lsinside @lssolid @lvdeleteall @lvdeletecolumn @lvdeleteitem @lvfinditem @lvgetcolumntext "
db " @lvgetcolwidth @lvgetcount @lvgetselcount @lvgetselected @lvgettext @lvgettopindex @lvinsertcolumn @lvinsertitem @lvnbeginlabeledit @lvncolumnclick @lvndeleteitem @lvnendlabeledit @lvninsertitem @lvnitemchanged @lvnitemchanging @lvnkeydown @lvsalignleft @lvsaligntop @lvsautoarrange @lvseditlabels "
db " @lvsetcolumntext @lvsetcolwidth @lvsetselected @lvsettext @lvsicon @lvslist @lvsnocolumnheader @lvsnolabelwrap @lvsnoscroll @lvsnosortheader @lvsreport @lvsshowselalways @lvssinglesel @lvssmallicon @lvssortascending @lvssortdescending @maxbox @maximized @mb_abortretryignore @mb_canceltrycontinue "
db " @mb_iconexclamation @mb_iconinformation @mb_iconquestion @mb_iconstop @mb_ok @mb_okcancel @mb_retrycancel @mb_yesno @mb_yesnocancel @mcn_getdaystate @mcn_selchange @mcn_select @mcs_daystate @mcs_multiselect @mcs_notoday @mcs_notodaycircle @mcs_weeknumbers @mdiframe @menucheck @menudisable "
db " @menunum @message @minbox @minimized @mousex @mousey @multiselect @navigate @nmclick @nmdblclk @nmkillfocus @nmoutofmemory @nmrclick @nmrdblclk @nmreturn @nmsetfocus @noautodraw @nocaption @notifycode @nwmf_first "
db " @nwmf_first_userinited @nwmf_forcetab @nwmf_forcewindow @nwmf_fromdialogchild @nwmf_fromproxy @nwmf_htmldialog @nwmf_inactivetab @nwmf_overridekey @nwmf_showhelp @nwmf_suggesttab @nwmf_suggestwindow @nwmf_unloading @nwmf_userallowed @nwmf_userinited @nwmf_userrequested @opaque @pbs_marquee @pbs_smooth @pbs_vertical @pgf_depressed "
db " @pgf_grayed @pgf_hot @pgf_invisible @pgf_normal @pgn_calcsize @pgn_scroll @pgs_autoscroll @pgs_dragndrop @pgs_horz @pgs_vert @qual @radiobutton @rbbs_break @rbbs_childedge @rbbs_fixedbmp @rbbs_fixedsize @rbbs_gripperalways @rbbs_hidden @rbbs_nogripper @rbbs_novert "
db " @rbbs_variableheight @rbn_autosize @rbn_begindrag @rbn_childsize @rbn_deletedband @rbn_deletingband @rbn_enddrag @rbn_getobject @rbn_heightchange @rbn_layoutchanged @rbs_autosize @rbs_bandborders @rbs_dblclktoggle @rbs_fixedorder @rbs_registerdrop @rbs_tooltips @rbs_varheight @rbs_verticalgripper @refresh @resaccel "
db " @resbitmap @rescursor @resdata @resdialog @resgroupcursor @resgroupicon @resicon @resmenu @resmessagetable @resstring @resversion @rgnbutton @richedit @rmblack @rmcopypen @rmmasknotpen @rmmaskpen @rmmaskpennot @rmmergenotpen @rmmergepen "
db " @rmmergepennot @rmnop @rmnot @rmnotcopypen @rmnotmaskpen @rmnotmergepen @rmnotxorpen @rmwhite @rmxorpen @rotozoom @rtaligncenter @rtalignleft @rtalignright @rtcanundo @rtcharfromline @rtcopy @rtcut @rtdeletesel @rtemptyundo @rtfindtext "
db " @rtgeteventmask @rtgetfirstline @rtgetlimittext @rtgetline @rtgetlinecount @rtgetlinelength @rtgetmodified @rtgetselection @rtgetseltext @rtgettextlength @rthidesel @rtlinefromchar @rtload @rtpaste @rtpastespecial @rtprint @rtreplacesel @rtsave @rtscroll @rtsetalignment "
db " @rtsetcharoffset @rtsetdefaultcolor @rtsetdefaultfont @rtseteventmask @rtsetlimittext @rtsetlinewidth @rtsetmargins @rtsetmodified @rtsetselcolor @rtsetselection @rtsetselfont @rtundo @sbbottom @sbendscroll @sbleft @sblinedown @sblineleft @sblineright @sblineup @sbpagedown "
db " @sbpageleft @sbpageright @sbpageup @sbright @sbthumbpos @sbthumbtrack @sbtop @scaled @scrollbar @scrolldown @scrollleft @scrollright @scrollup @sdalpha @sdangle @sdblttype @sdframe @sdheight @sdscale @sdshadow "
db " @sdshadowx @sdshadowy @sdtranskey @sdwidth @sdxpos @sdxvel @sdypos @sdyvel @sfitalic @sfstrikeout @sfunderline @shadow @size @sndasync @sndloop @sndnostop @sndsync @static @status @swhide "
db " @swmaximized @swminimized @swresize @swrestore @swsetpanes @swsetpanetext @swshow @sysbutton @sysmenu @tabstop @tb_bottom @tb_endtrack @tb_linedown @tb_lineup @tb_pagedown @tb_pageup @tb_thumbposition @tb_thumbtrack @tb_top @tbbottom "
db " @tbbuttoncheck @tbbuttongroup @tbenablebutton @tbflat @tbfromhandle @tbgetbuttonheight @tbgetbuttonstate @tbgetbuttonwidth @tbleft @tblist @tbnoalign @tbnoresize @tbresize @tbright @tbs_autoticks @tbs_both @tbs_bottom @tbs_enableselrange @tbs_fixedlength @tbs_horz "
db " @tbs_left @tbs_nothumb @tbs_noticks @tbs_right @tbs_tooltips @tbs_top @tbs_vert @tbsetbitmapsize @tbsetbuttonsize @tbsetbuttonstyle @tbsetlabels @tbsettip @tbtooltips @tbtop @tbtransparent @tbwrapable @tcn_getobject @tcn_keydown @tcn_selchange @tcn_selchanging "
db " @tcs_bottom @tcs_buttons @tcs_ex_flatseparators @tcs_ex_registerdrop @tcs_fixedwidth @tcs_flatbuttons @tcs_focusnever @tcs_focusonbuttondown @tcs_forceiconleft @tcs_forcelabelleft @tcs_hottrack @tcs_multiline @tcs_multiselect @tcs_ownerdrawfixed @tcs_raggedright @tcs_right @tcs_rightjustify @tcs_scrollopposite @tcs_singleline @tcs_tabs "
db " @tcs_tooltips @tcs_vertical @toolwindow @topmost @trans @transalpha @transhflip @transparent @transrotozoom @transscaled @transshadow @transvflip @treeview @ttf_absolute @ttf_centertip @ttf_di_setitem @ttf_idishwnd @ttf_rtlreading @ttf_subclass @ttf_track "
db " @ttf_transparent @ttn_getdispinfoa @ttn_getdispinfow @ttn_pop @ttn_show @tts_alwaystip @tts_balloon @tts_noanimate @tts_nofade @tts_noprefix @tvnbegindrag @tvnbeginlabeledit @tvnbeginrdrag @tvndeleteitem @tvnendlabeledit @tvngetdispinfo @tvngetinfotip @tvnitemexpanded @tvnitemexpanding @tvnkeydown "
db " @tvnselchanged @tvnselchanging @tvnsetdispinfo @tvnsingleexpand @tvscheckboxes @tvsdisabledragdrop @tvseditlabels @tvsfullrowselect @tvshasbuttons @tvshaslines @tvsinfotip @tvslinesatroot @tvsnohscroll @tvsnonevenheight @tvsnoscroll @tvsnotooltips @tvsrtlreading @tvsshowselalways @tvssingleexpand @tvstrackselect "
db " @typebfile @typebitfield @typebyte @typechar @typedialog @typedouble @typefile @typefloat @typeint @typeint64 @typememory @typepointer @typeschar @typestring @typesword @typeuint @typeuint64 @typeuser @typewindow @typeword "
db " @typewstring @uds_alignleft @uds_alignright @uds_arrowkeys @uds_autobuddy @uds_horz @uds_hottrack @uds_nothousands @uds_setbuddyint @uds_wrap @usedefault @usererror @vflip @vscroll @wparam @xaxis @yaxis @zaxis ",0

_endasm
LarryMc
Larry McCaughn
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

#### Andy

##### November 08, 2019, 04:16:30 am #2
Larry,

That's very interesting, will have a look, maybe that can help things.

I have replaced my array of words with a pointer, as always pointers are quicker or seem to be.

Thanks again.
Andy.

Day after day, day after day, we struck nor breath nor motion, as idle as a painted ship upon a painted ocean.

#### fasecero

##### November 08, 2019, 08:35:49 am #3
Wow Larry, that code is insane, amazing stuff, the _asm segments always confuse me . Here is one more way to do it, but it would require to change the logic of the current code, by using a custom dictionary (struct) and wrapping around 2 C-runtime functions, qsort and bsearch. In theory this code should be quick enough for huge arrays, even with millions of keywords (again, in theory  ), those runtime functions was developed for extreme performance.

Code Select
\$INCLUDE "windowssdk.inc"

CONST WORDSMAX = 12 ' number of keywords

TYPE DICTIONARY
INT key
string value
ENDTYPE

DICTIONARY Words[WORDSMAX+1]

OPENCONSOLE
PRINT
PRINT "[KEY, VALUE] ALPHABETICAL LIST"
PRINT
FillWords() ' Fill Keywords from non alphabetical DATA
SortWords() ' Sort Keywords in alphabetical order (requirement for searching using bsearch C-RUNTIME)
PrintWords() ' Show Keywords on the console

PRINT
PRINT "SEARCH EXAMPLES"
PRINT

string find = "AB"
int key = SearchKeyword(find) ' request a key for a keyword
PRINT "    " + find + " have the key: " + STR\$(key) + " - Value: " + Words[key].value

find = "BE"
key = SearchKeyword(find) ' request a key for a keyword
PRINT "    " + find + " have the key: " + STR\$(key) + " - Value: " + Words[key].value

find = "C"
key = SearchKeyword(find) ' request a key for a keyword
PRINT "    " + find + " have the key: " + STR\$(key) + " - Value: " + Words[key].value

find = "Z"
key = SearchKeyword(find) ' request a key for a keyword
PRINT "    " + find + " have the key: " + STR\$(key) + " - Value: " + Words[key].value

PRINT
PRINT "Press any key to exit"
DO:UNTIL INKEY\$ <> ""
CLOSECONSOLE

'-----------------------------------------------------------------------------------
' Search Keywords...
'-----------------------------------------------------------------------------------

SUB SearchKeyword(string keyword), INT ' return key ( -1 on failure )
DICTIONARY target
target.value = keyword

pointer v = &Words + 0 : v+ = LEN(target)
pointer result = bsearch(&target, v, WORDSMAX, LEN(target), &searchFunc)

IF result THEN
RETURN *<DICTIONARY>result.key
ENDIF

RETURN 0 ' error / no value was found
ENDSUB

DECLARE CDECL searchFunc(pointer a, pointer b),int

SUB searchFunc(pointer a, pointer b), INT
INT lenght = LEN(*<DICTIONARY>a.value)
string _left = LEFT\$(*<DICTIONARY>b.value, lenght)
RETURN strcmp(*<DICTIONARY>a.value, _left)
ENDSUB

'-----------------------------------------------------------------------------------
' Show Keywords on the console
'-----------------------------------------------------------------------------------

SUB PrintWords()
int j
FOR j = 1 TO WORDSMAX
PRINT "    " + STR\$(Words[j].key) + " " + Words[j].value
NEXT j
ENDSUB

'-----------------------------------------------------------------------------------
' Sort Keywords in alphabetical order
'-----------------------------------------------------------------------------------

SUB SortWords()
DICTIONARY k
k.key = 0

pointer v = &Words[1] + 0
qsort(v, WORDSMAX, LEN(k), &cmpFunc)

' reasign keys
int j
FOR j = 1 TO WORDSMAX
Words[j].key = j
NEXT j

Words[0].key = 0
Words[0].value = ""
ENDSUB

DECLARE CDECL cmpFunc(pointer a, pointer b),int

SUB cmpFunc(pointer a, pointer b), INT
return strcmp(*<DICTIONARY>a.value, *<DICTIONARY>b.value)
ENDSUB

'-----------------------------------------------------------------------------------
' Fill Keywords from DATA
'-----------------------------------------------------------------------------------

SUB FillWords()
RESTORE mydata
string temp

int j
FOR j = 1 TO WORDSMAX
GETDATA mydata, temp

Words[j].key = j
Words[j].value = temp
NEXT j
ENDSUB

DATABEGIN mydata
DATA "CALL", "BACKPEN", "BEGININSERTMENU", "ABS", "CASE&", "BASELEN"