+ Reply to Thread
Page 3 of 13 FirstFirst 12345 ... LastLast
Results 21 to 30 of 122

Thread: Subcode.vdm : The Macro Subroutines Project

  1. #21
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Hi Scott,

    I am rereading my message. In the meantime I did find the exact forum.vedit.refernce to your macro. Here it is,


    / Extract_Latex_Commands.vdm
    // by Scott Lambert, 2015-10-26 via forum.vedit.com
    // Needs_Help_In_Constructing-amslatex.vdf, Message 26.
    //
    //
    #10=buf_num
    #11=buf_free
    buf_switch(#11)
    file_open("|(user_home)\latex2e.txt")
    buf_switch(#10)
    goto_line(59)
    repeat(all) {
    search("* \",advance+noerr)
    if(return_value==0) {break}
    if(cur_line>=846) {break}
    block_begin(cur_pos)
    search("|S",noerr)
    if(return_value==0) {break}
    block_end(cur_pos)
    reg_copy_block(10,block_begin,block_end)
    buf_switch(#11)
    reg_ins(10)
    ins_newline(1)
    buf_switch(#10)
    }

    peter

  2. #22
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi Peter

    Attached is the getword.vdm subroutine. To test, execute the gwdemo.vdm, which calls getword.vdm. Also included is simple.tex which is the tex file I used for testing.

    Gwdemo just copies words to another buffer, you will know it is working... (don't use it on a test file over 90k)

    If file is a .tex file, it checks for a \ before the word

    If file is a .vdm file, it will grab words like reg_set, num_str, etc

    It will return filenames and URLs with their extension attached ie: simple.tex, vedit.com

    It handles words such as Peter's, I'm, you're, it's

    Note: Simple.tex comes from: https://en.wikibooks.org/wiki/LaTeX/simple.tex

    Test it on various file types and comment.

    Scott
    Attached Files Attached Files
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  3. #23
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Quote Originally Posted by Scott Lambert View Post
    Hi Peter

    Attached is the getword.vdm subroutine. To test, execute the gwdemo.vdm, which calls getword.vdm. Also included is simple.tex which is the tex file I used for testing.

    Gwdemo just copies words to another buffer, you will know it is working... (don't use it on a test file over 90k)

    If file is a .tex file, it checks for a \ before the word

    If file is a .vdm file, it will grab words like reg_set, num_str, etc

    It will return filenames and URLs with their extension attached ie: simple.tex, vedit.com

    It handles words such as Peter's, I'm, you're, it's

    Note: Simple.tex comes from: https://en.wikibooks.org/wiki/LaTeX/simple.tex

    Test it on various file types and comment.

    Scott
    Hi Scott,

    I did run your gwdemo.vdm on the file simple.tex. Spe cifically, I opened simple.tex in Vedit and then applied the menu command {Misc,Exec user macro, User_Macro\gwdemo.vdm}

    I ended up with e respectable column of strings . The first one was simple.tex, that is to say the name of the input file.

    I sure was glad to see strings like \adcdefg
    However the majority were just simple words. I did not have time to track them down. I could certainly identify some strings as arguments of Latex Commands, like document.

    Usually, I study new macros by opening them up in Vedit and then highlighting soem segment and executing them. This worked on your previous Extract_Latex_Command. However, I do not see how to do it for the gwdemo.vdm.

    Also just a thought. Would it be possible to rename getword.vdm to getword.sub ? Another renaming issue. You mentioned that you hope that Sub.vdm will be similar to MACRO-KEY.LIB . So, how about Subroutine.Lib ?

    Thanks as always,

    -peter

  4. #24
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Quote Originally Posted by rejto12 View Post
    Hi Scott,

    Usually, I study new macros by opening them up in Vedit and then highlighting soem segment and executing them. This worked on your previous Extract_Latex_Command. However, I do not see how to do it for the gwdemo.vdm.

    Also just a thought. Would it be possible to rename getword.vdm to getword.sub ? Another renaming issue. You mentioned that you hope that Sub.vdm will be similar to MACRO-KEY.LIB . So, how about Subroutine.Lib ?

    -peter
    Hi Scott,

    I would like to give you a progress report.

    I did go ahead and did rename your getword.vdm to getword.sub. Furthermore, I did put it into the newly created USER_MACRO\subroutines directory. It worked like a charm.

    Here are the details: I opened simple.tex in Vedit. Then I did run, {Misc, exec user macro}. When the user-mac directory window popped up I chose Show all files and clicked on the subroutines directory. Sure enough getword.sub popped up and I clicked on it.

    Also, running this subroutine highlighted a block in simple.tex. I removed the highlighting and moved the cursor manually. Then I called the subroutine again. This highlighted another block. So, I got a pretty good feeling about the action of the subroutine.

    So, now I see how the Addison Wiley stuff got into the file.
    In short the argument of the Latex \author{ } command can be anything. Ditto for the \title{} command.
    In other words, the property that something is an argument of a Latex command does not single out any specific words.

    I would say that for the moment let us forget about the arguments of a Latex command. Just collect Latex Commands.

    That is already a delicate problem. For example \begin{document} and \begin{equation} are two different Latex Commands.
    I would keep the curly braces. I tried to put them into latex.vdf and Scribe got angry.

    So, we should cal the output file simple.vdp, where vd stands for vedit and p for preliminary to simple.vdf. Where simple.vdf are
    the Latex commands in simple.tex in the sense of Scribe.

    In other words, Thank God for Subroutines. That is to say, I hope that on the subroutine level \begin{equation} is a perfectly good string, while on the latex.vdf level it is not.


    How does this sound to you ?

    -peter
    Last edited by rejto12; November 5th, 2015 at 02:59 PM. Reason: correct typos

  5. #25
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi Peter,

    Lets back up here a moment, we started this particular escapade, when you posted this:

    "Now, I would like to submit another subroutine. Specifically, the one that searches for a word. That is to say, for a string of letters."

    Now I feel I have done that with getword.vdm with the added bonus of how it gets a word is sensitive to the file type. gwdemo.vdm was just to show you that the subroutine worked. For example if you run it on a vdm file, you would see in the results things like reg_set, num_str, etc. However if you give the vdm file a txt extension, you will get reg, set, num,str on separate lines.

    Now if you agree I have fulfilled your original request above, I am unclear on why you requested such a subroutine and what sort of macro you thought it would be useful in.

    Basically getword.vdm gets a word from the buffer and puts it in t-reg 20, so what do you want a parent macro to do with the word?

    For example:

    "okay, the proposed macro gets a word from the buffer using the subroutine getword.vdm and determines if it is a tex command, and then....."

    Please complete the above for me.

    "In other words, Thank God for Subroutines. That is to say, I hope that on the subroutine level \begin{equation} is a perfectly good string, while on the latex.vdf level it is not."

    That is possible, but whether the subroutine handles that or the parent macro is still to determined. Note that is not what you originally requested, you said a string of letters.

    I am hoping to add getword to subcode.vdm, so one can call it like the other subroutines, but first want to make sure getword.vdm is complete and done.

    On your system you can name the files whatever you want. For myself personally the idea of .sub doesn't work for me, just individual preference.

    Scott
    Last edited by Scott Lambert; November 5th, 2015 at 04:02 PM.
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  6. #26
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311

    Your macro named Extract_Latex_Commands

    Quote Originally Posted by Scott Lambert View Post
    Hi Peter,

    Lets back up here a moment, we started this particular escapade, when you posted this:

    "Now, I would like to submit another subroutine. Specifically, the one that searches for a word. That is to say, for a string of letters."

    Now I feel I have done that with getword.vdm with the added bonus of how it gets a word is sensitive to the file type. gwdemo.vdm was just to show you that the subroutine worked. For example if you run it on a vdm file, you would see in the results things like reg_set, num_str, etc. However if you give the vdm file a txt extension, you will get reg, set, num,str on separate lines.

    Now if you agree I have fulfilled your original request above, I am unclear on why you requested such a subroutine and what sort of macro you thought it would be useful in.

    Basically getword.vdm gets a word from the buffer and puts it in t-reg 20, so what do you want a parent macro to do with the word?

    Scott
    Hi Scott,

    Originally, I wanted to adapt your Extract_Latex_Commands.vdm to the Berry definition of a Latex type (a) command. This says that it is a backslash followed by letters. In short, I wanted to replace the Search("|S") command by the search word subroutine.
    Once again you did a great job in guessing the definition of a Latex command. At that time I could not give it to you since I did not know it myself.

    Certainly, your subroutine accomplishes that and much more! How come I did not make this explicit in my previous message.

    Now comes the rub. Until I have seen the result of your subroutine, I believed that the Berry definition covers most of the Latex commands. I vaguely remember that Berry mentions some exceptional ones, which are easy to handle by hand. After seeing the result of your subroutine, I realized that I was wrong! In fact, now I believe that the majority of the Latex commands are of the form
    \ string of letters { string of letters } etc.

    That is to say, they are not of Berry type (a)
    In short, my idea of a Latex Command has changed !

    Now the question is where to go from here ? ( I am still very interested in getting a list of (general) Latex commands. )

    At the same time, I have a hunch that thanks to your generalized subroutine it would be possible to extract vedit commands.

    Here is my rough idea.

    Step 1:
    Copy the Alphabetic List Of Commands on the On-Line-Help file to a .txt file. Then copy the words of the form

    string of letters _ string of letters

    to file.

    Step 2.:
    Use the Command_Check command to check that the words are vedit commands indeed.

    If step 2 is too crude I still would like to have a list of command candidates. It is easy to check that an individual string is a command or not. In fact, based on your ideas I have written a Verify_Command_Cursor.vdm . In other words, I could do it individually. May it could be a subroutine in Step 2.

    Looking forward to hearing from you.


    -peer

  7. #27
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi Peter,

    Okay, I think I now know what you are looking for. Will write something and post it when ready.

    One question, command_check returns several values:

    0: not recognized
    1: a command / parameter (reg_set, num_str, append, insert, etc)
    2: a predined string value (user_home, user_macro, etc)
    3. config parameter (sr_non_english)

    So, when you say vedit command, do you mean returns not zero, or do you mean returns only 1 ??

    After some thought, I think to keep thing simple, we need one macro to deal with latex and one macro to deal with vedit commands. Try to handle both in one macro seem unnecessary complex. Will do the latex one first.
    (both will use getword subroutine)

    Scott
    Last edited by Scott Lambert; November 6th, 2015 at 10:07 AM.
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  8. #28
    Senior Member
    Join Date
    Nov 2014
    Location
    Minneapolis, MN
    Posts
    311
    Quote Originally Posted by Scott Lambert View Post
    Hi Peter,

    Okay, I think I now know what you are looking for. Will write something and post it when ready.

    One question, command_check returns several values:

    0: not recognized
    1: a command / parameter (reg_set, num_str, append, insert, etc)
    2: a predined string value (user_home, user_macro, etc)
    3. config parameter (sr_non_english)

    So, when you say vedit command, do you mean returns not zero, or do you mean returns only 1 ??

    After some thought, I think to keep thing simple, we need one macro to deal with latex and one macro to deal with vedit commands. Try to handle both in one macro seem unnecessary complex. Will do the latex one first.
    (both will use getword subroutine)

    Scott
    Hi Scott,

    "So, when you say vedit command, do you mean returns not zero, or do you mean returns only 1 ??"

    No, I meant return >0. My reason was that for Vedit these files are similar to vedit.vdf and this is the way you and Ted started. So, I did not wish to change notations midstream.

    At the same time, for latex files I would like to consider only commands and not arguments. Oops, this is up to Scribe and not us. So, this is my prfernce if it is OK with Mrs/MR Scribe.

    Now, I would like to give you a short progress report on the result of running your macro on the file simple.tex.

    I did run Scribe on the resulting file. It did flag only one word. It was something like specialises. Then I looked up specializes
    in the English dictionary. In other words it was a Britsh versus US spelling issue. I believe that the WinEdt website has a British English dictionary. I also believe that I have successfully used with one their dictionaries with Scribe.

    In short I did not learn any new words for latex.vdf.

    Speaking about WinEdt, I have downloaded some of my their dictionaries. Together with the recent .vdf files I have quite a few dictionaries in my Scribe directory. So, I would like to ask for a "dictionary" sub-directory.

    Finally, I was glad to learn that

    "Try to handle both in one macro seem unnecessary complex. Will do the latex one first.
    (both will use getword subroutine)"

    I think it is hard enough to handle one at a time. The main point is that they use the same subroutine.


    Looking forward to getting your new macro.

    Thanks as always.


    -peter

  9. #29
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Post deleted by Scott and reposted later in thread.
    Last edited by Scott Lambert; November 8th, 2015 at 07:45 AM.
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

  10. #30
    Senior Member
    Join Date
    Aug 2011
    Location
    British Columbia, Canada
    Posts
    383
    Hi Peter,

    Here is the Vedit Command Extractor Vecomex.vdm, which extracts Vedit related words from a file (does not need to have a vdm extension). Uses same version of getword.vdm as texcomex.vdm.

    It display a menu with 3 checkboxes and two buttons. The three checkboxes allow you to select the type of word: Command, String Value, Config Parameter. All boxes are checked by default.

    Once the types are selected, you clcik the start button to execute.

    Click ESC to exit and return to Vedit


    One interesting use for vecomex.vdm is in Vedit, goto the help menu, and select Macro command List, and then right-click on the right hand side list.

    If it opens in notepad or something other then Vedit, use the save-as function to save it to a text file and then open it in Vedit.

    If it opens in Vedit, you are good.

    Now execute vecomex.vdm on the file, you get all commands listed on that page of help system for your version of Vedit.

    Scott
    Attached Files Attached Files
    Using Vedit 6.21.3, (32 bit), dated 9/12/11 running on Windows 7 (64 bit).

+ Reply to Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts