Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Deleting empty array element

0 views
Skip to first unread message

Don

unread,
Jan 25, 2002, 11:41:59 AM1/25/02
to
Is there a way to remave an array element, while retaining the other
elements in the array?

I am pulling in values from an Excel spreadsheet and some of the cells are
blank, but the array is adding these to it's list of elements with a null
(maybe empty string) element.

Thanks,
Don


Neil Madden

unread,
Jan 25, 2002, 1:00:13 PM1/25/02
to
Something like:

% set a(something) "Foo"
Foo
% set a() "Bar"
Bar
% parray a
a() = Bar
a(something) = Foo
% unset a()
% parray a
a(something) = Foo

i.e. just unset the unused elements.

Neil Madden

unread,
Jan 25, 2002, 1:03:29 PM1/25/02
to
Just thought - if you are actually wanting to remove blank items (i.e.
might have non-blank index), then the following will do it:
foreach {index item} [array get a] {
if {![string length $item]} {
unset a($index)
0 new messages