What data type is suitable?

Discussion in 'Cadence' started by I-F AB, Mar 26, 2009.

  1. I-F AB

    I-F AB Guest

    Hi everyone,

    I have a GUI which has a varying number of fields ( I've used
    hiAddFields() & hiDeleteFields() ).
    From the data I get, I can create a list of these fields or a list of
    their values such as:
    ( LyrX1 HaloX1 LayTyp1 LyrX2 HaloX2 LayTyp2 LyrX3
    HaloX3 LayTyp3 ) ;fieldname
    ( "met2" 0.3 "dmy" "diff" 0.5 "excl"
    "via3" 0.8 "excl" ) ;value

    This data is actually showing that for every 1 layer, it has 2 other
    corresponding properties.
    If it's just 1 property for 1 layer, I'd think of using disembodied
    property lists.

    Is there a way to store the data into something like below?
    LStore(1) -> LyrX1 /*OR*/ LStore(1) -> Layer ;gives "met2"
    LStore(3) -> HaloX3 /*OR*/ LStore(3) -> Halo ;gives 0.8
    LStore(2) -> HaloX2 /*OR*/ LStore(2) -> Halo ;gives 0.5

    I thought of splitting the field / fieldvalue list into lists with
    segments of 3's but it seems inefficient.

    Any suggestions?
    Thanks.

    Best regards,
    I-FAB
     
    I-F AB, Mar 26, 2009
    #1
  2. I-F AB wrote, on 03/26/09 04:22:
    You could use something like this:

    LStore=makeTable('LStoreData nil
    LStore[1]=list(nil)
    LStore[1]->LyrField=LyrX1
    LStore[1]->LyrValue="met2"
    LStore[1]->HaloField=HaloX1
    LStore[1]->HaloValue=0.3

    and so on. In other words, use a table to store disembodied property lists. You
    could use a defstruct instead of the DPL if you prefer, since the slots are all
    known in advance.

    I may have misunderstood your question, however...

    Regards,

    Andrew.
     
    Andrew Beckett, Mar 30, 2009
    #2
  3. I-F AB

    I-F AB Guest

    Hi,

    Thanks for the tip, I've realized I've been under-utilising the DPL
    format!
    So, suppose I have a list of fields generated from *** -> fieldList:
    ( LayerExtr1 HaloExtr1 LayTyp1 LayerExtr2 HaloExtr2 LayTyp2 ....
    LayTypN)

    I can transform them with:
    Larr = makeTable( 'ArrayList1 nil )
    for( n 1 length(XTFields)/3
    Larr[n] = list(nil)
    Larr[n]->Type = get(XTForm nthelem(3*n XTFields))->value
    Larr[n]->Layer = get(XTForm nthelem(3*n-2 XTFields))->value
    Larr[n]->Halo = get(XTForm nthelem(3*n-1 XTFields))->value
    )
    Now, I can access the data using:
    Larr[1]->? , Larr[2]->Halo , Larr[N]->Layer , etc.

    Thanks again.

    Best regards,
    I-FAB
     
    I-F AB, Apr 2, 2009
    #3
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.