Community

    • Login
    • Search
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    UDL: folding code definitions that include ((EOL)) or similar

    Help wanted · · · – – – · · ·
    2
    4
    148
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • DIV-on-github
      DIV-on-github last edited by

      I would like to define a UDL in which the following would be detected as sets of four lines to be folded once only

      blah blah blah:
      blah: blah
      blah :blah blah
      END
      

      and

      >blah blah blah\
      blah \blah blah\
      blah\
      blah blah\ blah
      

      In the first example I can define the folding to start with “:” and finish with “END”, and I almost get what I want, but the trouble is that “:” occasionally appears in things like hardcoded paths in the code, so ideally I’d like to start with “:((EOL))”, but I haven’t been able to figure out the correct syntax to implement that.

      In the second example I want to start with “>”, and finish with ((EOL)) unless there is a \ immediately before the ((EOL)). I thought that perhaps this could be done using the comment functionality, but I wasn’t able to figure out the correct syntax to implement that either. Strictly speaking the “>” should be at the start of a line, but fortunately I don’t seem to have too many of those floating around elsewhere in the code.

      Thank-you in advance for any pointers.

      —DIV

      PeterJones 1 Reply Last reply Reply Quote 0
      • PeterJones
        PeterJones @DIV-on-github last edited by

        @DIV-on-github ,

        I’m not sure I fully understand what you want, so I won’t comment on specifics.

        However, the UDL code-folding capabilities are pretty “simplistic”, and what I think you’ve described sounds more complex than it can handle. Your best bet might be writing a plugin or a PythonScript which can code in the more complex rules that you’ve defined.

        Unfortunately, while there have been lots of example PythonScripts here on the forum, I don’t think I’ve seen one yet that implements code folding, so I cannot point you to an example. (There was another recent thread asking about code folding, and I was hoping one of our PythonScript experts was going to wade in with a solution, but I don’t remember any doing so.)

        1 Reply Last reply Reply Quote 1
        • DIV-on-github
          DIV-on-github last edited by DIV-on-github

          Hello, PeterJones.
          Thank-you for your input.
          I guess my examples were quite abstracted, as I wasn’t sure whether it might be tedious for readers if I made them longer.

          Maybe the following examples will help to illustrate what I meant.

          # The following continues across two lines.  
          >load filename=C:\Users\James James Morrison Morrison Witherby George Dupree\Important Docum\
          ents\user.prefs
          
          INITIALISE VARIABLES:
             SCALAR:
                a = 0
                q = 99
                END    # Closes SCALAR
             ARRAY:
                mVec = {1, 2, 3}
                nVec = {5, 6, 7}
                END    # Closes ARRAY
             END    # Closes INITIALISE VARIABLES
          
          >system run="J:/shared/debugTest.exe"
          
          COMMUNICATIONS:
             Mode = Normal
             Error log = c:\temp\oops.txt
             NETWORK:
                # More code here
                END    # Closes NETWORK
             END    # Closes COMMUNICATIONS
          
          >update
          
          # More code here
          
          >update
          >write output=c:/temp/allOutputs.data mode=verbose format=\
          csv overwrite=true underwrite=false sideswipe=maybe notifyadmin\
          =true
          # The above continues across three lines, and is preceded by a single-line command.  
          

          A few points to note:
          The two types of syntax may be mutually exclusive (in the example above, at any rate), and are not nested in the above example.
          However, the colon–END syntax does often nest. Also, in that syntax the head ‘words’ are sometimes phrases with spaces. Notice that the line

          Error log = c:\temp\oops.txt
          

          contains an embedded colon that shouldn’t be interpreted as the start of a code-folding snippet. And there are a few colons I threw in elsewhere too.

          In the “>” command syntax a backslash at the end of a line means that the command continues to the following line.
          But notice that there may be many other backslashes elsewhere in the example code that should be read literally.

          I take your point that the UDL is a compromise between functionality and user-friendliness. In other words, it’s relatively easy to implement, but cannot do everything that one could imagine.
          I suspect it would be quite challenging for me to write a plugin or a PythonScript ‘from scratch’, and for my current purposes I don’t think it’d be worth the hours, days or weeks of time I’d need to put in to get a useful outcome.
          However, if anyone does have an idea of how to do it in UDL, or if they have an existing plugin/script built for a somewhat similar purpose that I could merely ‘tweak’, then that’d be of interest.

          —DIV

          DIV-on-github 1 Reply Last reply Reply Quote 0
          • DIV-on-github
            DIV-on-github @DIV-on-github last edited by

            For reference, the syntax is CFX Command Language (CCL), as used in several ANSYS applications, including session files for CFX-Pre and CST files for CFD Post.
            The colon–END syntax is called CCL “Simple Syntax” (for defining objects, including their constituent parameters).
            The lines starting with “>” are CCL “action line” syntax.
            There can also be lines of Perl code embedded in the same script file, which would start with “!” and are called “Power Syntax” (not included in the above example).

            1 Reply Last reply Reply Quote 0
            • First post
              Last post
            Copyright © 2014 NodeBB Forums | Contributors