Forum Discussion

Cindy_Berry_103's avatar
Cindy_Berry_103
Icon for Nimbostratus rankNimbostratus
Aug 14, 2012

How to create a Datagroup with Multiple values

I would like to create an external datagroup that contains multiple values for one key. I have seen the following format posted several different locations....

External Class Format:

class namevalue {

"name1" := "value",

"name2" := "value",

}

 

However, I would like my external format to look like this, and be able to reference values1 and values 2 based on the key.

 

External Class Format:

class namevalue {

"name1" := "value1", "value2" ,

"name2" := "value", "value2",

}

 

 

For instance, in the scenario that I am using this in the file format might look similar to the following:

 

"/ug/atl" := “http”,"/a7391/events/live/20110403/regions.php?region=atl",
"/ug/sea" := "http”,“/a2416/events/live/20100602/regions.php?region=sea",
"/ug/nyc" := “https”,“/a1753/0524611/live/20100714/regions.php?region=nyc",
"/ug/la" := "https”,“/a6542/0316327/live/20100312/regions.php?region=la",
I am sure that my format is incorrect...but, this might give me some more 
flexibility if I can reference a couple of different values per key.

  • Hi Cindy,

     

     

    You can do this almost exactly as you have it listed--just combine the two values into one string:

     

     

    "/ug/atl" := “http,/a7391/events/live/20110403/regions.php?region=atl",

     

     

    You can then use the class command to get the value:

     

     

    Get the combined value for $find in the $datagroup

     

    set value [class lookup $find $datagroup]

     

    if {$value ne }{

     

     

    Use scan to separate the two values

     

    scan $value {%[^,],%s} value1 value2

     

    log local0. "Parsed $value1 and $value2"

     

    }

     

     

    Aaron