Would like to reformat a line

Product Compare Forums Multi-Edit User Created Macros Would like to reformat a line

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
  • #1326
    Leslie Satenstein

    Here is the challenge. When I detect a certain keyword as the first word on a line, I would like to retrieve the entire line into a string, (only 1 line for now), I would call a function that I would write to reformat that string, and then, I would like to replace the line with the reformatted string.

    It seems easy, but have not discovered how to do the get current line, then to replace it.

    Can someone point me to a cmac source that does it, or to a code fragment that does.

    Here is what I thought I needed.

    Tstr = Get_current_line();
    // i reformat Tstr then
    Replace_current_line(Tstr) ; // reformatted version


    Clay Martin

    Try this:
    /*reformat astring*/



    I would use GET_LINE and PUT_LINE, which are documented under HELP | CMAC LANGUAGE

    PUT_LINE will replace the current line with a string you supply.

    To search for a line starting with a keyword, you could set up a regular expression that searches for Beginning Of Line, Optional Whitespace, Keyword.

    (I’m not good at regular expressions, so I’m no help on the details. You also now get to choose between Multi-Edit classic regular expression syntax, or Unix regular expression syntax, or Perl regular expression syntax was recently added. And you could use Find_Text to search for the regular expression, setting the flags accordingly.)

    Ken Walker

    I concur, if you follow David’s suggestion, you’ll get something like this:
    void swapline
    str TStr;
    TStr = Get_Line;
    // yourreformat(TStr);


    Get_Line does not reposition the cursor, and Put_Line replaces the current line with the string passed to it.

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