Forum Discussion
tidenz_92110
Nimbostratus
Jul 26, 2010Data Class to array
Hi Guys,
I am trying to reference a new external data class and read the contents into an array.
class URL_LIST
"/help" := "www.companya.com/help/get"
foreach item [class get URL_LIST] {
set index [findstr $item "" 0 ":="]
set data [findstr $item ":=" 1 "\n"]
set LIST "$index $data"
set ::ARRAY($index) $data
however when i debug
log local0.debug [array size ::ARRAY] i get 2 entries
and if i log both index and data i only get stuff in index. so it looks like the value is not parsed into data.
any idea's i have been stuffing around but i think i am missing something basic.
Is there a better way to read a data class into an array?
Thanks
- hoolio
Cirrostratus
Hi Tidenz,log local0. "[class get my_strings_class]" if {[array exists my_array]}{ array unset my_array } foreach line [class get my_strings_class] { log local0. "Adding \$line to array: $line" set my_array([lindex $line 0]) [lindex $line 1] } log local0. "\[array get my_array\]: [array get my_array]"
- tidenz_92110
Nimbostratus
Hi Aaron, - hoolio
Cirrostratus
I was assuming that you really need to use an array for some reason and that if that was true that it would be more efficient to get all of the datagroup elements in one go. Once you have the datagroup as a TCL list, it doesn't matter whether you access that data as a TCL list or not.
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects