Search Backward Options

Product Compare Forums Multi-Edit Support Search Backward Options

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #2933
    Notebooker
    Participant

    I am using an older version right now. ME9.0e that seems to do the job pretty well.

    My goal is for a way to search backwards with a regular expression using a shortcut key. For example, I enter a regular expression (^0) to find a "0" in the first column through the standard Search dialog and click "Search" to find the first occurrence. I can then find the next one with a short-cut key for "Find Again".

    With a regular expression however, I have found no easy way to "Find Again" backwards. I know I can pull up the dialog and do an ALT-B and hit search again, but I would like to reduce it to a single keystroke forward or backwards if I could.

    If I am not using a regular expression it works fine with the "Search Word Backward" command that I have mapped to CTL-Up keys.

    Is there a way to make this "Search Word Backward" command use a regular expression? I noticed that the actual command is "SearchWord /D=1" (and just "SearchWord" for forward direction). I could not find any documentation on this command. Does any exist?

    I have played a little bit with the Find_Text macro function. That one does take a regular expression and searches backward, but I’m not sure how to pass in the current regular expression being searched for.

    I have also tried to map the regular search dialog to set or unset "Backward Search" to a macro and continue on. Actually while I was writing this post just now, I got this working somewhat. I can now hit a key sequence to call a macro that pulls up the default search dialog, reverses the setting for "Backward Search", then continue on with shortcut keystrokes (ctl-N for for my keymap) to get the next matches in that direction. This should be workable, it would be a little bit better though if I could do it with just one shortcut keystroke for forward and another shortcut for backward, like the "Search Word Forward" and "Search Word Backward" commands handle it.

    By the way, can anyone tell me how to use "Search–> Complete–> Backward Search (Ctrl+,)? I have experimented and read the doc but cannot figure out what it is trying to do exactly. Sometimes it inserts a double of the word at the cursor, sometimes not.

    Thanks!

    #9485
    Clay Martin
    Keymaster

    Hi,
    I’ll start with the search complete question. The purpose of that function is to be able to complete a word based on the same word being in the existing file for instance:

    [code:3c7bc37x]*– PROGRAM FILE ————————————————————-
    * Application:
    * Description:
    * File Name: test.prg
    * Author: Tester:
    * Date created: 2/15/2012

    clay
    #INCLUDE "clude.CH" //
    [/code:3c7bc37x]

    If you placed your cursor after the clay on the line above the #include line. Then typed desc. Would look like this

    [code:3c7bc37x]*– PROGRAM FILE ————————————————————-
    * Application:
    * Description:
    * File Name: test.prg
    * Author: Tester:
    * Date created: 2/15/2012

    clay desc
    #INCLUDE "clude.CH" //
    [/code:3c7bc37x]

    Then if you selected Search-Complete-Backward search (or used the keystroke associated with it) you would get this result:
    [code:3c7bc37x]*– PROGRAM FILE ————————————————————-
    * Application:
    * Description:
    * File Name: test.prg
    * Author: Tester:
    * Date created: 2/15/2012

    clay Description
    #INCLUDE "clude.CH" //
    [/code:3c7bc37x]

    Thus we completed the word without typing it all out. This might be most useful writing code with long variable names, used line after line. Thus you could start typing xpoi and complete the variable name from a reference above or below the line to get: xpoint_long_name_cause_of_qca.

    The search again function will always search in the last direction set in the search options for the last search you made.

    Search word backwards allows you to have your cursor in front of a word (words are determined by being surrounded by a character listed in the word delimits) the first time you execute search word backwards it will highlight the word in front of the cursor. executing a second time will find that word backwards of the cursor location.

    As for coding a macro using Find_Text, there will be a Global Variable that holds the last search phrase, and what type of search (regular expression or not). You can find out what these variables are by looking at RepSrch (search again) in the search.s file the search.sh file may be useful too. You may even be able to copy (rename of course) RepSrch and modify it to operate like you want similar to find word backwards.

    Hope this helps,
    Clay

    #9486
    Notebooker
    Participant

    Thanks Clay. That was extremely helpful! That completion capability is something I think I’ll use a LOT.

    I’ve got the search working the way I need it now. As you suggested, I looked at search.s and found the flags I needed to set for reverse. Working great now!

    One problem however on this version (9.0e) is that I seem to have to recompile my macros every time I reload. I was reading the solution for the help macro recompile. Thankfully I’ve got Help working now but even with that I have to recompile each time I call up a new session. I tried the instructions to compile it again a certain way that is supposed to make it permanent, but I still have to recompile.

    Any ideas on this?

    Thanks!

    #9487
    Notebooker
    Participant

    Looks like I got a partial answer to this one.

    I did the rebuild macro library followed by recompile macro source from the Start –> multi-edit menu and it solved part of the problem. (It didn’t work until I was out of Multi-Edit though).

    It did not totally resolve my new source files from the need of being recompiled each time. So I transferred my source to the standard Search.s and did the rebuild library and recompile macro source. Now I don’t have to recompile for each session.

    I wonder if I am missing something though, that caused it not to become permanent when I was using my own source file.

    Thanks!

    #9488
    Clay Martin
    Keymaster

    Hi,
    The rebuild macro library is what is needed when you modify one of the standard code libraries (like search.s or one of the other major source files), but when you are using a macro from your own macro file you need to load that file in one of the startup.cfg or startup2.cfg files. See this post:
    viewtopic.php?f=3&t=63457&p=99724

    Or you need to call the macro with the full name, like mymacfile^mymacfunction. Where the macro you want is mymacfunction and it was compiled from the file mymacfile.s

    Thanks,
    Clay

    #9489
    Notebooker
    Participant

    Hey! It worked! Thanks again.

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.