Subscribe Bookmark RSS Feed

concatenate Check Box Lists

haloway13

Community Trekker

Joined:

Feb 12, 2013

How do I merge lists together?

nw = New Window( "Choose Columns", <<Modal,

       H List Box(

  V List Box (

  WH = Check Box ({WbSpdA,WbSpdS,WbLngthA,RwndTenA,RwndTenS,P11,P12,P15,P16,IG11,IG16,P21,P22,P25,

  P26,IG21,IG26,WH1A,WH1S,WH2A,WH2S,WH3A,WH3S,WH4A,WH4S,WH5A,WH5S,WH6A,WH6S,

  WH7A,WH7S,WH8A,WH8S,WH9A,WH9S,WH10A,WH10S,WH11A,WH11S,WH12A,WH12S,WH13A,WH13S,

  WH1M,WH2M,WH3M,WH4M,WH5M,WH6M,WH7M,WH8M,WH9M,WH10M,WH11M,WH12M,WH13M,Z1LHA,

  Z1LHS,Z1BHA,Z1BHS,Z1RHA,Z1RHS,Z2LHA,Z2LHS,Z2BHA,Z2BHS,Z2RHA,Z2RHS,Z3LHA,Z3LHS,

  Z3BHA,Z3BHS,Z3RHA,Z3RHS,Z4LHA,Z4LHS,Z4BHA,Z4BHS,Z4RHA,Z4RHS,Z5LHA,Z5LHS,Z5BHA,

  Z5BHS,Z5RHA,Z5RHS})),

  Z1 = Check Box ({Z1COTT,Z1COTP,Z1COTC,Z1COBT,Z1COBW,Z1COBA,Z1CDTT,Z1CDTW,Z1CDTA,Z1CDBT,Z1CDBW,

  Z1CDBA,Z1GOTT,Z1GOTP,Z1GOTC,Z1GOBT,Z1GOBW,Z1GOBA,Z1GDTT,Z1GDTW,Z1GDTA,Z1GDBT,

  Z1GDBW,Z1GDBA,Z1IOTT,Z1IOTP,Z1IOTC,Z1IOBT,Z1IOBW,Z1IOBA,Z1IDTT,Z1IDTW,Z1IDTA,

  Z1IDBT,Z1IDBW,Z1IDBA,Z1SOTT,Z1SOTP,Z1SOTC,Z1SOBT,Z1SOBW,Z1SOBA,Z1SDTT,Z1SDTW,

  Z1SDTA,Z1SDBT,Z1SDBW,Z1SDBA,Z1SVP,Z1IG1,Z1IG2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4CDTT,Z4CDTW,Z4CDTA,Z4CDBT,Z4CDBW,

  Z4CDBA,Z4GOTT,Z4GOTP,Z4GOTC,Z4GOBT,Z4GOBW,Z4GOBA,Z4GDTT,Z4GDTW,Z4GDTA,Z4GDBT,

  Z4GDBW,Z4GDBA,Z4IOTT,Z4IOTP,Z4IOTC,Z4IOBT,Z4IOBW,Z4IOBA,Z4IDTT,Z4IDTW,Z4IDTA,

  Z4IDBT,Z4IDBW,Z4IDBA,Z4SOTT,Z4SOTP,Z4SOTC,Z4SOBT,Z4SOBW,Z4SOBA,Z4SDTT,Z4SDTW,

  Z4SDTA,Z4SDBT,Z4SDBW,Z4SDBA,Z4SVP,Z4IG1,Z4IG2,Z4SVS,Z4JP,Z4CWT,Z4GWT,Z4IWT,Z4SWT}),

  Z5 = Check Box ({Z5COTT,Z5COTP,Z5COTC,Z5COBT,Z5COBW,Z5COBA,Z5CDTT,Z5CDTW,Z5CDTA,Z5CDBT,Z5CDBW,

  Z5CDBA,Z5GOTT,Z5GOTP,Z5GOTC,Z5GOBT,Z5GOBW,Z5GOBA,Z5GDTT,Z5GDTW,Z5GDTA,Z5GDBT,

  Z5GDBW,Z5GDBA,Z5IOTT,Z5IOTP,Z5IOTC,Z5IOBT,Z5IOBW,Z5IOBA,Z5IDTT,Z5IDTW,Z5IDTA,

  Z5IDBT,Z5IDBW,Z5IDBA,Z5SOTT,Z5SOTP,Z5SOTC,Z5SOBT,Z5SOBW,Z5SOBA,Z5SDTT,Z5SDTW,

  Z5SDTA,Z5SDBT,Z5SDBW,Z5SDBA,Z5SVP,Z5IG1,Z5IG2,Z5SVS,Z5JP,Z5CWT,Z5GWT,Z5IWT,Z5SWT}),

  Button Box("OK"),Button Box("Cancel"),

  )

);

How do I get a single list of the selected boxes in the format of:

'text1,text2,text3....,textN'

