RE: GCIC search/replace algorithm
"Rocky" <[email protected]>
| Newsgroups | gmane.comp.emulators.hercules390.vm |
|---|---|
| Message-ID | <[email protected]> |
You are designing an application for the replace function - I need a function for replace in the existing application No change in maps one line on the bottom for an error message and do the replace Undo is PF3 and start over - If you are worried then do a save before the change - or perhaps I can do an autosave - and maybe design a mechanism to reload from the last autosave.- that would be pretty ineffecient but doable. However that is not necesarily specific to the change function We need to replace the string -- It needs to be a small effecient routine What is the replace LOGIC when field two is bigger than field one.. Complete detailed LOGIC - Not generalities No new maps - one small error field You did not refer to the trunc issue - We are not on the same page here. Thnk about how about the logic of the replace. Not the application. We will get to that. Roc _____ From: [email protected] [mailto:[email protected]] On Behalf Of Mike Stramba Sent: Sunday, August 08, 2010 22:36 To: [email protected] Subject: [H390-VM] GCIC search/replace algorithm Roc, I have no experience in writing an editor, and haven't looked at your editor code yet .. :) But maybe my ideas will spark further discussion / thoughts. You also didn't mention *undo* :) .... a feature that eventually would be very nice ;), again I haven't looked at your code, so don't know if what I propose below is already implemented. Any editing of the file now (insert delete .. etc), can already be looked at as sort of a "search / replace", and if that's the case, then adding a REP(LACE) command might be easy(ier). My idea is to maintain a linked list or other table where any changes to the file are kept, regardless of search / replace .. user input .. DD, CC .. MM .. whatever. Then the display is updated with a combination of the original buffer / file and any changes that have occured at the current displayed position. Sounds complex, even as I write the description ;) A look through Source forge .. other public source for editors, might yield some other ideas Mike On 8/8/10, Rocky <[email protected] <mailto:rocsystems%40gmail.com> > wrote: > > Need an algorythm for the search/replace routine. > > Anybody have any experience with this or a well thought out sugestion. > > Issue is: > > We probably need a trunc command to tell us where to stop shifting > We need to know what to do if we find an impossibe situation > > My ideas is > > String2 replaces string1 > > If string 2 is shorter than string1 than pad with blanks and don't touch > anything else in the record. > > Same if string2 is equal in length to string1 without the padding > > If string 2 is greater it begins to get complicated. > > My thoughts are: > > If there are enough blanks immediately adjacent then use them as long as you > leave at least one blank > > if not enough blanks then find the first place that there are two blanks to > the right of the insert and shift up to 1 blank and then continue. > > Cannot eliminate blanks that are between Quotes "" or ' ' > Cannot shift past the trunc setting > > that is sort of the idea that I have but does anybody have some serious > thoughts on how to do this, or what the proper algorytm should be. > > Not a simple routine. The things we take for granted in x-edit or ispf edit > are not all that simple. > > What is the proper logic? Not the kind of routine that I want to write more > than once. > > Roc > > > > > > ------------------------------------ > > Yahoo! Groups Links > > > >