Skip to main content
Tek Ileri
New Participant
Dec 11, 2023 1:30 AM UTC

Multivalue dictionaries

I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

Say:

Field<1> is 123a1]456b2]789c9

I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

 I want LIST FILE F1 TEST2 to show:

FILE     F1………         TEST2………

1          123a1               a1
2          456b2               b2
3          789c9               c9

 But what I'm getting is:
LIST FILE F1 TEST2

FILE     F1………         TEST2………
1          123S1               S1
2          456S2               456S2
3          789L9               789L9

I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

Tek.



------------------------------
Tek Ileri
Rocket Forum Shared Account
------------------------------

    9 replies

    Neil Morris
    Rocketeer
    Dec 11, 2023 10:23 AM UTC

    I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

    Say:

    Field<1> is 123a1]456b2]789c9

    I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

    Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

     I want LIST FILE F1 TEST2 to show:

    FILE     F1………         TEST2………

    1          123a1               a1
    2          456b2               b2
    3          789c9               c9

     But what I'm getting is:
    LIST FILE F1 TEST2

    FILE     F1………         TEST2………
    1          123S1               S1
    2          456S2               456S2
    3          789L9               789L9

    I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    Is the format of the data consistent as described in your example? Always 3 numeric followed by an alpha? 

    Or is the number of numeric characters beginning the string random? 



    ------------------------------
    Neil Morris
    Universe Advanced Technical Support
    Rocket Software
    ------------------------------
    Brian Speirs
    Participating Frequently
    Dec 11, 2023 1:58 PM UTC

    Is the format of the data consistent as described in your example? Always 3 numeric followed by an alpha? 

    Or is the number of numeric characters beginning the string random? 



    ------------------------------
    Neil Morris
    Universe Advanced Technical Support
    Rocket Software
    ------------------------------

    OpenQM has the MATCHFIELDS function to handle this situation - but UniVerse doesn't.

    I suspect you will need to put this into a subroutine to successively process each multi-value, and then call that subroutine using the SUBR function.

    Cheers,

    Brian



    ------------------------------
    Brian Speirs
    Senior Analyst - Information Systems
    Rush Flat Ltd
    Wellington NZ
    ------------------------------
    Thomas Ludwig
    Participating Frequently
    Dec 11, 2023 3:16 PM UTC

    I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

    Say:

    Field<1> is 123a1]456b2]789c9

    I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

    Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

     I want LIST FILE F1 TEST2 to show:

    FILE     F1………         TEST2………

    1          123a1               a1
    2          456b2               b2
    3          789c9               c9

     But what I'm getting is:
    LIST FILE F1 TEST2

    FILE     F1………         TEST2………
    1          123S1               S1
    2          456S2               456S2
    3          789L9               789L9

    I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    I usually create a SB/XA Correlative with the SB/XA Expression Syntax, and look what SB/XA creates for a OE Correlative.
    In this case I created a Correlative called FIELD1 with the following Syntax:
    (<1>[4,2])

    what means take the Value of attribute 1 from Index 4 for 2 characters.
    This Creates an Universe  Correlative with the following Values

    0001 A              
    0002 0              
    0003 F1             
    0004                
    0005               
    0006                
    0007                
    0008 F;1;C4;C2;[]   
    0009 L              
    0010 5             

    When I now call LIST FLAGFILE FIELD1 I get the output as you want.

    hope this helps.

    Thomas



    ------------------------------
    Thomas Ludwig
    System Builder Developer
    Rocket Forum Shared Account
    ------------------------------
    Tek Ileri
    Tek IleriAuthor
    New Participant
    Dec 11, 2023 10:59 PM UTC

    I usually create a SB/XA Correlative with the SB/XA Expression Syntax, and look what SB/XA creates for a OE Correlative.
    In this case I created a Correlative called FIELD1 with the following Syntax:
    (<1>[4,2])

    what means take the Value of attribute 1 from Index 4 for 2 characters.
    This Creates an Universe  Correlative with the following Values

    0001 A              
    0002 0              
    0003 F1             
    0004                
    0005               
    0006                
    0007                
    0008 F;1;C4;C2;[]   
    0009 L              
    0010 5             

    When I now call LIST FLAGFILE FIELD1 I get the output as you want.

    hope this helps.

    Thomas



    ------------------------------
    Thomas Ludwig
    System Builder Developer
    Rocket Forum Shared Account
    ------------------------------

    Thanks Thomas,
    Very close.  Unfortunately the the data is not consistent.  That is why I was trying to use the MATCHFILED function of 0N0X.  It's basically a string of numbers, a single alpha, and more numbers including a decimal point in the second set of numbers, sometimes .  I need to display the alpha and numbers after the alpha including any decimal points.  It would be nice to modify your suggestion to replace the C4 with a way to index the location of the alpha in the field.  I tried a few things to no avail.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------
    Thomas Ludwig
    Participating Frequently
    Dec 12, 2023 1:50 AM UTC

    Thanks Thomas,
    Very close.  Unfortunately the the data is not consistent.  That is why I was trying to use the MATCHFILED function of 0N0X.  It's basically a string of numbers, a single alpha, and more numbers including a decimal point in the second set of numbers, sometimes .  I need to display the alpha and numbers after the alpha including any decimal points.  It would be nice to modify your suggestion to replace the C4 with a way to index the location of the alpha in the field.  I tried a few things to no avail.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    Okay, this makes it a bit more complicated.

    Unfortunately for this expression SB/XA doesn't create an OE-Correlative  which is usab le withoult SB/XA installed, but I explain how it worked anyway - maybe you get an idea how it could work. (I'm not good in writing UV-Correlatives my own)

    I could manage it by createing an additional helper field.

    Lets assume we have a file "FLAGFILE" WITH 2 Items 

    Item A -> Attribute 1 = 1234A665

    Item B -> Attribute 1 = 123G56

    The Helper Field got the SB# Expression: (REPL(OCONV(<1>,"MCA"),"_",<1>))

    Which basically replaces the non-numeric part of the whole string with an Underscore.  (assuming there is only one Character)

    I called The helper Field "FELD4"

    The Results are Item A: 1234_665 ; ItemB: 123_56

    The coresponding OE-Correlativ unfortunately looks  a bit weird - so you can not use it without SB/XA installed.

    As a Second Step I created the Field for splitting the string and get the first part.
    The SB/XA Expression looks like this:  (OCONV(FELD4,"G0_1"))
    Which basically returns all characters before the first "_" in the helper field.
    The created OE-Correlative unfortunately looks same weird as the one for the helper field, but in the end it worked...
    Unfortunately Im not good in writing OE-Correlatives but maybe you get an idea how to manange the two steps on your own with UV-Correlative's
    - Replace any character with a fixed string (e.g. "_")
    - Do a Group-Extraction on the fixed string
    greetings
    Thomas


    ------------------------------
    Thomas Ludwig
    System Builder Developer
    Rocket Forum Shared Account
    ------------------------------
    Mark Vander Veen
    Participating Frequently
    Dec 12, 2023 7:40 AM UTC

    I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

    Say:

    Field<1> is 123a1]456b2]789c9

    I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

    Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

     I want LIST FILE F1 TEST2 to show:

    FILE     F1………         TEST2………

    1          123a1               a1
    2          456b2               b2
    3          789c9               c9

     But what I'm getting is:
    LIST FILE F1 TEST2

    FILE     F1………         TEST2………
    1          123S1               S1
    2          456S2               456S2
    3          789L9               789L9

    I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    This should work for you.  If you're hitting a field in another file you can use OCONV(FILENAME;X2;1;1).

    I

    @RECORD<1,2>

    Test

    5L

    S



    ------------------------------
    Mark Vander Veen
    Project Leader, System Administrator
    University of Chicago Distribution Center
    Chicago IL US
    ------------------------------
    Tyrel Marak
    Participating Frequently
    Dec 12, 2023 10:49 AM UTC

    I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

    Say:

    Field<1> is 123a1]456b2]789c9

    I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

    Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

     I want LIST FILE F1 TEST2 to show:

    FILE     F1………         TEST2………

    1          123a1               a1
    2          456b2               b2
    3          789c9               c9

     But what I'm getting is:
    LIST FILE F1 TEST2

    FILE     F1………         TEST2………
    1          123S1               S1
    2          456S2               456S2
    3          789L9               789L9

    I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    You could also try something like this in your I-Type

    IFS(EQS(FIELDS(WHOLE,'A',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'B',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'C',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'D',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'E',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'F',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'G',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'H',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'I',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'J',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'K',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'L',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'M',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'N',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'O',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'P',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'Q',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'R',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'S',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'T',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'U',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'V',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'W',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'X',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'Y',2,1),REUSE('')),IFS(EQS(FIELDS(WHOLE,'Z',2,1),REUSE('')),WHOLE,CATS(REUSE('Z'),FIELDS(WHOLE,'Z',2,1))),CATS(REUSE('Y'),FIELDS(WHOLE,'Y',2,1))),CATS(REUSE('X'),FIELDS(WHOLE,'X',2,1))),CATS(REUSE('W'),FIELDS(WHOLE,'W',2,1))),CATS(REUSE('V'),FIELDS(WHOLE,'V',2,1))),CATS(REUSE('U'),FIELDS(WHOLE,'U',2,1))),CATS(REUSE('T'),FIELDS(WHOLE,'T',2,1))),CATS(REUSE('S'),FIELDS(WHOLE,'S',2,1))),CATS(REUSE('R'),FIELDS(WHOLE,'R',2,1))),CATS(REUSE('Q'),FIELDS(WHOLE,'Q',2,1))),CATS(REUSE('P'),FIELDS(WHOLE,'P',2,1))),CATS(REUSE('O'),FIELDS(WHOLE,'O',2,1))),CATS(REUSE('N'),FIELDS(WHOLE,'N',2,1))),CATS(REUSE('M'),FIELDS(WHOLE,'M',2,1))),CATS(REUSE('L'),FIELDS(WHOLE,'L',2,1))),CATS(REUSE('K'),FIELDS(WHOLE,'K',2,1))),CATS(REUSE('J'),FIELDS(WHOLE,'J',2,1))),CATS(REUSE('I'),FIELDS(WHOLE,'I',2,1))),CATS(REUSE('H'),FIELDS(WHOLE,'H',2,1))),CATS(REUSE('G'),FIELDS(WHOLE,'G',2,1))),CATS(REUSE('F'),FIELDS(WHOLE,'F',2,1))),CATS(REUSE('E'),FIELDS(WHOLE,'E',2,1))),CATS(REUSE('D'),FIELDS(WHOLE,'D',2,1))),CATS(REUSE('C'),FIELDS(WHOLE,'C',2,1))),CATS(REUSE('B'),FIELDS(WHOLE,'B',2,1))),CATS(REUSE('A'),FIELDS(WHOLE,'A',2,1)))

    I know it's ugly, but it should work.  It's even uglier if you allow upper-case AND lower-case.  The above only assumes upper-case.

    WHOLE is a D-Type
    00 WHOLE
    01 D
    02 1
    03
    04
    05 20L
    06 M

    ------------------------------
    Tyrel Marak
    Technical Support Manager
    Aptron Corporation
    Florham Park NJ US
    ------------------------------

    Brian Speirs
    Participating Frequently
    Dec 12, 2023 1:36 PM UTC

    I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

    Say:

    Field<1> is 123a1]456b2]789c9

    I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

    Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

     I want LIST FILE F1 TEST2 to show:

    FILE     F1………         TEST2………

    1          123a1               a1
    2          456b2               b2
    3          789c9               c9

     But what I'm getting is:
    LIST FILE F1 TEST2

    FILE     F1………         TEST2………
    1          123S1               S1
    2          456S2               456S2
    3          789L9               789L9

    I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    As I noted yesterday, the best way to do this is via a subroutine, and the SUBR function. Here is the subroutine:

    SUBROUTINE XXTRACT(ans, indata, pattern, elno)
    *****************************************************************************
    ans = ''
    dcv = DCOUNT(indata<1>, @VM)
    FOR vno = 1 TO dcv
      adata = indata<1, vno>
      aval = MATCHFIELD(adata, pattern, elno)
      ans<1, vno> = aval
    NEXT vno
    
    RETURN
    END

    And to use this, create a dictionary like this:

    I
    SUBR('XXTRACT', F1, '0N0X', 2)
    
    XTract
    7L
    M

    This should do exactly what you want.

    HTH

    Brian



    ------------------------------
    Brian Speirs
    Senior Analyst - Information Systems
    Rush Flat Ltd
    Wellington NZ
    ------------------------------

    Martin Shields
    Participating Frequently
    Dec 12, 2023 4:07 PM UTC

    I need to create a dictionary that takes the multivalue data from a field in FILE, field<1>

    Say:

    Field<1> is 123a1]456b2]789c9

    I want a dictionary item, say called TEST2 to show only  (a1,b2,c9)

    Currently i have the Dictionary item TEST2 as I-type with MATCHFIELD(@RECORD<1>,"0N0X",2) in field 2

     I want LIST FILE F1 TEST2 to show:

    FILE     F1………         TEST2………

    1          123a1               a1
    2          456b2               b2
    3          789c9               c9

     But what I'm getting is:
    LIST FILE F1 TEST2

    FILE     F1………         TEST2………
    1          123S1               S1
    2          456S2               456S2
    3          789L9               789L9

    I've tried a number of options in the TEST2 dictionary item but no joy.  Can anyone help with this.  I had done something similar decades ago, but cannot remember how.  I want to avoid using a subroutine if I can.  Any advice would be greatly appreciated.

    Tek.



    ------------------------------
    Tek Ileri
    Rocket Forum Shared Account
    ------------------------------

    There are a number of suggestions below, but here's my option. In the UV home directory create the following entry in APP.PROGS:

         1111
    0001 SUBROUTINE U1111(ANS,STATUS,DATA,TYPE)
    0002 $OPTIONS DEFAULT
    0003 vmcnt = dcount(DATA<1>,@VM)
    0004 ANS = ''
    0005 for i = 1 to vmcnt
    0006    ANS<i> = DATA<1,i>[index(DATA<1,i>,oconv(DATA<1,i>,'MCA')[1,1],1),len(DATA<1,i>)]
    0007 next i
    0008 STATUS = 0
    0009 RETURN
    0010 END

    Compile and globally catalog this as follows:

    BASIC APP.PROGS 1111
    CATALOG APP.PROGS $1111 1111

    Finally, create the following dictionary for your file:

         A1
    0001 I
    0002 OCONVS(@RECORD<1>,'U1111')
    0003
    0004
    0005 10L
    0006 M

    Now, when you use this dictionary you get the result you want (if I understand what you're after):

    LIST TESTFILE F1 A1 08:06:47am  13 Dec 2023  PAGE    1
    TESTFILE...................... F1............. A1........
    
    0001                           0A10            A10
                                   04B9.80         B9.80
                                   123Z56568       Z56568



    ------------------------------
    Martin Shields
    Senior Technical Consultant
    Meier Business Systems PTY LTD
    Carnegie VIC AU
    ------------------------------