Topic
8 replies Latest Post - ‏2013-05-03T16:40:04Z by llandale
tlwtheq
tlwtheq
50 Posts
ACCEPTED ANSWER

Pinned topic Handling Enumerated Types

‏2013-04-23T12:29:39Z |

Within my DXL script, how do I detect, per object, whether an enumerated type has multiple values?

And then how do I capture them for output, say, to an Excel cell?

Thanks,

Tara

  • llandale
    llandale
    2943 Posts
    ACCEPTED ANSWER

    Re: Handling Enumerated Types

    ‏2013-04-23T13:52:05Z  in response to tlwtheq

    [1] If an object has more than one enumerated selected? 
    [1a]Since Enumerated values cannot contain the EOL '\n' character, you can get the value of the obj-attr and searc for '\n':

    • Value = obj."NameMultiAttr"
    • if (Value contains '\n') ...

    [1b] You can get a handle on the AttrType, get a list of legal enumerations, then loop through the obj.attr value using isMember

    • if (isMember(obj.NameAttr, Enum[i])

    [2] There just HAS to be a better way, but years ago I came up with the following to export to MS-Word tables:

    • DesiredCellValue = whatever raw text I want in a cell
    • replace all '\n' characters in DesiredCellValue to a wierd holding pattern #1
    • replace all '\t' characters to a different holding pattern #2
    • Export to a Windows file.
    • "system" command for MS-Word to open that Window's file
    • Select the aprt that becomes the table, and convert it to a table
    • convert Holding pattern #1 back to '\n'
    • convert Holding patter #2 back to '\t'.

    I have a "converter" macro which has to be coordinated with the holding patterns in the DXL.

    Having some difficulty with rich-text, searing for "\par ' and \'tab ' etc.

    [2b] Now if you "export" by opening Word or Excel and using OLE Cut/Paste for each cell, then I don't think you need the holding pattern, since I think it works like this:

    • copy to Clipboard the cell value
    • get an OLE handle on a cell
    • paste from Clipboard into that cell

    None of my DXL does it that way however.

    -Louie

    • tlwtheq
      tlwtheq
      50 Posts
      ACCEPTED ANSWER

      Re: Handling Enumerated Types

      ‏2013-04-23T13:57:21Z  in response to llandale

      Yeah, I was looking at isMember as a possible solution.  I might do that and see how it turns out.

      Thanks, Louie!

  • BenSharples
    BenSharples
    7 Posts
    ACCEPTED ANSWER

    Re: Handling Enumerated Types

    ‏2013-05-02T09:16:22Z  in response to tlwtheq

    Most of my DXL exports to Excel I now use the OleMethod, OlePut, etc functions to paste direct to an Excel cell, which effectively requires a string as the input.

    Regardless of the number of selected enumerations, using the probeAttr_(obj, NameMultiAttr) will return the string with each selected enumeration separated by a \n character which Excel interprets fine and in the outputted sheet you will see each enumeration on new lines within the cell

    • llandale
      llandale
      2943 Posts
      ACCEPTED ANSWER

      Re: Handling Enumerated Types

      ‏2013-05-02T15:23:47Z  in response to BenSharples

      Oops forgot to mention:  My "exporters" create the file system file with "Stream", then open the file with the application <system("../winword.exe NameFileJustCreated.rtf")>; then I use Word macro to create the file.  Not sure this is "better" than the OLE method, but it is an order of magnitude faster.

      -Louie

      • Wolfgang Uhr
        Wolfgang Uhr
        207 Posts
        ACCEPTED ANSWER

        Re: Handling Enumerated Types

        ‏2013-05-02T15:56:28Z  in response to llandale

        Yes it is. And if you have your own invisible word in the background, the user is not disturbed by using his own word. You only have

        1. allways to create a word object
        2. to close all documents and quit the word before releasing the ole-object

        Best regards

        Wolfgang

        • llandale
          llandale
          2943 Posts
          ACCEPTED ANSWER

          Re: Handling Enumerated Types

          ‏2013-05-02T17:35:40Z  in response to Wolfgang Uhr

          ... and never have two scripts running at once and don't do any copy-cutting manually else you risk clobbering the system clip-board.

          You say the OLE method works with invisible Word target document?  Didn't know that.  That should speed things up considerably.

          -Louie

          My rich text exporter is indeed hopelessly convoluded; but I want the same routines to be able to send output to Attr-Values and Dialog Boxes as well.  Part of the problem is that I want a "summary" at the top of the file, that gets generated only after the entire body is finished.

          Thinking out loud: instead of replacements for TAB and EOL characters intended inside a cell I can have replacements for TAB and EOL characters that are the bounderies between the cells.  Accumulate everything in some Buffer, then the "exporter" reads the buffer, looking for these TAB and EOL replacement patterns to determine where to delimit the OLE copy-paste functions....

          • Wolfgang Uhr
            Wolfgang Uhr
            207 Posts
            ACCEPTED ANSWER

            Re: Handling Enumerated Types

            ‏2013-05-02T18:19:36Z  in response to llandale

            Hello Louie

            > You say the OLE method works with invisible Word target document?  Didn't know that.

            Yes it does, I have tested it. Word may be invisible and in may be a separate word session. Both works well. Doors does some export and the user can work on his document, but

            > ... and never have two scripts running at once and don't do any copy-cutting manually else you risk clobbering the system clip-board.

            You must not use the clippboard. That is impossible, because this is the feature for the user. You have to use the range object to insert data.

            It's a little script redesign ...

            Best regards

            Wolfgang

             

            • llandale
              llandale
              2943 Posts
              ACCEPTED ANSWER

              Re: Handling Enumerated Types

              ‏2013-05-03T16:40:04Z  in response to Wolfgang Uhr

              Sorry not following.  I'm suggesting you cannot have two instances of the script running at once due to clipboard conflicts ... and your response is?

              -Louie

              Mental note: "Range" Object.