Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Best way of handling a certain given datastructure

Status
Not open for further replies.

tuxic

Technical User
Dec 12, 2019
3
DE
Hi,

Given is the following form of datastructure
set a { DATE "2019-05-12"
{ PARAMETERS { { NAME "LENGTH" VALUE "100" }
{ NAME "HEIGHT" VALUE "314" }
{ NAME "WEIGHT" VALUE "1000" }
{ NAME "COLOR" VALUE "blue" } ) )

In reality, this datastructure is much bigger. The structure is given by a certain software as a result.
What is the advantage of storeing to key-value pairs which keys are NAME and VALUE and which first value
looks like a key and its second value is the value (instead of storing "real" key-value pairs like "Weight" 1000)?
How can I effectively access this structure to retrieve - say - the COLOR "blue" from it?

Thanks in advance!
 
Maybe a data structure like this could be used to backup several parameter settings from different dates.

For example you could have at 2019-05-12 this set of parameters
LENGTH = "100"
HEIGHT = "314"
WEIGHT = "1000"
COLOR" = "blue"
and on 2019-12-12 a set of parameters like this
LENGTH = "200"
HEIGHT = "614"
WEIGHT = "2000"
COLOR = "red"

The you could store the parameters in a data structure like above and later retrieve for given date the appropriate parameter set like this:

Code:
[COLOR=#a52a2a][b]set[/b][/color] parameters_store [COLOR=#ff0000]\[/color]
{
 { DATE [COLOR=#ff00ff]"2019-05-12"[/color] 
   PARAMETERS { 
       { NAME [COLOR=#ff00ff]"LENGTH"[/color] VALUE [COLOR=#ff00ff]"100"[/color] } 
       { NAME [COLOR=#ff00ff]"HEIGHT"[/color] VALUE [COLOR=#ff00ff]"314"[/color] } 
       { NAME [COLOR=#ff00ff]"WEIGHT"[/color] VALUE [COLOR=#ff00ff]"1000"[/color]} 
       { NAME [COLOR=#ff00ff]"COLOR"[/color] VALUE [COLOR=#ff00ff]"blue"[/color] } } } 
 { DATE [COLOR=#ff00ff]"2019-12-12"[/color] 
   PARAMETERS { 
       { NAME [COLOR=#ff00ff]"LENGTH"[/color] VALUE [COLOR=#ff00ff]"200"[/color] } 
       { NAME [COLOR=#ff00ff]"HEIGHT"[/color] VALUE [COLOR=#ff00ff]"614"[/color] } 
       { NAME [COLOR=#ff00ff]"WEIGHT"[/color] VALUE [COLOR=#ff00ff]"2000"[/color]} 
       { NAME [COLOR=#ff00ff]"COLOR"[/color] VALUE [COLOR=#ff00ff]"red"[/color] } } }
}

[COLOR=#0000ff]#puts $parameters_store[/color]


[COLOR=#0000ff]#puts -nonewline "Enter date (YYYY-MM-DD): "[/color]
[COLOR=#0000ff]#flush stdout[/color]
[COLOR=#0000ff]#set date_search [gets stdin][/color]

[COLOR=#a52a2a][b]set[/b][/color] date_search [COLOR=#ff00ff]"2019-12-12"[/color]
[COLOR=#a52a2a][b]puts[/b][/color] [COLOR=#ff00ff]"Searching for parameters from date: [/color][COLOR=#008b8b]$date_search[/color][COLOR=#ff00ff] .."[/color]

[COLOR=#a52a2a][b]set[/b][/color] parameters_found [COLOR=#ff00ff]0[/color]

[COLOR=#a52a2a][b]foreach[/b][/color] parameter_set [COLOR=#008b8b]$parameters_store[/color] {

  [COLOR=#a52a2a][b]set[/b][/color] date_archive [[COLOR=#a52a2a][b]dict[/b][/color] get [COLOR=#008b8b]$parameter_set[/color] DATE]

  [COLOR=#a52a2a][b]if[/b][/color] {[[COLOR=#a52a2a][b]string[/b][/color] equal [COLOR=#008b8b]$date_archive[/color] [COLOR=#008b8b]$date_search[/color]]} {
    [COLOR=#a52a2a][b]set[/b][/color] parameters_found [COLOR=#ff00ff]1[/color]
    [COLOR=#a52a2a][b]set[/b][/color] parameters_list [[COLOR=#a52a2a][b]dict[/b][/color] get [COLOR=#008b8b]$parameter_set[/color] PARAMETERS]
    [COLOR=#a52a2a][b]puts[/b][/color] [[COLOR=#a52a2a][b]format[/b][/color] [COLOR=#ff00ff]".. found paramaters from %s:[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color] [COLOR=#008b8b]$date_archive[/color]] 
    [COLOR=#a52a2a][b]foreach[/b][/color] p [COLOR=#008b8b]$parameters_list[/color] {
      [COLOR=#a52a2a][b]set[/b][/color] param_name [[COLOR=#a52a2a][b]dict[/b][/color] get [COLOR=#008b8b]$p[/color] NAME]
      [COLOR=#a52a2a][b]set[/b][/color] param_value [[COLOR=#a52a2a][b]dict[/b][/color] get [COLOR=#008b8b]$p[/color] VALUE]
      [COLOR=#a52a2a][b]puts[/b][/color] [[COLOR=#a52a2a][b]format[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#6a5acd]\t[/color][COLOR=#ff00ff]%-6s = [/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]%s[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]"[/color] [COLOR=#008b8b]$param_name[/color] [COLOR=#008b8b]$param_value[/color]]
    }
    [COLOR=#a52a2a][b]break[/b][/color]
  }
}

[COLOR=#a52a2a][b]if[/b][/color] {![COLOR=#008b8b]$parameters_found[/color]} {
 [COLOR=#a52a2a][b]puts[/b][/color] [COLOR=#ff00ff]"No parameters were found for [/color][COLOR=#008b8b]$date_search[/color][COLOR=#ff00ff]."[/color]
}

Output:
Code:
$ tclsh tuxic.tcl
Searching for parameters from date: 2019-12-12 ..
.. found paramaters from 2019-12-12:

	LENGTH = "200"
	HEIGHT = "614"
	WEIGHT = "2000"
	COLOR  = "red"

 
Hi mikrom,

Thank you very much for your answer and your coding! :)

I was astonished about one detail of the layout of that structure:
The usage of NAME and VALUE as keys and (for example) "LENGTH" and "100" as
their values instead of using "LENGTH as key and "100" as its value.

I think (please correct me...that's why I am asking in this forum about this! :) )
that this layout makes a direct access to a searched key-value pair via the dict
command of TCL impossible and one needs a linear search to access a certain
information.

What do you think?
 
Hi tuxic,

I thing the same as you.
For direct searching I would use a dictionary of dictionaries like you mentioned.
From this data structure we could retrieve for given date the appropriate parameter set at similar way:

Code:
[COLOR=#804040][b]set[/b][/color] parameters_store [COLOR=#ff0000]\[/color]
{
 [COLOR=#ff00ff]"2019-05-12"[/color] 
   { LENGTH [COLOR=#ff00ff]"100"[/color] 
     HEIGHT [COLOR=#ff00ff]"314"[/color] 
     WEIGHT [COLOR=#ff00ff]"1000"[/color] 
     COLOR [COLOR=#ff00ff]"blue"[/color]} 
 [COLOR=#ff00ff]"2019-12-12"[/color] 
   { LENGTH [COLOR=#ff00ff]"200"[/color] 
     HEIGHT [COLOR=#ff00ff]"614"[/color]
     WEIGHT [COLOR=#ff00ff]"2000"[/color] 
     COLOR  [COLOR=#ff00ff]"red"[/color]
   }
}

[COLOR=#0000ff]#puts $parameters_store[/color]


[COLOR=#0000ff]#puts -nonewline "Enter date (YYYY-MM-DD): "[/color]
[COLOR=#0000ff]#flush stdout[/color]
[COLOR=#0000ff]#set date_search [gets stdin][/color]

[COLOR=#804040][b]set[/b][/color] date_search [COLOR=#ff00ff]"2019-12-12"[/color]

[COLOR=#0000ff]# direct access individual parameters for given date[/color]
[COLOR=#804040][b]set[/b][/color] param_name [COLOR=#ff00ff]"COLOR"[/color]
[COLOR=#804040][b]if[/b][/color] {[[COLOR=#804040][b]lsearch[/b][/color] [[COLOR=#804040][b]dict[/b][/color] keys [COLOR=#008080]$parameters_store[/color]] [COLOR=#008080]$date_search[/color]] >= [COLOR=#ff00ff]0[/color]} {
  [COLOR=#804040][b]set[/b][/color] parameters_dict [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameters_store[/color] [COLOR=#008080]$date_search[/color]]
  [COLOR=#804040][b]if[/b][/color] {[[COLOR=#804040][b]lsearch[/b][/color] [[COLOR=#804040][b]dict[/b][/color] keys [COLOR=#008080]$parameters_dict[/color]] [COLOR=#008080]$param_name[/color]] >= [COLOR=#ff00ff]0[/color]} {
    [COLOR=#804040][b]set[/b][/color] param_value [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameters_dict[/color] [COLOR=#008080]$param_name[/color]]
    [COLOR=#804040][b]puts[/b][/color] [[COLOR=#804040][b]format[/b][/color] [COLOR=#ff00ff]"parameter [/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]%s[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff] from date [/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]%s[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff] : [/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]%s[/color][COLOR=#6a5acd]\"\n[/color][COLOR=#ff00ff]"[/color] [COLOR=#ff0000]\[/color]
      [COLOR=#008080]$param_name[/color] [COLOR=#008080]$date_search[/color] [COLOR=#008080]$param_value[/color]]
  } [COLOR=#804040][b]else[/b][/color] {
    [COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"A parameter named [/color][COLOR=#6a5acd]\"[/color][COLOR=#008080]$param_name[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff] was not found.[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color]
  }
} [COLOR=#804040][b]else[/b][/color] {
  [COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"No parameters were found for [/color][COLOR=#008080]$date_search[/color][COLOR=#ff00ff].[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color]
}

[COLOR=#0000ff]# searching all parameters for given date[/color]
[COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"Searching for parameters from date: [/color][COLOR=#008080]$date_search[/color][COLOR=#ff00ff] .."[/color]

[COLOR=#804040][b]set[/b][/color] parameters_found [COLOR=#ff00ff]0[/color]

[COLOR=#804040][b]foreach[/b][/color] date_archive [[COLOR=#804040][b]lsort[/b][/color] [[COLOR=#804040][b]dict[/b][/color] keys [COLOR=#008080]$parameters_store[/color]]] {

  [COLOR=#804040][b]if[/b][/color] {[[COLOR=#804040][b]string[/b][/color] equal [COLOR=#008080]$date_archive[/color] [COLOR=#008080]$date_search[/color]]} {
    [COLOR=#804040][b]set[/b][/color] parameters_found [COLOR=#ff00ff]1[/color]
    [COLOR=#804040][b]set[/b][/color] parameters_dict [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameters_store[/color] [COLOR=#008080]$date_archive[/color]]
    [COLOR=#804040][b]puts[/b][/color] [[COLOR=#804040][b]format[/b][/color] [COLOR=#ff00ff]".. found paramaters from %s:[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color] [COLOR=#008080]$date_archive[/color]]
    [COLOR=#804040][b]foreach[/b][/color] param_name [[COLOR=#804040][b]lsort[/b][/color] [[COLOR=#804040][b]dict[/b][/color] keys [COLOR=#008080]$parameters_dict[/color]]] {
      [COLOR=#804040][b]set[/b][/color] param_value [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameters_dict[/color] [COLOR=#008080]$param_name[/color]]
      [COLOR=#804040][b]puts[/b][/color] [[COLOR=#804040][b]format[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#6a5acd]\t[/color][COLOR=#ff00ff]%-6s = [/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]%s[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]"[/color] [COLOR=#008080]$param_name[/color] [COLOR=#008080]$param_value[/color]]      
    }
    [COLOR=#804040][b]break[/b][/color]     
  }  
}

[COLOR=#804040][b]if[/b][/color] {![COLOR=#008080]$parameters_found[/color]} {
 [COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"No parameters were found for [/color][COLOR=#008080]$date_search[/color][COLOR=#ff00ff]."[/color]
}

Output:
Code:
$ tclsh tuxic2.tcl
parameter "COLOR" from date "2019-12-12" : "red"

Searching for parameters from date: 2019-12-12 ..
.. found paramaters from 2019-12-12:

        COLOR  = "red"
        HEIGHT = "614"
        LENGTH = "200"
        WEIGHT = "2000"
 
Hi mikrom,

I am feeling better now... :)

A big thank you for adapting your tcl examples according to the progress in the thread! :)

I initially asked for a way to efficiently access the data structure, because I didn't understand
the reason behind this special NAME "x" VALUE "y" layout thinking of something real "deep TCL", I
had simply overlooked.

But as you also think, that a real key-value layout of a real dictionary would be better for searching, I am sure,
that there is no "deep TCL" behind the NAME "x" VALUE "y" layout -- at least when it comes to retrieving values from it.

May be I get the chance to ask the author of that software (which creates that NAME/VALUE-structure initially), for the
reason for that layout...

Will see...

Thank you very much, mikrom, for your effort to help me and your help!
Cheers! :)
tuxic


 
Hi tuxic,
I have not deep tcl knowledge, but if you have the original data structure as you mentioned, you can transform it programmatically into a simpler data structure you desired.
Here is a little example:

Code:
[COLOR=#0000ff]# -- functions[/color]
[COLOR=#804040][b]proc[/b][/color] create_parameters_for_direct_access {parameters_store} {
  [COLOR=#804040][b]set[/b][/color] parameters_store_result {}
  [COLOR=#804040][b]foreach[/b][/color] parameter_set [COLOR=#008080]$parameters_store[/color] {
[COLOR=#0000ff]    # get date[/color]
    [COLOR=#804040][b]set[/b][/color] param_date [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameter_set[/color] DATE]
[COLOR=#0000ff]    # get list of parameters[/color]
    [COLOR=#804040][b]set[/b][/color] parameters_list [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameter_set[/color] PARAMETERS]
[COLOR=#0000ff]    # transform parameters into dictionary[/color]
    [COLOR=#804040][b]set[/b][/color] parameters_dict {} 
    [COLOR=#804040][b]foreach[/b][/color] p [COLOR=#008080]$parameters_list[/color] {
      [COLOR=#804040][b]set[/b][/color] param_name [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$p[/color] NAME]
      [COLOR=#804040][b]set[/b][/color] param_value [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$p[/color] VALUE]
[COLOR=#0000ff]      # add parameter to dictionary {NAME : VALUE .. }[/color]
      [COLOR=#804040][b]dict[/b][/color] [COLOR=#804040][b]set[/b][/color] parameters_dict [COLOR=#008080]$param_name[/color] [COLOR=#008080]$param_value[/color]
    }
[COLOR=#0000ff]    # add to dictionary DATE: {NAME1: VALUE1 NAME2 : VALUE2 .. }[/color]
    [COLOR=#804040][b]dict[/b][/color] [COLOR=#804040][b]set[/b][/color] parameters_store_result [COLOR=#008080]$param_date[/color] [COLOR=#008080]$parameters_dict[/color] 
  }
[COLOR=#0000ff]  # return resulting dictionary[/color]
  [COLOR=#804040][b]return[/b][/color] [COLOR=#008080]$parameters_store_result[/color]
}

[COLOR=#804040][b]proc[/b][/color] get_param_value {parameters_store date_search param_name} {
  [COLOR=#804040][b]set[/b][/color] result_value {} 
  [COLOR=#804040][b]if[/b][/color] {[[COLOR=#804040][b]lsearch[/b][/color] [[COLOR=#804040][b]dict[/b][/color] keys [COLOR=#008080]$parameters_store[/color]] [COLOR=#008080]$date_search[/color]] >= [COLOR=#ff00ff]0[/color]} {
    [COLOR=#804040][b]set[/b][/color] parameters_dict [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameters_store[/color] [COLOR=#008080]$date_search[/color]]
    [COLOR=#804040][b]if[/b][/color] {[[COLOR=#804040][b]lsearch[/b][/color] [[COLOR=#804040][b]dict[/b][/color] keys [COLOR=#008080]$parameters_dict[/color]] [COLOR=#008080]$param_name[/color]] >= [COLOR=#ff00ff]0[/color]} {
      [COLOR=#804040][b]set[/b][/color] param_value [[COLOR=#804040][b]dict[/b][/color] get [COLOR=#008080]$parameters_dict[/color] [COLOR=#008080]$param_name[/color]]
      [COLOR=#804040][b]set[/b][/color] result_value [COLOR=#008080]$param_value[/color]
    }
  }
  [COLOR=#804040][b]return[/b][/color] [COLOR=#008080]$result_value[/color]
}

[COLOR=#804040][b]proc[/b][/color] get_parameter {data_structure date name} {
  [COLOR=#804040][b]set[/b][/color] param_val [get_param_value [COLOR=#008080]$data_structure[/color] [COLOR=#008080]$date[/color] [COLOR=#008080]$name[/color]]
  [COLOR=#804040][b]if[/b][/color] {[[COLOR=#804040][b]string[/b][/color] equal [COLOR=#008080]$param_val[/color] [COLOR=#ff00ff]""[/color]]} {
    [COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"* ERROR: value for date=[/color][COLOR=#6a5acd]\"[/color][COLOR=#008080]$date[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff] and name=[/color][COLOR=#6a5acd]\"[/color][COLOR=#008080]$name[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff] not found !"[/color]
  } [COLOR=#804040][b]else[/b][/color] {
    [COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"[/color][COLOR=#008080]$date[/color][COLOR=#ff00ff]: [/color][COLOR=#008080]$name[/color][COLOR=#ff00ff] = [/color][COLOR=#6a5acd]\"[/color][COLOR=#008080]$param_val[/color][COLOR=#6a5acd]\"[/color][COLOR=#ff00ff]"[/color]
  }
}

[COLOR=#0000ff]# --- main program ---[/color]

[COLOR=#0000ff]# data structure given[/color]
[COLOR=#804040][b]set[/b][/color] parameters_store [COLOR=#ff0000]\[/color]
{
 { DATE [COLOR=#ff00ff]"2019-05-12"[/color] 
   PARAMETERS { 
       { NAME [COLOR=#ff00ff]"LENGTH"[/color] VALUE [COLOR=#ff00ff]"100"[/color] } 
       { NAME [COLOR=#ff00ff]"HEIGHT"[/color] VALUE [COLOR=#ff00ff]"314"[/color] } 
       { NAME [COLOR=#ff00ff]"WEIGHT"[/color] VALUE [COLOR=#ff00ff]"1000"[/color]} 
       { NAME [COLOR=#ff00ff]"COLOR"[/color] VALUE [COLOR=#ff00ff]"blue"[/color] } } } 
 { DATE [COLOR=#ff00ff]"2019-12-12"[/color] 
   PARAMETERS { 
       { NAME [COLOR=#ff00ff]"LENGTH"[/color] VALUE [COLOR=#ff00ff]"200"[/color] } 
       { NAME [COLOR=#ff00ff]"HEIGHT"[/color] VALUE [COLOR=#ff00ff]"614"[/color] } 
       { NAME [COLOR=#ff00ff]"WEIGHT"[/color] VALUE [COLOR=#ff00ff]"2000"[/color]} 
       { NAME [COLOR=#ff00ff]"COLOR"[/color] VALUE [COLOR=#ff00ff]"red"[/color] } } }
}

[COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"original data structure:[/color][COLOR=#6a5acd]\n\t[/color][COLOR=#008080]$parameters_store[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color]

[COLOR=#0000ff]# create new data structure [/color]
[COLOR=#804040][b]set[/b][/color] parameters_store_direct_access [COLOR=#ff0000]\[/color]
  [create_parameters_for_direct_access [COLOR=#008080]$parameters_store[/color]]

[COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"new data structure:[/color][COLOR=#6a5acd]\n\t[/color][COLOR=#ff00ff]{[/color][COLOR=#008080]$parameters_store_direct_access[/color][COLOR=#ff00ff]}[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color]

[COLOR=#0000ff]# access values in the new dictionary[/color]
[COLOR=#804040][b]puts[/b][/color] [COLOR=#ff00ff]"Accessing individual parameters for given date:[/color][COLOR=#6a5acd]\n[/color][COLOR=#ff00ff]"[/color]
get_parameter [COLOR=#008080]$parameters_store_direct_access[/color] [COLOR=#ff00ff]"2019-05-12"[/color] [COLOR=#ff00ff]"COLOR"[/color]
get_parameter [COLOR=#008080]$parameters_store_direct_access[/color] [COLOR=#ff00ff]"2019-05-12"[/color] [COLOR=#ff00ff]"FOO"[/color]
get_parameter [COLOR=#008080]$parameters_store_direct_access[/color] [COLOR=#ff00ff]"2019-11-11"[/color] [COLOR=#ff00ff]"COLOR"[/color]
get_parameter [COLOR=#008080]$parameters_store_direct_access[/color] [COLOR=#ff00ff]"2019-12-12"[/color] [COLOR=#ff00ff]"COLOR"[/color]
get_parameter [COLOR=#008080]$parameters_store_direct_access[/color] [COLOR=#ff00ff]"2019-05-12"[/color] [COLOR=#ff00ff]"HEIGHT"[/color]
get_parameter [COLOR=#008080]$parameters_store_direct_access[/color] [COLOR=#ff00ff]"2019-12-12"[/color] [COLOR=#ff00ff]"WEIGHT"[/color]

Output:
Code:
$ tclsh tuxic3.tcl
original data structure:

 { DATE "2019-05-12"
   PARAMETERS {
       { NAME "LENGTH" VALUE "100" }
       { NAME "HEIGHT" VALUE "314" }
       { NAME "WEIGHT" VALUE "1000"}
       { NAME "COLOR" VALUE "blue" } } }
 { DATE "2019-12-12"
   PARAMETERS {
       { NAME "LENGTH" VALUE "200" }
       { NAME "HEIGHT" VALUE "614" }
       { NAME "WEIGHT" VALUE "2000"}
       { NAME "COLOR" VALUE "red" } } }


new data structure:
        {2019-05-12 {LENGTH 100 HEIGHT 314 WEIGHT 1000 COLOR blue} 2019-12-12 {LENGTH 200 HEIGHT 614 WEIGHT 2000 COLOR red}}

Accessing individual parameters for given date:

2019-05-12: COLOR = "blue"
* ERROR: value for date="2019-05-12" and name="FOO" not found !
* ERROR: value for date="2019-11-11" and name="COLOR" not found !
2019-12-12: COLOR = "red"
2019-05-12: HEIGHT = "314"
2019-12-12: WEIGHT = "2000"


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top