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

  • SEARCH
  • Home
  • 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 3666118
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T01:50:31+00:00 2026-05-19T01:50:31+00:00

Am attempting to teach myself to program using Tcl. (I want to become more

  • 0

Am attempting to teach myself to program using Tcl. (I want to become more familiar with the language to understand someone else’s code – SCID chess)
The task i’ve set myself to motivate my learing of Tcl is to solve the 8 queens problem.
My approach to creating a program is to sucessively ‘prototype’ a solution.
So.
I’m up to nesting a for loop holding the q pos on row 2
inside the for loop holding the q pos on row 1

Here is my code

set allowd 1
set notallowd 0

for {set r1p 1} {$r1p <= 8} {incr r1p } {
    puts "1st row q placed at $r1p" 
    ;# re-initialize r2 'free for q placemnt' array after every change of r1 q pos:
    for {set i 1 } {$i <= 8} {incr i} { set r2($i) $allowd    }

    for { set r2($r1p) $notallowd ; set r2([eval $r1p-1]) $notallowd ;
           set r2([eval $r1p+1]) $notallowd ; set r2p 1}   {$r2p <= 8} {
         incr r2p ;# end of 'next' arg of r2 forloop
        }
        ;# commnd arg of r2 forloop placed below: 
        {puts "2nd row q placed at $r2p"    
    }
} 

My problem is that when i run the code the interpreter is aborting with the fatal error:
“wrong #args should be for start test next command.

I’ve gone over my code a few times and can’t see that i’ve missed any of the for loop arguments.

  • 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-05-19T01:50:32+00:00Added an answer on May 19, 2026 at 1:50 am

    The carriage return before the command in the last for loop is what’s getting you. From the first syntax rule on the Tcl man page, “Semi-colons and newlines are command separators unless quoted as described below.” BTW, your eval’s should be expr’s.

    This works for me:

    set allowd 1
    set notallowd 0
    
    for {set r1p 1} {$r1p <= 8} {incr r1p } {
        puts "1st row q placed at $r1p" 
        ;# re-initialize r2 'free for q placemnt' array after every change of r1 q pos:
        for {set i 1 } {$i <= 8} {incr i} { set r2($i) $allowd    }
    
        for { set r2($r1p) $notallowd ; set r2([expr $r1p-1]) $notallowd ;
            set r2([expr $r1p+1]) $notallowd ; set r2p 1}   {$r2p <= 8} {
            incr r2p ;# end of 'next' arg of r2 forloop
        } {
            # commnd arg of r2 forloop placed below: 
            puts "2nd row q placed at $r2p"    
        }
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Am attempting to teach myself to program using Tcl. The task i've set myself
I'm just starting to teach myself objective-c and attempting to learn the cocoa touch
I am trying to teach myself Lucene.Net to implement on my site. I understand
I've been attempting to teach myself Ruby over the past while and I've been
Attempting to set up Samba + OpenLDAP using nss_ldap. After joining Windows7 to Samba
Attempting to generics-ify some legacy code, I'm stuck. I have a ParentObject which wraps
Attempting to compile the following code under Qt SDK 4.7.4 for Desktop - MinGW
I'm working through a CSV importing approach that I want to teach to other
Attempting to follow the directions as specified on http://code.google.com/p/gears/wiki/BuildingGearsForWindows my attempts are failing at
I am attempting to use Powershell to automate the builds of projects using a

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.