to be passed to a sp SQL call?

Thank you,

Tim Hall

2 REPLIES
asdfasdf

Community Trekker

Joined:

Aug 1, 2012

Maybe something like this you have in mind?


Clear Log();



flatten = function({item_list}, {Default Local},


    result = {};


    if(N Items(item_list) > 0,


        for(i = 1, i <= N Items(item_list), i++,


            subitem = item_list;


            if(!Is List(subitem),


                insert into(result, subitem),


                t = recurse(subitem);               


                insert into(result, t);


            );                           


        );


    );


    result;


);



callback = function({},


    b = Eval List({Z1 << get selected, Z2 << get selected,


        Z3 << get selected, Z4 << get selected});


    items = flatten(b);


    if(N Items(items) > 1,


        sql = "SELECT $VARS FROM TABLE";


        x = concat items(items, ", ");


        sql = munger(sql, 1, "$VARS", x);


        show(sql);       


    );


);



w = New Window("Choose Columns",


    V List Box(       


        H List Box(


            Panel Box("Z1",


                Z1 = Check Box({"Z1a", "Z1b", "Z1c", "Z1d", "Z1e", "Z1f"})


            ),


            Spacer Box(<< Size(30, 0)),


            Panel Box("Z2",


                Z2 = Check Box({"Z2a", "Z2b", "Z2c", "Z2d", "Z2e", "Z2f"})


            ),


            Spacer Box(<< Size(30, 0)),


            Panel Box("Z3",


                Z3 = Check Box({"Z3a", "Z3b", "Z3c", "Z3d", "Z3e", "Z3f"})


            ),


            Spacer Box(<< Size(30, 0)),


            Panel Box("Z4",


                Z4 = Check Box({"Z4a", "Z4b", "Z4c", "Z4d", "Z4e", "Z4f"})


            )               


        ),


        Spacer Box(<< Size(0, 20)),


        Button Box("Print selected", callback);   


    )


);



pmroz

Super User

Joined:

Jun 23, 2011

This might be a little cleaner.  Uses INSERTINTO to concatenate lists.

