Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7803747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T01:41:06+00:00 2026-06-02T01:41:06+00:00

I need some help in defining arrays and displaying and looping thrrough them in

  • 0

I need some help in defining arrays and displaying and looping thrrough them in TCL.

Here is how I would do them in php.

$date =array();
$size=0;
$date[$size] =$pre_event_date;
/* After doing some manpulation and calculations with $size */
for($i=0;$i<=$size;$i++){
    echo $date[$i];
}

I would like to do the same with tcl.Is the following code appropriate?

set size 0
set date[$size] $pre_event_date
#After performing some manipulation
for {set i 0} { $i <=$size } {incr i} {
    puts "$date[$i]";
}

Also can I define set $date as an array. Some like like:

set date array();

So i edited my code tried a simple test using RSeeger’s array implementation:

set date(0) 35
set date(1)  40
foreach key [array names date]{
   puts "${key}=$date($key)"
}

the above doesnt return anything there is probably some error.
I also tried:
puts $date($key) without quotes but that doesnt work either.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T01:41:08+00:00Added an answer on June 2, 2026 at 1:41 am

    If you’re looking to index things by number (which your code implies), use a list. It is analogous to an array in C.

    set mylist {}
    lappend mylist a
    lappend mylist b
    lappend mylist c
    lappend mylist d
    foreach elem $mylist {
        puts $elem
    }
    // or if you really want to use for
    for {set i 0} {$i < [length $mylist]} {incr i} {
        puts "${i}=[lindex $mylist $i]"
    }
    

    If you want to index things by string (or have a sparse list), you can use an array, which is a hashmap of key->value.

    set myarr(chicken) animal
    set myarr(cows) animal
    set myarr(rock) mineral
    set myarr(pea) vegetable
    
    foreach key [array names myarr] {
        puts "${key}=$myarr($key)"
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need some help about PHP GD. Here is my piece of code. header(Content-type:
I need some help with allocating arrays dynamically. I have an array whose size
I need some help defining the following object hierarchy/ database relationship in Hibernate From
Hi I am using CodeIgniter with DataMapper and really need some help defining relationship
Need some help understanding the difference between the success and ajaxSuccess events documented here
need some help here My problem is, my app starts with a single view,
I need some help with defining a dynamic method. Basically, I have many classes
need some help with adding extra time to current time currentTime= new Date(); var
Need some help understanding if I'm on the right track here and exactly what
Need some help... I have jasperserver 4.1 installed on my ubuntu. It runs via

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.