Robert Purves wrote: > > >Hi, > > > >Here is a possible entry for searching an edit field: > > >begin enum = 1 > >_searchBtn > >_quitBtn > >_startBtn > >_caseBtn > >_allBtn > >end enum > > Nice routine. > I think you should remove that "=" character. Otherwise _searchBtn turns out (with general shock and horror) to be 0, which cannot be what you intend. Also, it will not work with the Appearance runtime, in which a button 0 is flagged as an error. > thanks, I have overlooked that. I have overlooked also that the uppercased text handle is created each time the routine is called, which is not so cool in a search all process. Here is another version that creates only once that handle: /* Searching field. This demo is supposed to search an edit field for a given string. The search can be performed from the start of the text or from the current position of the insertion point, it can be case sensitive or not, and finally you can choose to search for a single match or all matches. Alain { 23/11/01 } */ begin enum 1 _searchBtn _quitBtn _startBtn _caseBtn _allBtn end enum local fn doBuildWindow dim as str255 myStr myStr = "Visit www.stazsoftware.com for the hottest news! " myStr += "or you can mail staz at <mailto:staz@...>" + chr$(13) myStr += "European residents may wish to visit www.euro.futurebasic.com " myStr += "or get info at <mailto:alain@...>" window 1,"Searching test" edit field 1, myStr , (10, 10)-(400,100), _noFramed setselect 0,0 edit field 2, "mail", (10,110)-(200,130), _framed button _searchBtn,_activeBtn,"Search" ,(100,140)-(200,160),_push button _quitBtn ,_activeBtn,"Quit" ,( 10,140)-( 80,160),_push button _startBtn ,_activeBtn,"From Start" ,(100,170)-(250,185),_checkbox button _caseBtn ,_activeBtn,"Case Sensitive",(100,190)-(250,205),_checkbox button _allBtn ,_activeBtn,"Search All" ,(100,210)-(250,225),_checkbox end fn /* input: id: FB edit field ID toSearch: the string to search found: starting position for the search (0 = at top) casing: true = case sensitive, false = not case sensitive upTxtHP: pointer to the handle to the uppercased text output: found: offset from start of the text where the searched string has been found. If no match, return -1 Note: the calling routine is responsible for the disposing of the uppercased text handle */ local mode local fn SearchField( id as long, toSearch as str255, found as long , casing as boolean, @upTxtHP as ptr ) dim teH as ..TERec dim @ txtH as handle teH = tehandle( id ) if teH = _nil then found = -1 : exit fn txtH = teH..hText long if casing = _false long if upTxtHP.nil& = _nil long if fn HandToHand( txtH ) = _noErr UpperCaseText( [txtH], fn GetHandleSize( txtH ), _smCurrentScript ) upTxtHP.nil& = txtH xelse found = -1 : exit fn end if xelse txtH = upTxtHP.nil& end if UpperCaseText( @toSearch[1], toSearch[0], _smCurrentScript ) end if found = fn Munger( txtH, found, @toSearch[1], toSearch[0], _nil, _nil ) end fn = found local fn doSearch dim as long where, strLen dim as str255 toSearch dim as boolean casing, searchAll dim as handle @ ucaseTxtH toSearch = edit$( 2 ) strLen = toSearch[0] long if strLen select button(_startBtn) case _activeBtn : where = {[teHandle(1)]+ _teSelStart} case _markedBtn : where = 0 end select casing = ( button( _caseBtn ) == _markedBtn ) searchAll = ( button( _allBtn ) == _markedBtn ) ucaseTxtH = _nil edit field 1 do where = fn SearchField( 1, toSearch, where ,casing , ucaseTxtH ) long if where > -1 setselect where, where + strLen where += strLen delay _sec end if until where = -1 or searchAll = _false if ucaseTxtH != _nil then DisposeHandle( ucaseTxtH ) xelse beep end if end fn local fn doDialog dim as long evt, ref evt = dialog(0) ref = dialog(evt) select evt case _btnClick select ref case _searchBtn : fn doSearch case _quitBtn : gFBQuit = _zTrue case _startBtn, _caseBtn, _allBtn button ref, 1 + usr abs( button( ref ) != _markedBtn ) end select end select end fn // main test fn doBuildWindow on dialog fn doDialog do handleevents until gFBQuit -- Cheers Alain ----------------------------------------------------- FB^3 in Europe: http://euro.futurebasic.com/ FB II Pouch: http://www.pixmix.com/FB/outils.html -----------------------------------------------------