nw = New Window( "Choose Columns",

    <<Modal,

    H List Box(

        V List Box(

            WH = Check Box(

                {WbSpdA, WbSpdS, WbLngthA, RwndTenA, RwndTenS, P11, P12, P15, P16, IG11, IG16, P21, P22, P25, P26, IG21, IG26,

                WH1A, WH1S, WH2A, WH2S, WH3A, WH3S, WH4A, WH4S, WH5A, WH5S, WH6A, WH6S, WH7A, WH7S, WH8A, WH8S, WH9A, WH9S,

                WH10A, WH10S, WH11A, WH11S, WH12A, WH12S, WH13A, WH13S, WH1M, WH2M, WH3M, WH4M, WH5M, WH6M, WH7M, WH8M, WH9M,

                WH10M, WH11M, WH12M, WH13M, Z1LHA, Z1LHS, Z1BHA, Z1BHS, Z1RHA, Z1RHS, Z2LHA, Z2LHS, Z2BHA, Z2BHS, Z2RHA, Z2RHS,

                Z3LHA, Z3LHS, Z3BHA, Z3BHS, Z3RHA, Z3RHS, Z4LHA, Z4LHS, Z4BHA, Z4BHS, Z4RHA, Z4RHS, Z5LHA, Z5LHS, Z5BHA, Z5BHS,

                Z5RHA, Z5RHS}

            )

        ),

        Z1 = Check Box(

            {Z1COTT, Z1COTP, Z1COTC, Z1COBT, Z1COBW, Z1COBA, Z1CDTT, Z1CDTW, Z1CDTA, Z1CDBT, Z1CDBW, Z1CDBA, Z1GOTT, Z1GOTP,

            Z1GOTC, Z1GOBT, Z1GOBW, Z1GOBA, Z1GDTT, Z1GDTW, Z1GDTA, Z1GDBT, Z1GDBW, Z1GDBA, Z1IOTT, Z1IOTP, Z1IOTC, Z1IOBT,

            Z1IOBW, Z1IOBA, Z1IDTT, Z1IDTW, Z1IDTA, Z1IDBT, Z1IDBW, Z1IDBA, Z1SOTT, Z1SOTP, Z1SOTC, Z1SOBT, Z1SOBW, Z1SOBA,

            Z1SDTT, Z1SDTW, Z1SDTA, Z1SDBT, Z1SDBW, Z1SDBA, Z1SVP, Z1IG1, Z1IG2, Z1SVS, Z1JP, Z1CWT, Z1GWT, Z1IWT, Z1SWT}

        ),

        Z2 = Check Box(

            {Z2COTT, Z2COTP, Z2COTC, Z2COBT, Z2COBW, Z2COBA, Z2CDTT, Z2CDTW, Z2CDTA, Z2CDBT, Z2CDBW, Z2CDBA, Z2GOTT, Z2GOTP,

            Z2GOTC, Z2GOBT, Z2GOBW, Z2GOBA, Z2GDTT, Z2GDTW, Z2GDTA, Z2GDBT, Z2GDBW, Z2GDBA, Z2IOTT, Z2IOTP, Z2IOTC, Z2IOBT,

            Z2IOBW, Z2IOBA, Z2IDTT, Z2IDTW, Z2IDTA, Z2IDBT, Z2IDBW, Z2IDBA, Z2SOTT, Z2SOTP, Z2SOTC, Z2SOBT, Z2SOBW, Z2SOBA,

            Z2SDTT, Z2SDTW, Z2SDTA, Z2SDBT, Z2SDBW, Z2SDBA, Z2SVP, Z2IG1, Z2IG2, Z2SVS, Z2JP, Z2CWT, Z2GWT, Z2IWT, Z2SWT}

        ),

        Z3 = Check Box(

            {Z3COTT, Z3COTP, Z3COTC, Z3COBT, Z3COBW, Z3COBA, Z3CDTT, Z3CDTW, Z3CDTA, Z3CDBT, Z3CDBW, Z3CDBA, Z3GOTT, Z3GOTP,

            Z3GOTC, Z3GOBT, Z3GOBW, Z3GOBA, Z3GDTT, Z3GDTW, Z3GDTA, Z3GDBT, Z3GDBW, Z3GDBA, Z3IOTT, Z3IOTP, Z3IOTC, Z3IOBT,

            Z3IOBW, Z3IOBA, Z3IDTT, Z3IDTW, Z3IDTA, Z3IDBT, Z3IDBW, Z3IDBA, Z3SOTT, Z3SOTP, Z3SOTC, Z3SOBT, Z3SOBW, Z3SOBA,

            Z3SDTT, Z3SDTW, Z3SDTA, Z3SDBT, Z3SDBW, Z3SDBA, Z3SVP, Z3IG1, Z3IG2, Z3SVS, Z3JP, Z3CWT, Z3GWT, Z3IWT, Z3SWT}

        ),

        Z4 = Check Box(

            {Z4COTT, Z4COTP, Z4COTC, Z4COBT, Z4COBW, Z4COBA, Z4CDTT, Z4CDTW, Z4CDTA, Z4CDBT, Z4CDBW, Z4CDBA, Z4GOTT, Z4GOTP,

            Z4GOTC, Z4GOBT, Z4GOBW, Z4GOBA, Z4GDTT, Z4GDTW, Z4GDTA, Z4GDBT, Z4GDBW, Z4GDBA, Z4IOTT, Z4IOTP, Z4IOTC, Z4IOBT,

            Z4IOBW, Z4IOBA, Z4IDTT, Z4IDTW, Z4IDTA, Z4IDBT, Z4IDBW, Z4IDBA, Z4SOTT, Z4SOTP, Z4SOTC, Z4SOBT, Z4SOBW, Z4SOBA,

            Z4SDTT, Z4SDTW, Z4SDTA, Z4SDBT, Z4SDBW, Z4SDBA, Z4SVP, Z4IG1, Z4IG2, Z4SVS, Z4JP, Z4CWT, Z4GWT, Z4IWT, Z4SWT}

        ),

        Z5 = Check Box(

            {Z5COTT, Z5COTP, Z5COTC, Z5COBT, Z5COBW, Z5COBA, Z5CDTT, Z5CDTW, Z5CDTA, Z5CDBT, Z5CDBW, Z5CDBA, Z5GOTT, Z5GOTP,

            Z5GOTC, Z5GOBT, Z5GOBW, Z5GOBA, Z5GDTT, Z5GDTW, Z5GDTA, Z5GDBT, Z5GDBW, Z5GDBA, Z5IOTT, Z5IOTP, Z5IOTC, Z5IOBT,

            Z5IOBW, Z5IOBA, Z5IDTT, Z5IDTW, Z5IDTA, Z5IDBT, Z5IDBW, Z5IDBA, Z5SOTT, Z5SOTP, Z5SOTC, Z5SOBT, Z5SOBW, Z5SOBA,

            Z5SDTT, Z5SDTW, Z5SDTA, Z5SDBT, Z5SDBW, Z5SDBA, Z5SVP, Z5IG1, Z5IG2, Z5SVS, Z5JP, Z5CWT, Z5GWT, Z5IWT, Z5SWT}

        ),

        Button Box( "OK",

            wh_list = wh << get selected();

            z1_list = z1 << get selected();

            z2_list = z2 << get selected();

            z3_list = z3 << get selected();

            z4_list = z4 << get selected();

            z5_list = z5 << get selected();

         ),

        Button Box( "Cancel" ),

    )

);

all_list = {};

insertinto(all_list, wh_list);

insertinto(all_list, z1_list);

insertinto(all_list, z2_list);

insertinto(all_list, z3_list);

insertinto(all_list, z4_list);

insertinto(all_list, z5_list);