Simple Array problem(unable to pass to a procedure)
- From: anand kumar <kumar.anand743@xxxxxxxxx>
- Date: Thu, 31 May 2012 04:09:25 -0700 (PDT)
Hi
I am a newbie to TCL/TK. I wrote a simple program to create a data
structure using arrays. The following is the code
-----------------------------------------------------------------------------------------------------------------------------------------------------------
#Following is the procedure which creates a data structure using
arrays for an argument list passed to it
proc create_data_table {arg_list} {
puts "Argument list passed to procedure : $arg_list"
foreach {key data} $arg_list {
set data_table($key) $data
puts "Key $key : Data $data_table($key)"
}
}
#Following is the data processing procedure which takes a data
structure as an argument
proc data_process {data_table_list} {
array set my_data_table_list $data_table_list
foreach {key} $my_data_table_list {
puts "Processing $key with Data $my_data_table_list($key)"
}
puts "End of dummy process\n"
}
#Following is the declaration of my data_structure as a global
global data_table
array set data_table {}
#Following is the simple loop to create a list from command line
arguments
set arglist {}
foreach argument $argv {
lappend arglist $argument
}
puts $arglist
# Create the data structure by calling the process "create data table"
create_data_table $arglist
# Call the data processing procedure by serializing the array through
the list using "array get" command
data_process [array get $data_table]
-----------------------------------------------------------------------------------------------------------------------------------------------------------
I save the file as arr_data_struct.tcl and in my cygwin terminal, I
run the following
%tclsh arr_data_struct.tcl data1 key1 data2 key2 data3 key3 data4 key4
The error that flags is as follows :-
can't read "map_table": variable is array
while executing "data_process [array get $data_table]"
(file "dummy_map_test.tcl" line 41)
Please help me in understanding the error and what s going wrong
Thank you
.
- Follow-Ups:
- Re: Simple Array problem(unable to pass to a procedure)
- From: Charlie Bursell
- Re: Simple Array problem(unable to pass to a procedure)
- From: Arjen Markus
- Re: Simple Array problem(unable to pass to a procedure)
- From: Eugene
- Re: Simple Array problem(unable to pass to a procedure)
- Prev by Date: Re: Excel column numbers to letters
- Next by Date: Re: proc named "#"
- Previous by thread: Making public/private tcl proc pairs
- Next by thread: Re: Simple Array problem(unable to pass to a procedure)
- Index(es):
Relevant Pages
|